All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd: mmc: modify partconf to be used in script
@ 2020-12-12  7:46 ` grygorii tertychnyi
  2020-12-14  9:59   ` Jaehoon Chung
  0 siblings, 1 reply; 4+ messages in thread
From: grygorii tertychnyi @ 2020-12-12  7:46 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Grygorii Tertychnyi <grygorii.tertychnyi@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);
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] cmd: mmc: modify partconf to be used in script
  2020-12-12  7:46 ` [PATCH] cmd: mmc: modify partconf to be used in script grygorii tertychnyi
@ 2020-12-14  9:59   ` Jaehoon Chung
  2020-12-14 14:45     ` gr embeter
  0 siblings, 1 reply; 4+ messages in thread
From: Jaehoon Chung @ 2020-12-14  9:59 UTC (permalink / raw)
  To: u-boot

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. 

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

> 
> Signed-off-by: Grygorii Tertychnyi <grygorii.tertychnyi@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);
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] cmd: mmc: modify partconf to be used in script
  2020-12-14  9:59   ` Jaehoon Chung
@ 2020-12-14 14:45     ` gr embeter
  2020-12-14 21:47       ` Jaehoon Chung
  0 siblings, 1 reply; 4+ messages in thread
From: gr embeter @ 2020-12-14 14:45 UTC (permalink / raw)
  To: u-boot

Hi Jaehoon,
thanks for replying.

On Mon, Dec 14, 2020 at 10:58 AM Jaehoon Chung <jh80.chung@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@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);
> >
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] cmd: mmc: modify partconf to be used in script
  2020-12-14 14:45     ` gr embeter
@ 2020-12-14 21:47       ` Jaehoon Chung
  0 siblings, 0 replies; 4+ messages in thread
From: Jaehoon Chung @ 2020-12-14 21:47 UTC (permalink / raw)
  To: u-boot

On 12/14/20 11:45 PM, gr embeter wrote:
> Hi Jaehoon,
> thanks for replying.
> 
> On Mon, Dec 14, 2020 at 10:58 AM Jaehoon Chung <jh80.chung@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")

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?

> 
> 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.
> 

If you need to add this behavior, adding new command is better than modifying partconf.

Best Regards,
Jaehoon Chung

> 
> 
>> Best Regards,
>> Jaehoon Chung
>>
>>>
>>> Signed-off-by: Grygorii Tertychnyi <grygorii.tertychnyi@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);
>>>
>>
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-14 21:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20201212181434epcas1p239747ef2ac0096fe61e830e86efde7cc@epcas1p2.samsung.com>
2020-12-12  7:46 ` [PATCH] cmd: mmc: modify partconf to be used in script grygorii tertychnyi
2020-12-14  9:59   ` Jaehoon Chung
2020-12-14 14:45     ` gr embeter
2020-12-14 21:47       ` Jaehoon Chung

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.