[PATCH] cmd: mmc: modify partconf to be used in script
gr embeter
grembeter at gmail.com
Mon Dec 14 15:45:32 CET 2020
Hi Jaehoon,
thanks for replying.
On Mon, Dec 14, 2020 at 10:58 AM Jaehoon Chung <jh80.chung at samsung.com> wrote:
>
> Hi,
>
> On 12/12/20 4:46 PM, grygorii tertychnyi wrote:
> > 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.
>
> 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
> 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.
> Best Regards,
> Jaehoon Chung
>
> >
> > Signed-off-by: Grygorii Tertychnyi <grygorii.tertychnyi at leica-geosystems.com>
> > ---
> > cmd/mmc.c | 23 ++++++++++++++++++++++-
> > 1 file changed, 22 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/mmc.c b/cmd/mmc.c
> > index 1529a3e05ddd..c8db008bc90d 100644
> > --- a/cmd/mmc.c
> > +++ b/cmd/mmc.c
> > @@ -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);
> >
>
More information about the U-Boot
mailing list