cmd: mmc: add mmc partboot
PATCH 1/1 cmd: mmc: add mmc partboot
This patch allows to determine active boot partition in boot script:
if mmc partboot ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
fi
--- cmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
cmd/mmc.c +39 -0
@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,return CMD_RET_SUCCESS ; } +static int do_mmc_partboot (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false); +if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +puts ("PARTITION_CONFIG only exists on eMMC\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { +printf ("No part_config info for ver. 0x%x\n" , mmc->version); +return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;
@@ -953,6 +988,7 @@ static struct cmd_tbl cmd_mmc[] = {#ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ),U_BOOT_CMD_MKENT (bootpart-resize,4 ,0 , do_mmc_boot_resize,"" ,"" ), +U_BOOT_CMD_MKENT (partboot,3 ,0 , do_mmc_partboot,"" ,"" ),U_BOOT_CMD_MKENT (partconf,5 ,0 , do_mmc_partconf,"" ,"" ), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""), #endif
@@ -1021,6 +1057,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 partboot dev boot_partition\n" +" - Return success if the given boot_partition value matches BOOT_PARTITION_ENABLE\n" +" bit field of the specified device\n" "mmc partconf dev [boot_ack boot_partition partition_access]\n" " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n" "mmc rst-function dev value\n"
Signature · 1 line
2.25.1
PATCH 1/1 cmd: mmc: add mmc partboot
Dear Grygorii,
Quoted 5 lines · grygorii tertychnyi
This patch allows to determine active boot partition in boot script:
if mmc partboot ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
fi
I don't know what purpose this patch has.
Best Regards,
Jaehoon Chung
Quoted 71 lines
Signed-off-by Grygorii Tertychnyi <[email protected]>--- cmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)cmd/mmc.c +39
-0@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,return CMD_RET_SUCCESS ; } +static int do_mmc_partboot (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false); +if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +puts ("PARTITION_CONFIG only exists on eMMC\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { +printf ("No part_config info for ver. 0x%x\n" , mmc->version); +return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;@@ -953,6 +988,7 @@ static struct cmd_tbl cmd_mmc[] = {#ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ),U_BOOT_CMD_MKENT (bootpart-resize,4 ,0 , do_mmc_boot_resize,"" ,"" ), +U_BOOT_CMD_MKENT (partboot,3 ,0 , do_mmc_partboot,"" ,"" ),U_BOOT_CMD_MKENT (partconf,5 ,0 , do_mmc_partconf,"" ,"" ), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""), #endif@@ -1021,6 +1057,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 partboot dev boot_partition\n" +" - Return success if the given boot_partition value matches BOOT_PARTITION_ENABLE\n" +" bit field of the specified device\n" "mmc partconf dev [boot_ack boot_partition partition_access]\n" " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n" "mmc rst-function dev value\n"
PATCH 1/1 cmd: mmc: add mmc partboot
Hello Jaehoon,
Quoted 10 lines · On Sun, 14 Feb 2021 at 23:08 Jaehoon Chung <[email protected]> wrote:
Dear Grygorii,
Quoted 5 lines · grygorii tertychnyi
This patch allows to determine active boot partition in boot script:
if mmc partboot ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
fiI don't know what purpose this patch has.
With an eMMC as a boot source I have two boot partitions, i.e. ?boot1? and ?boot2?, with two different versions of U-Boot on each partition.
I also have two different kernels located on eMMC ?user? partition, let?s say ?image1? and ?image2?.
So, I want to boot ?image1? kernel if it is U-boot from ?boot1? partition is booted now,
and to boot ?image2? kernel if it is U-boot from ?boot2? partition is booted.
It is easy to do it manually. I just added possibility to do it with U-boot script now,
because ?mmc partconf ...? does not let you check the current boot partition with hush.
Hope, I explained the purpose.
Quoted 84 lines
Best Regards,
Jaehoon ChungQuoted 2 lines
Signed-off-by Grygorii Tertychnyi <grygorii.tertychnyi at leica-geosystems.com>
cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl
Quoted 9 lines
--- cmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)cmd/mmc.c +0
-0@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl*cmdtp, int flag,
Quoted 16 lines
cmd/mmc.c +13
-0return CMD_RET_SUCCESS ; } +static int do_mmc_partboot (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false);cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,
Quoted 10 lines
cmd/mmc.c +10
-0+if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +puts ("PARTITION_CONFIG only exists on eMMC\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { + printf("No part_config info for ver. 0x%x\n",
mmc->version);Quoted 16 lines
cmd/mmc.c +12
-0+return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 990
Quoted 3 lines
cmd/mmc.c +0
-0@@ -953,6 +988,7 @@ static struct cmd_tbl cmd_mmc[] = {#ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ), U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "",""),
cmd/mmc.c U_BOOT_CMD( · line 1058
Quoted 7 lines
cmd/mmc.c +1
-0+U_BOOT_CMD_MKENT (partboot,3 ,0 , do_mmc_partboot,"" ,"" ),U_BOOT_CMD_MKENT (partconf,5 ,0 , do_mmc_partconf,"" ,"" ), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""), #endif@@ -1021,6 +1057,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 sizeMB>\n"
cmd/mmc.c U_BOOT_CMD(
Quoted 3 lines
cmd/mmc.c +2
-0" - Change sizes of boot and RPMB partitions of specified device\n" +"mmc partboot dev boot_partition\n" + " - Return success if the given boot_partition value matchesBOOT_PARTITION_ENABLE\n"
cmd/mmc.c U_BOOT_CMD(
Quoted 3 lines
cmd/mmc.c +1
-0+" bit field of the specified device\n" "mmc partconf dev [boot_ack boot_partition partition_access]\n" " - Show or change the bits of the PARTITION_CONFIG field of thespecified device\n"
Quoted 2 lines
cmd/mmc.c +0
-0"mmc rst-function dev value\n"
PATCH 1/1 cmd: mmc: add mmc partboot
Hi Grygorii,
Quoted 27 lines · gr embeter
Hello Jaehoon,
Quoted 10 lines · On Sun, 14 Feb 2021 at 23:08 Jaehoon Chung <[email protected]> wrote:
Dear Grygorii,
Quoted 5 lines · grygorii tertychnyi
This patch allows to determine active boot partition in boot script:
if mmc partboot ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
fiI don't know what purpose this patch has.
With an eMMC as a boot source I have two boot partitions, i.e. ?boot1? and ?boot2?, with two different versions of U-Boot on each partition.
I also have two different kernels located on eMMC ?user? partition, let?s say ?image1? and ?image2?.
So, I want to boot ?image1? kernel if it is U-boot from ?boot1? partition is booted now,
and to boot ?image2? kernel if it is U-boot from ?boot2? partition is booted.
Quoted 6 lines
It is easy to do it manually. I just added possibility to do it with U-boot script now,
because ?mmc partconf ...? does not let you check the current boot partition with hush.Hope, I explained the purpose.
I remembered. Because i feel to see similar patch to use bootpart. At that time, i also asked same question. Sorry for not remembered yours.
https://patchwork.ozlabs.org/project/uboot/patch/20201212074633.891704-1-grembeter at outlook.com/
Quoted 67 lines
Quoted 67 lines
Best Regards,
Jaehoon ChungQuoted 2 lines
Signed-off-by Grygorii Tertychnyi <grygorii.tertychnyi at leica-geosystems.com>
cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl
Quoted 9 lines
--- cmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)cmd/mmc.c +0
-0@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl*cmdtp, int flag,
Quoted 16 lines
cmd/mmc.c +13
-0return CMD_RET_SUCCESS ; } +static int do_mmc_partboot (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false);cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,
Quoted 10 lines
cmd/mmc.c +10
-0+if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +puts ("PARTITION_CONFIG only exists on eMMC\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { + printf("No part_config info for ver. 0x%x\n",
mmc->version);Quoted 16 lines
cmd/mmc.c +12
-0+return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 990
Quoted 3 lines
cmd/mmc.c +0
-0@@ -953,6 +988,7 @@ static struct cmd_tbl cmd_mmc[] = {#ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ), U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "",""),
Quoted 1 line
Quoted 1 line
cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 991
Quoted 1 line
cmd/mmc.c +1
-0+ U_BOOT_CMD_MKENT(partboot, 3, 0, do_mmc_partboot, "", ""),
partboot can be confused. how about changing more clear name, like mmc_bootpart_check?
Quoted 9 lines
Quoted 9 lines
cmd/mmc.c U_BOOT_CMD( · line 1058
Quoted 6 lines
cmd/mmc.c +0
-0U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""),#endif @@ -1021,6 +1057,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 sizeMB>\n"
Quoted 2 lines
cmd/mmc.c +1
-0" - Change sizes of boot and RPMB partitions of specified device\n" +"mmc partboot dev boot_partition\n"
why it needs to pass "boot_partition"?
And use more clear usage..with optional or mandatory. <> - mandatory
[] - optional
mmc partboot <dev>
Quoted 11 lines
Quoted 10 lines
cmd/mmc.c U_BOOT_CMD( · line 1061
Quoted 1 line
cmd/mmc.c +1
-0+ " - Return success if the given boot_partition value matchesBOOT_PARTITION_ENABLE\n"
cmd/mmc.c U_BOOT_CMD(
Quoted 3 lines
cmd/mmc.c +1
-0+" bit field of the specified device\n" "mmc partconf dev [boot_ack boot_partition partition_access]\n" " - Show or change the bits of the PARTITION_CONFIG field of thespecified device\n"
Quoted 2 lines
cmd/mmc.c +0
-0"mmc rst-function dev value\n"
PATCH 1/1 cmd: mmc: add mmc partboot
Hi Jaehoon,
thanks for your comments.
Quoted 38 lines · On Tue, 16 Feb 2021 at 00:30 Jaehoon Chung <[email protected]> wrote:
Hi Grygorii,
Quoted 3 lines · gr embeter
Hello Jaehoon,
On Sun, 14 Feb 2021 at 23:08 Jaehoon Chung <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
Dear Grygorii,
Quoted 2 lines · grygorii tertychnyi
This patch allows to determine active boot partition in boot script:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
if mmc partboot ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
fiI don't know what purpose this patch has.
With an eMMC as a boot source I have two boot partitions, i.e. ?boot1?
and
Quoted 11 lines
?boot2?, with two different versions of U-Boot on each partition.
I also have two different kernels located on eMMC ?user? partition, let?s say ?image1? and ?image2?.
So, I want to boot ?image1? kernel if it is U-boot from ?boot1? partition is booted now,
and to boot ?image2? kernel if it is U-boot from ?boot2? partition is booted.It is easy to do it manually. I just added possibility to do it with
U-boot
Quoted 4 lines
script now,
because ?mmc partconf ...? does not let you check the current boot partition with hush.
Quoted 8 lines
Quoted 1 line
Hope, I explained the purpose.
I remembered. Because i feel to see similar patch to use bootpart. At that time, i also asked same question. Sorry for not remembered yours.
https://patchwork.ozlabs.org/project/uboot/patch/20201212074633.891704-1-grembeter at outlook.com/
Indeed. I should?ve mentioned this link. Sorry. I?ll extend commit message.
Quoted 67 lines
Quoted 67 lines
Quoted 67 lines
Best Regards,
Jaehoon ChungQuoted 2 lines
Signed-off-by Grygorii Tertychnyi <grygorii.tertychnyi at leica-geosystems.com>
cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl
Quoted 9 lines
--- cmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)cmd/mmc.c +0
-0@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl*cmdtp, int flag,
Quoted 16 lines
cmd/mmc.c +13
-0return CMD_RET_SUCCESS ; } +static int do_mmc_partboot (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false);cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,
Quoted 10 lines
cmd/mmc.c +10
-0+if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +puts ("PARTITION_CONFIG only exists on eMMC\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { + printf("No part_config info for ver. 0x%x\n",
mmc->version);Quoted 16 lines
cmd/mmc.c +12
-0+return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 990
Quoted 3 lines
cmd/mmc.c +0
-0@@ -953,6 +988,7 @@ static struct cmd_tbl cmd_mmc[] = {#ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ), U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "",""),
Quoted 4 lines
Quoted 1 line
Quoted 1 line
cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 991
Quoted 1 line
cmd/mmc.c +1
-0+ U_BOOT_CMD_MKENT(partboot, 3, 0, do_mmc_partboot, "", ""),partboot can be confused. how about changing more clear name, like
mmc_bootpart_check?
Agree. We have ?bootpart-resize?, and ?bootpart-check? looks very natural.
I?ll prepare V2 for
mmc bootpart-check <dev> <boot_partition>
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
cmd/mmc.c U_BOOT_CMD( · line 1058
Quoted 7 lines
cmd/mmc.c +0
-0U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""),#endif @@ -1021,6 +1057,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 sizeMB>\n"
Quoted 5 lines
Quoted 1 line
Quoted 1 line
cmd/mmc.c U_BOOT_CMD( · line 1059
Quoted 1 line
cmd/mmc.c +0
-0" - Change sizes of boot and RPMB partitions of specifieddevice\n"
Quoted 1 line
Quoted 1 line
cmd/mmc.c U_BOOT_CMD( · line 1060
Quoted 1 line
cmd/mmc.c +1
-0+"mmc partboot dev boot_partition\n" why it needs to pass "
boot_partition"?
We need to return true or false to be able to use ?if? in boot script (hush).
Comparing the real value with the given one is the only way to return true or false. So, this argument is mandatory.
Quoted 3 lines
And use more clear usage..with optional or mandatory. <> - mandatory
[] - optional
OK.
Quoted 18 lines
mmc partboot <dev>
Quoted 11 lines
Quoted 10 lines
cmd/mmc.c U_BOOT_CMD( · line 1061
Quoted 1 line
cmd/mmc.c +1
-0+ " - Return success if the given boot_partition value matchesBOOT_PARTITION_ENABLE\n"
cmd/mmc.c U_BOOT_CMD(
Quoted 3 lines
cmd/mmc.c +1
-0+" bit field of the specified device\n" "mmc partconf dev [boot_ack boot_partition partition_access]\n" " - Show or change the bits of the PARTITION_CONFIG field of thespecified device\n"
Quoted 2 lines
cmd/mmc.c +0
-0"mmc rst-function dev value\n"
PATCH 1/1 cmd: mmc: add mmc partboot
Quoted 146 lines · gr embeter
Hi Jaehoon,
thanks for your comments.Quoted 38 lines · On Tue, 16 Feb 2021 at 00:30 Jaehoon Chung <[email protected]> wrote:
Hi Grygorii,
Quoted 3 lines · gr embeter
Hello Jaehoon,
On Sun, 14 Feb 2021 at 23:08 Jaehoon Chung <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
Dear Grygorii,
Quoted 2 lines · grygorii tertychnyi
This patch allows to determine active boot partition in boot script:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
if mmc partboot ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
fiI don't know what purpose this patch has.
With an eMMC as a boot source I have two boot partitions, i.e. ?boot1?
and
Quoted 11 lines
?boot2?, with two different versions of U-Boot on each partition.
I also have two different kernels located on eMMC ?user? partition, let?s say ?image1? and ?image2?.
So, I want to boot ?image1? kernel if it is U-boot from ?boot1? partition is booted now,
and to boot ?image2? kernel if it is U-boot from ?boot2? partition is booted.It is easy to do it manually. I just added possibility to do it with
U-boot
Quoted 4 lines
script now,
because ?mmc partconf ...? does not let you check the current boot partition with hush.Quoted 8 lines
Quoted 1 line
Hope, I explained the purpose.
I remembered. Because i feel to see similar patch to use bootpart. At that time, i also asked same question. Sorry for not remembered yours.
Indeed. I should?ve mentioned this link. Sorry. I?ll extend commit message.
Quoted 67 lines
Quoted 67 lines
Quoted 67 lines
Best Regards,
Jaehoon ChungQuoted 2 lines
Signed-off-by Grygorii Tertychnyi <grygorii.tertychnyi at leica-geosystems.com>
cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl
Quoted 9 lines
--- cmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)cmd/mmc.c +0
-0@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl*cmdtp, int flag,
Quoted 16 lines
cmd/mmc.c +13
-0return CMD_RET_SUCCESS ; } +static int do_mmc_partboot (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false);cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,
Quoted 10 lines
cmd/mmc.c +10
-0+if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +puts ("PARTITION_CONFIG only exists on eMMC\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { + printf("No part_config info for ver. 0x%x\n",
mmc->version);Quoted 16 lines
cmd/mmc.c +12
-0+return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 990
Quoted 3 lines
cmd/mmc.c +0
-0@@ -953,6 +988,7 @@ static struct cmd_tbl cmd_mmc[] = {#ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ), U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "",""),
Quoted 4 lines
Quoted 1 line
Quoted 1 line
cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 991
Quoted 1 line
cmd/mmc.c +1
-0+ U_BOOT_CMD_MKENT(partboot, 3, 0, do_mmc_partboot, "", ""),partboot can be confused. how about changing more clear name, like
mmc_bootpart_check?Agree. We have ?bootpart-resize?, and ?bootpart-check? looks very natural.
I?ll prepare V2 for
mmc bootpart-check <dev> <boot_partition>Quoted 12 lines
Quoted 9 lines
Quoted 9 lines
cmd/mmc.c U_BOOT_CMD( · line 1058
Quoted 7 lines
cmd/mmc.c +0
-0U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""),#endif @@ -1021,6 +1057,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 sizeMB>\n"
Quoted 1 line
cmd/mmc.c +0
-0" - Change sizes of boot and RPMB partitions of specifieddevice\n"
Quoted 1 line
Quoted 1 line
Quoted 1 line
cmd/mmc.c +1
-0+"mmc partboot dev boot_partition\n"
Quoted 7 lines
Quoted 1 line
why it needs to pass "
boot_partition"?We need to return true or false to be able to use ?if? in boot script (hush).
Comparing the real value with the given one is the only way to return true or false. So, this argument is mandatory.
How about setting environment variable in checking command? With optional arguments. e,g) mmc partconf-check <dev> [varname] ?
- mmc partconf-check 0
Then just returned BOOT_PARTITON_ENABLE[5:3] value.
- mmc partconf-check 0 boot_partition
Then it will be set to boot_partition as PARTITION_ENABLE[5:3] value.
boot_partition=0x2
I think that you can use %boot_partition variable in your boot script.
Refer to cmd/part.c.
How about this? It's just my opinion.
Best Regards,
Jaehoon Chung
Quoted 29 lines
Quoted 5 lines
And use more clear usage..with optional or mandatory. <> - mandatory
[] - optionalOK.
Quoted 18 lines
mmc partboot <dev>
Quoted 11 lines
Quoted 10 lines
cmd/mmc.c U_BOOT_CMD( · line 1061
Quoted 1 line
cmd/mmc.c +1
-0+ " - Return success if the given boot_partition value matchesBOOT_PARTITION_ENABLE\n"
cmd/mmc.c U_BOOT_CMD(
Quoted 3 lines
cmd/mmc.c +1
-0+" bit field of the specified device\n" "mmc partconf dev [boot_ack boot_partition partition_access]\n" " - Show or change the bits of the PARTITION_CONFIG field of thespecified device\n"
Quoted 2 lines
cmd/mmc.c +0
-0"mmc rst-function dev value\n"
PATCH 1/1 cmd: mmc: add mmc partboot
Quoted 172 lines · On Tue, 16 Feb 2021 at 10:00 Jaehoon Chung <[email protected]> wrote:
Quoted 4 lines · gr embeter
Hi Jaehoon,
thanks for your comments.On Tue, 16 Feb 2021 at 00:30 Jaehoon Chung <[email protected]>
Quoted 18 lines · wrote:
Quoted 18 lines
Hi Grygorii,
Quoted 3 lines · gr embeter
Hello Jaehoon,
On Sun, 14 Feb 2021 at 23:08 Jaehoon Chung <[email protected]>
Quoted 10 lines · wrote:
Quoted 10 lines
Dear Grygorii,
Quoted 5 lines · grygorii tertychnyi
This patch allows to determine active boot partition in boot script:
if mmc partboot ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
fiQuoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
I don't know what purpose this patch has.
With an eMMC as a boot source I have two boot partitions, i.e. ?boot1?
and
Quoted 3 lines
?boot2?, with two different versions of U-Boot on each partition.
I also have two different kernels located on eMMC ?user? partition,
let?s
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
say ?image1? and ?image2?.
So, I want to boot ?image1? kernel if it is U-boot from ?boot1?
partition
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
is booted now,
and to boot ?image2? kernel if it is U-boot from ?boot2? partition is booted.It is easy to do it manually. I just added possibility to do it with
U-boot
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
script now,
because ?mmc partconf ...? does not let you check the current boot partition with hush.Hope, I explained the purpose.
I remembered. Because i feel to see similar patch to use bootpart. At that time, i also asked same question. Sorry for not remembered
yours.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Indeed. I should?ve mentioned this link. Sorry. I?ll extend commit
message.
Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
Best Regards,
Jaehoon ChungQuoted 2 lines
Signed-off-by Grygorii Tertychnyi <grygorii.tertychnyi at leica-geosystems.com>
cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl
Quoted 9 lines
--- cmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)cmd/mmc.c +0
-0@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl*cmdtp, int flag,
Quoted 16 lines
cmd/mmc.c +13
-0return CMD_RET_SUCCESS ; } +static int do_mmc_partboot (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false);cmd/mmc.c static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,
Quoted 10 lines
cmd/mmc.c +10
-0+if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +puts ("PARTITION_CONFIG only exists on eMMC\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { + printf("No part_config info for ver. 0x%x\n",
mmc->version);Quoted 16 lines
cmd/mmc.c +12
-0+return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 990
Quoted 3 lines
cmd/mmc.c +0
-0@@ -953,6 +988,7 @@ static struct cmd_tbl cmd_mmc[] = {#ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ), U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "",""),
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
cmd/mmc.c static struct cmd_tbl cmd_mmc[] = { · line 991
Quoted 1 line
cmd/mmc.c +1
-0+ U_BOOT_CMD_MKENT(partboot, 3, 0, do_mmc_partboot, "", ""),partboot can be confused. how about changing more clear name, like
mmc_bootpart_check?Agree. We have ?bootpart-resize?, and ?bootpart-check? looks very
natural.
Quoted 15 lines
I?ll prepare V2 for
mmc bootpart-check <dev> <boot_partition>Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
cmd/mmc.c U_BOOT_CMD( · line 1058
Quoted 7 lines
cmd/mmc.c +0
-0U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""),#endif @@ -1021,6 +1057,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 sizeMB>\n"
Quoted 1 line
cmd/mmc.c +0
-0" - Change sizes of boot and RPMB partitions of specifieddevice\n"
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
cmd/mmc.c U_BOOT_CMD( · line 1060
Quoted 1 line
cmd/mmc.c +1
-0+"mmc partboot dev boot_partition\n" why it needs to pass "
boot_partition"?We need to return true or false to be able to use ?if? in boot script (hush).
Comparing the real value with the given one is the only way to returntrue
Quoted 1 line
or false. So, this argument is mandatory.
How about setting environment variable in checking command? With optional arguments.
e,g) mmc partconf-check <dev> [varname] ?- mmc partconf-check 0
Then just returned BOOT_PARTITON_ENABLE[5:3] value.
- mmc partconf-check 0boot_partition
Then it will be set toboot_partitionas PARTITION_ENABLE[5:3] value.
Quoted 7 lines
boot_partition=0x2
I think that you can use %boot_partition variable in your boot script.
Refer to
cmd/part.c.How about this? It's just my opinion.
it looks like an overkill for this purpose.
it is additional ?if?: 1st to check the return value of bootpart-check (to verify the value is set), 2nd to check the value of variable. And if there is ?save env? call in the same boot script, we would need to unset this new variable.
Quoted 36 lines
Best Regards,
Jaehoon ChungQuoted 20 lines
Quoted 5 lines
And use more clear usage..with optional or mandatory. <> - mandatory
[] - optionalOK.
Quoted 10 lines
mmc partboot <dev>
Quoted 5 lines
Quoted 5 lines
cmd/mmc.c U_BOOT_CMD( · line 1061
Quoted 1 line
cmd/mmc.c +1
-0+ " - Return success if the given boot_partition value matchesBOOT_PARTITION_ENABLE\n"
Quoted 3 lines
cmd/mmc.c +1
-0+" bit field of the specified device\n" "mmc partconf dev [boot_ack boot_partition partition_access]\n" " - Show or change the bits of the PARTITION_CONFIG field ofthe
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
specified device\n"
Quoted 2 lines
cmd/mmc.c +0
-0"mmc rst-function dev value\n"
PATCH v2 1/1 cmd: mmc: add mmc bootpart-check
In reply to grygorii tertychnyiThis patch allows to check the current boot partition. It is useful when you use two different sets of (bootloader, kernel) images and want to boot the corresponding kernel image in boot script. E.g.:
if mmc bootpart-check ${mmcdev} 1; then
echo "booted from eMMC boot0 partition"
...load kernel image1
elif mmc bootpart-check ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
...load kernel image2
fi
---
v2:
- renamed the command, it is "bootpart-check" now
- added <> to mandatory arguments help string
- added more details to commit message
cmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
cmd/mmc.c +39 -0
@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,return CMD_RET_SUCCESS ; } +static int do_mmc_boot_check (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false); +if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +printf ("It is not an eMMC device\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { +printf ("No part_config info for ver. 0x%x\n" , mmc->version); +return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;
@@ -952,6 +987,7 @@ static struct cmd_tbl cmd_mmc[] = {#endif #ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ), +U_BOOT_CMD_MKENT (bootpart-check,3 ,0 , do_mmc_boot_check,"" ,"" ),U_BOOT_CMD_MKENT (bootpart-resize,4 ,0 , do_mmc_boot_resize,"" ,"" ),U_BOOT_CMD_MKENT (partconf,5 ,0 , do_mmc_partconf,"" ,"" ), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""),
@@ -1019,6 +1055,9 @@ U_BOOT_CMD(#ifdef CONFIG_SUPPORT_EMMC_BOOT "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n" " - Set the BOOT_BUS_WIDTH field of the specified device\n" +"mmc bootpart-check <dev> <boot_partition>\n" +" - Return success if the given boot_partition value matches BOOT_PARTITION_ENABLE\n" +" bit 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"
Signature · 1 line
2.25.1
PATCH v2 1/1 cmd: mmc: add mmc bootpart-check
Hi,
Quoted 11 lines · grygorii tertychnyi
This patch allows to check the current boot partition. It is useful when you use two different sets of (bootloader, kernel) images and want to boot the corresponding kernel image in boot script. E.g.:
if mmc bootpart-check ${mmcdev} 1; then
echo "booted from eMMC boot0 partition"
...load kernel image1
elif mmc bootpart-check ${mmcdev} 2; then
echo "booted from eMMC boot1 partition"
...load kernel image2
fi
If mmc_bootpart-check <dev> <boot_partition> is used, it's just for your bootsripts. Your patch is doing nothing...
U-boot> mmc bootpart-check 1 1
U-boot> mmc bootpart-check 1 2
U-boot> mmc bootpart-check 1 3
To use this command by other developer, it needs to be more useful than now. So i think good that displayed the bootpart value in your patch.
Then it doesn't need to use "echo booted from.." in your bootscript.
e.g) if success..
U-boot> mmc bootpart-check 1 1
Boot partition 1 enabled for boot
if fail
U-boot> mmc bootpart-check 1 1
Boot partition 2 enabled for boot
Code can be the below..
switch (part_emmc) {
case 0x0:
printf("Device not boot enabled");
break;
case 0x1:
printf("Boot partition 1 ...);
break;
case 0x2:
...
default:
printf("BOOT_PARTITION_ENABLE is reserved\n");
}Then other developer and you can get more information with this command. Also when checking is failed, it can provide which bootpart is valid. And this patch's commit-msg can be described more common, not only bootscript's case.
how about this?
Quoted 2 lines
Signed-off-by Grygorii Tertychnyi <[email protected]>
I think better that Signed-off-by and Author's email address maintains to same.
Author: grygorii tertychnyi <[email protected]> Date: Wed Feb 17 17:35:16 2021 +0100
cmd: mmc: add mmc bootpart-check
Best Regards,
Jaehoon Chung
Quoted 74 lines
---
v2:
- renamed the command, it is "bootpart-check" now
- added <> to mandatory arguments help string
- added more details to commit messagecmd/mmc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)cmd/mmc.c +39
-0@@ -771,6 +771,41 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,return CMD_RET_SUCCESS ; } +static int do_mmc_boot_check (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +int dev; +struct mmc *mmc; +u8 part_args, part_emmc; + +if (argc !=3 ) +return CMD_RET_USAGE ; + + dev =simple_strtoul (argv[1 ],NULL ,10 ); + + mmc =init_mmc_device (dev, false); +if (!mmc) +return CMD_RET_FAILURE ; + +if (IS_SD (mmc)) { +printf ("It is not an eMMC device\n" ); +return CMD_RET_FAILURE ; + } + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { +printf ("No part_config info for ver. 0x%x\n" , mmc->version); +return CMD_RET_FAILURE ; + } + + part_emmc =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + part_args =simple_strtoul (argv[2 ],NULL ,10 ); + +if (part_emmc == part_args) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int mmc_partconf_print (struct mmc *mmc) {u8 ack, access, part;@@ -952,6 +987,7 @@ static struct cmd_tbl cmd_mmc[] = {#endif #ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT (bootbus,5 ,0 , do_mmc_bootbus,"" ,"" ), +U_BOOT_CMD_MKENT (bootpart-check,3 ,0 , do_mmc_boot_check,"" ,"" ),U_BOOT_CMD_MKENT (bootpart-resize,4 ,0 , do_mmc_boot_resize,"" ,"" ),U_BOOT_CMD_MKENT (partconf,5 ,0 , do_mmc_partconf,"" ,"" ), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""),@@ -1019,6 +1055,9 @@ U_BOOT_CMD(#ifdef CONFIG_SUPPORT_EMMC_BOOT "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n" " - Set the BOOT_BUS_WIDTH field of the specified device\n" +"mmc bootpart-check <dev> <boot_partition>\n" +" - Return success if the given boot_partition value matches BOOT_PARTITION_ENABLE\n" +" bit 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"