cmd: mmc: modify partconf to be used in script
PATCH 1/1 cmd: mmc: modify partconf to be used in script
To implement dual-boot strategy we need to know what is the current boot partition for U-Boot. It can be easily identified by looking at the PARTITION_CONFIG value shown by "mmc partconf dev", but I didn't find any way to use it in the boot script.
Hence, modify it, so that "mmc partboot dev part_num" command returns true if "part_num" is the current boot partition, otherwise it returns false.
--- cmd/mmc.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
cmd/mmc.c +22 -1
@@ -792,6 +792,23 @@ static int mmc_partconf_print(struct mmc *mmc)return CMD_RET_SUCCESS ; } +static int mmc_partnum_cmp (struct mmc *mmc,u8 part_num) +{ +u8 part; + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { +printf ("No part_config info for ver. 0x%x\n" , mmc->version); +return CMD_RET_FAILURE ; + } + + part =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + +if (part == part_num) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int do_mmc_partconf (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {
@@ -799,7 +816,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 );
@@ -815,6 +832,10 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,if (argc ==2 )return mmc_partconf_print (mmc); +if (argc ==3 ) { + part_num =simple_strtoul (argv[2 ],NULL ,10 ); +return mmc_partnum_cmp (mmc, part_num); + } ack =simple_strtoul (argv[2 ],NULL ,10 ); part_num =simple_strtoul (argv[3 ],NULL ,10 );
Signature · 1 line
2.25.1
PATCH 1/1 cmd: mmc: modify partconf to be used in script
Hi,
Quoted 8 lines · grygorii tertychnyi
To implement dual-boot strategy we need to know what is the current boot partition for U-Boot. It can be easily identified by looking at the
PARTITION_CONFIGvalue shown by "mmc partconf dev", but I didn't find any way to use it in the boot script.Hence, modify it, so that "mmc partboot dev
part_num" command returns true if "part_num" is the current boot partition, otherwise it returns false.
Sorry. I don't understand what you want.
And if you want to change something about mmc partconf, then you need to update the Usage. There is no usage about yours.
And i don't want to add its. It's too dangerous because of possible to set to wrong boot partition.
Best Regards,
Jaehoon Chung
Quoted 55 lines
Signed-off-by Grygorii Tertychnyi <[email protected]>--- cmd/mmc.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)cmd/mmc.c +22
-1@@ -792,6 +792,23 @@ static int mmc_partconf_print(struct mmc *mmc)return CMD_RET_SUCCESS ; } +static int mmc_partnum_cmp (struct mmc *mmc,u8 part_num) +{ +u8 part; + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { +printf ("No part_config info for ver. 0x%x\n" , mmc->version); +return CMD_RET_FAILURE ; + } + + part =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + +if (part == part_num) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int do_mmc_partconf (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {@@ -799,7 +816,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 );@@ -815,6 +832,10 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,if (argc ==2 )return mmc_partconf_print (mmc); +if (argc ==3 ) { + part_num =simple_strtoul (argv[2 ],NULL ,10 ); +return mmc_partnum_cmp (mmc, part_num); + } ack =simple_strtoul (argv[2 ],NULL ,10 ); part_num =simple_strtoul (argv[3 ],NULL ,10 );
PATCH 1/1 cmd: mmc: modify partconf to be used in script
Hi Jaehoon,
thanks for replying.
Quoted 9 lines · Jaehoon Chung
Hi,
Quoted 5 lines · grygorii tertychnyi
To implement dual-boot strategy we need to know what is the current boot partition for U-Boot. It can be easily identified by looking at the
PARTITION_CONFIGvalue shown by "mmc partconf dev", but I didn't find any way to use it in the boot script.
Quoted 5 lines
Quoted 3 lines
Hence, modify it, so that "mmc partboot dev
part_num" command returns true if "part_num" is the current boot partition, otherwise it returns false.Sorry. I don't understand what you want.
Here is what I meant.
We have two boot partitions on MMC: boot0 and boot1. And two kernels on MMC: "kernel-a" and "kernel-b".
I want to have a way to determine the current boot partition to implement the algorithm in the boot script:
if (boot0 == currect_boot_partition())
boot("kernel-a")
if (boot1 == currect_boot_partition())
boot("kernel-b")With this patch it is possible to write:
if mmc partconf ${mmcdev} 1; then
echo "::::: booted from boot0"
...
fi
if mmc partconf ${mmcdev} 2; then
echo "::::: booted from boot1"
...fi
Quoted 4 lines
And if you want to change something about mmc partconf, then you need to update the Usage. There is no usage about yours.
And i don't want to add its. It's too dangerous because of possible to set to wrong boot partition.
I will rework it and introduce a new mmc command for this specific action.
Quoted 59 lines
Best Regards,
Jaehoon ChungQuoted 55 lines
Signed-off-by Grygorii Tertychnyi <[email protected]>--- cmd/mmc.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)cmd/mmc.c +22
-1@@ -792,6 +792,23 @@ static int mmc_partconf_print(struct mmc *mmc)return CMD_RET_SUCCESS ; } +static int mmc_partnum_cmp (struct mmc *mmc,u8 part_num) +{ +u8 part; + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { +printf ("No part_config info for ver. 0x%x\n" , mmc->version); +return CMD_RET_FAILURE ; + } + + part =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + +if (part == part_num) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int do_mmc_partconf (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {@@ -799,7 +816,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 );@@ -815,6 +832,10 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,if (argc ==2 )return mmc_partconf_print (mmc); +if (argc ==3 ) { + part_num =simple_strtoul (argv[2 ],NULL ,10 ); +return mmc_partnum_cmp (mmc, part_num); + } ack =simple_strtoul (argv[2 ],NULL ,10 ); part_num =simple_strtoul (argv[3 ],NULL ,10 );
PATCH 1/1 cmd: mmc: modify partconf to be used in script
Quoted 23 lines · gr embeter
Hi Jaehoon,
thanks for replying.Quoted 9 lines · Jaehoon Chung
Hi,
Quoted 5 lines · grygorii tertychnyi
To implement dual-boot strategy we need to know what is the current boot partition for U-Boot. It can be easily identified by looking at the
PARTITION_CONFIGvalue shown by "mmc partconf dev", but I didn't find any way to use it in the boot script.Quoted 5 lines
Quoted 3 lines
Hence, modify it, so that "mmc partboot dev
part_num" command returns true if "part_num" is the current boot partition, otherwise it returns false.Sorry. I don't understand what you want.
Here is what I meant.
We have two boot partitions on MMC: boot0 and boot1. And two kernels on MMC: "kernel-a" and "kernel-b".
Quoted 6 lines
I want to have a way to determine the current boot partition to implement the algorithm in the boot script:
if (boot0 ==currect_boot_partition())boot("kernel-a") if (boot1 == currect_boot_partition()) boot("kernel-b")
According to my understanding,
there are two kernels somewhere and you want to choose kernel according to boot partition, right?
Is there u-boot into boot partition? AFAIK, maybe there is some bl images, not u-boot. Does it impossible to implement something in bl image?
Quoted 10 lines
With this patch it is possible to write:
if mmc partconf ${mmcdev} 1; then
echo "::::: booted from boot0" ... fi if mmc partconf ${mmcdev} 2; then echo "::::: booted from boot1" ...
Quoted 9 lines
fi
Quoted 4 lines
And if you want to change something about mmc partconf, then you need to update the Usage. There is no usage about yours.
And i don't want to add its. It's too dangerous because of possible to set to wrong boot partition.
I will rework it and introduce a new mmc command for this specific action.
If you need to add this behavior, adding new command is better than modifying partconf.
Best Regards,
Jaehoon Chung
Quoted 62 lines
Quoted 61 lines
Best Regards,
Jaehoon ChungQuoted 55 lines
Signed-off-by Grygorii Tertychnyi <[email protected]>--- cmd/mmc.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)cmd/mmc.c +22
-1@@ -792,6 +792,23 @@ static int mmc_partconf_print(struct mmc *mmc)return CMD_RET_SUCCESS ; } +static int mmc_partnum_cmp (struct mmc *mmc,u8 part_num) +{ +u8 part; + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) { +printf ("No part_config info for ver. 0x%x\n" , mmc->version); +return CMD_RET_FAILURE ; + } + + part =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + +if (part == part_num) +return CMD_RET_SUCCESS ; +else +return CMD_RET_FAILURE ; +} +static int do_mmc_partconf (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {@@ -799,7 +816,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 );@@ -815,6 +832,10 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,if (argc ==2 )return mmc_partconf_print (mmc); +if (argc ==3 ) { + part_num =simple_strtoul (argv[2 ],NULL ,10 ); +return mmc_partnum_cmp (mmc, part_num); + } ack =simple_strtoul (argv[2 ],NULL ,10 ); part_num =simple_strtoul (argv[3 ],NULL ,10 );