Skip to contentSkip to conversation

mmc: Update environment variable with active partition

PATCH Superseded Reuben Dowle 3 participants 4 messages May 13, 2021

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mmc: Update environment variable with active partition

This patch allows uboot scripts make choices about where to boot from based on the active mmc boot partition. This allows having two copies of kernel, filesystems etc, and choosing which to boot from based off of the active bootloader partition.

---
 cmd/mmc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
cmd/mmc.c +9 -5
index a10f137..b942576 100644
@@ -808,7 +808,7 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,
 	return CMD_RET_SUCCESS;
 }
 
-static int mmc_partconf_print(struct mmc *mmc)
+static int mmc_partconf_print(struct mmc *mmc, const char *varname)
 {
 	u8 ack, access, part;
 
@@ -821,6 +821,9 @@ static int mmc_partconf_print(struct mmc *mmc)
 	ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config);
 	part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
 
+	if(varname)
+		env_set_hex(varname, part);
+
 	printf("EXT_CSD[179], PARTITION_CONFIG:\n"
 		"BOOT_ACK: 0x%x\n"
 		"BOOT_PARTITION_ENABLE: 0x%x\n"
@@ -836,7 +839,7 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
 	struct mmc *mmc;
 	u8 ack, part_num, access;
 
-	if (argc != 2 && argc != 5)
+	if (argc != 2 && argc != 3 && argc != 5)
 		return CMD_RET_USAGE;
 
 	dev = simple_strtoul(argv[1], NULL, 10);
@@ -850,8 +853,8 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
 		return CMD_RET_FAILURE;
 	}
 
-	if (argc == 2)
-		return mmc_partconf_print(mmc);
+	if (argc == 2 || argc == 3)
+		return mmc_partconf_print(mmc, argc == 3 ? argv[2] : NULL);
 
 	ack = simple_strtoul(argv[2], NULL, 10);
 	part_num = simple_strtoul(argv[3], NULL, 10);
@@ -1061,8 +1064,9 @@ U_BOOT_CMD(
 	" - Set the BOOT_BUS_WIDTH field of the specified device\n"
 	"mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
 	" - Change sizes of boot and RPMB partitions of specified device\n"
-	"mmc partconf <dev> [boot_ack boot_partition partition_access]\n"
+	"mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]\n"
 	" - Show or change the bits of the PARTITION_CONFIG field of the specified device\n"
+	"   If showing the bits, optionally store the boot_partition field into varname\n"
 	"mmc rst-function <dev> <value>\n"
 	" - Change the RST_n_FUNCTION field of the specified device\n"
 	"   WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n"
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/1 mmc: Update environment variable with active partition

Hi Reuben,

Quoted 4 lines · Reuben Dowle

This patch allows uboot scripts make choices about where to boot from based on the active mmc boot partition. This allows having two copies of kernel, filesystems etc, and choosing which to boot from based off of the active bootloader partition.

Could you also update doc/usage/mmc.rst?

Quoted 2 lines

Best Regards,
Jaehoon Chung

Quoted 59 lines
---
 cmd/mmc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
cmd/mmc.c +9 -5
index a10f137..b942576 100644
@@ -808,7 +808,7 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,
 	return CMD_RET_SUCCESS;
 }
 
-static int mmc_partconf_print(struct mmc *mmc)
+static int mmc_partconf_print(struct mmc *mmc, const char *varname)
 {
 	u8 ack, access, part;
 
@@ -821,6 +821,9 @@ static int mmc_partconf_print(struct mmc *mmc)
 	ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config);
 	part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
 
+	if(varname)
+		env_set_hex(varname, part);
+
 	printf("EXT_CSD[179], PARTITION_CONFIG:\n"
 		"BOOT_ACK: 0x%x\n"
 		"BOOT_PARTITION_ENABLE: 0x%x\n"
@@ -836,7 +839,7 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
 	struct mmc *mmc;
 	u8 ack, part_num, access;
 
-	if (argc != 2 && argc != 5)
+	if (argc != 2 && argc != 3 && argc != 5)
 		return CMD_RET_USAGE;
 
 	dev = simple_strtoul(argv[1], NULL, 10);
@@ -850,8 +853,8 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
 		return CMD_RET_FAILURE;
 	}
 
-	if (argc == 2)
-		return mmc_partconf_print(mmc);
+	if (argc == 2 || argc == 3)
+		return mmc_partconf_print(mmc, argc == 3 ? argv[2] : NULL);
 
 	ack = simple_strtoul(argv[2], NULL, 10);
 	part_num = simple_strtoul(argv[3], NULL, 10);
@@ -1061,8 +1064,9 @@ U_BOOT_CMD(
 	" - Set the BOOT_BUS_WIDTH field of the specified device\n"
 	"mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
 	" - Change sizes of boot and RPMB partitions of specified device\n"
-	"mmc partconf <dev> [boot_ack boot_partition partition_access]\n"
+	"mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]\n"
 	" - Show or change the bits of the PARTITION_CONFIG field of the specified device\n"
+	"   If showing the bits, optionally store the boot_partition field into varname\n"
 	"mmc rst-function <dev> <value>\n"
 	" - Change the RST_n_FUNCTION field of the specified device\n"
 	"   WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n"
#2 lore raw

PATCH v3 1/1 mmc: Update environment variable with active partition

Quoted 4 lines

Could you also update doc/usage/mmc.rst?

I have sent a v4 patch that also updates the documentation.

#3 lore raw

PATCH v3 1/1 mmc: Update environment variable with active partition

Quoted 6 lines · Reuben Dowle
Quoted 4 lines

Could you also update doc/usage/mmc.rst?

I have sent a v4 patch that also updates the documentation.

Thank you!

Best Regards,
Jaehoon Chung

Quoted 27 lines

________________________________

[cid:4RFLogo(Custom)(2)_0f31a7de-6dd6-43cf-bc6a-a097a2b80b69.jpg] Reuben Dowle
Software Architect

Phone:

Fax:
E-Mail:
Website:

+64 4 499 6000

+64 4 473 4447
reuben.dowle at 4rf.com<mailto:[email protected]>
https://protect2.fireeye.com/v1/url?k=36d0d29e-694beb95-36d159d1-002590f5b904-2debe5e0a90c035e&q=1&e=ff3585ce-8e60-46cc-9aaf-ae5b55b985c7&u=https%3A%2F%2Fwww.4rf.com%2F<https://protect2.fireeye.com/v1/url?k=de6dd9d1-81f6e0da-de6c529e-002590f5b904-899aefd52c6e7aca&q=1&e=ff3585ce-8e60-46cc-9aaf-ae5b55b985c7&u=https%3A%2F%2Fwww.4rf.com%2F>

________________________________

[cid:Family_53c410b1-7227-4a5f-9acb-f09bd7617a39.png] <https://protect2.fireeye.com/v1/url?k=af634559-f0f87c52-af62ce16-002590f5b904-bf3890c92039dd39&q=1&e=ff3585ce-8e60-46cc-9aaf-ae5b55b985c7&u=http%3A%2F%2Fwww.4rf.com%2Fnews%2Fevents>

________________________________
The information in this email communication (inclusive of attachments) is confidential to 4RF Limited and the intended recipient(s). If you are not the intended recipient(s), please note that any use, disclosure, distribution or copying of this information or any part thereof is strictly prohibited and that the author accepts no liability for the consequences of any action taken on the basis of the information provided. If you have received this email in error, please notify the sender immediately by return email and then delete all instances of this email from your system. 4RF Limited will not accept responsibility for any consequences associated with the use of this email (including, but not limited to, damages sustained as a result of any viruses and/or any action or lack of action taken in reliance on it).