diff mbox series

cmd: mmc: add mmcboot command

Message ID 1608753437-5004-1-git-send-email-rahasij@linux.microsoft.com
State Changes Requested
Delegated to: Peng Fan
Headers show
Series cmd: mmc: add mmcboot command | expand

Commit Message

Ravik Hasija Dec. 23, 2020, 7:57 p.m. UTC
Similar to usbboot, add command line to boot from raw mmc partition
using common_diskboot(), which supports legacy or FIT images.

Usage:
mmcboot loadAaddr dev:part

Where <loadAddr> defaults to CONFIG_SYS_LOAD_ADDR, and <dev:part>
defaults to ${bootdevice}.

Also fixing config macro usage for CONFIG_SUPPORT_EMMC_BOOT (suggested
by checkpatch.pl).

Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com>
Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com>
---
 cmd/mmc.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

Comments

Jaehoon Chung Dec. 27, 2020, 10:58 p.m. UTC | #1
Hi Ravik,

On 12/24/20 4:57 AM, Ravik Hasija wrote:
> Similar to usbboot, add command line to boot from raw mmc partition
> using common_diskboot(), which supports legacy or FIT images.
> 
> Usage:
> mmcboot loadAaddr dev:part
> 
> Where <loadAddr> defaults to CONFIG_SYS_LOAD_ADDR, and <dev:part>
> defaults to ${bootdevice}.
> 
> Also fixing config macro usage for CONFIG_SUPPORT_EMMC_BOOT (suggested
> by checkpatch.pl).

Could you check a build error?

> 
> Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com>
> Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com>
> ---
>  cmd/mmc.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/cmd/mmc.c b/cmd/mmc.c
> index 1529a3e05d..4d134e35a1 100644
> --- a/cmd/mmc.c
> +++ b/cmd/mmc.c
> @@ -711,7 +711,7 @@ static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, int flag,
>  }
>  #endif
>  
> -#ifdef CONFIG_SUPPORT_EMMC_BOOT
> +#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
>  static int do_mmc_bootbus(struct cmd_tbl *cmdtp, int flag,
>  			  int argc, char *const argv[])
>  {
> @@ -950,7 +950,7 @@ static struct cmd_tbl cmd_mmc[] = {
>  #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
>  	U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""),
>  #endif
> -#ifdef CONFIG_SUPPORT_EMMC_BOOT
> +#if CONFIG_IS_ENABLED(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(partconf, 5, 0, do_mmc_partconf, "", ""),
> @@ -992,6 +992,14 @@ static int do_mmcops(struct cmd_tbl *cmdtp, int flag, int argc,
>  	return cp->cmd(cmdtp, flag, argc, argv);
>  }
>  
> +#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
> +static int do_mmcboot(cmd_tbl_t *cmdtp, int flag, int argc,
> +		char *const argv[])

cmd/mmc.c:996:23: error: unknown type name 'cmd_tbl_t'
  996 | static int do_mmcboot(cmd_tbl_t *cmdtp, int flag, int argc,
      |                       ^~~~~~~~~


> +{
> +	return common_diskboot(cmdtp, "mmc", argc, argv);

common_diskboot is depend on CONFIG_CMD_IDE, so i think that you have to enable CMD_IDE.

> +}
> +#endif
> +
>  U_BOOT_CMD(
>  	mmc, 29, 1, do_mmcops,
>  	"MMC sub system",
> @@ -1016,7 +1024,7 @@ U_BOOT_CMD(
>  	"  WARNING: Partitioning is a write-once setting once it is set to complete.\n"
>  	"  Power cycling is required to initialize partitions after set to complete.\n"
>  #endif
> -#ifdef CONFIG_SUPPORT_EMMC_BOOT
> +#if CONFIG_IS_ENABLED(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-resize <dev> <boot part size MB> <RPMB part size MB>\n"
> @@ -1046,3 +1054,11 @@ U_BOOT_CMD(
>  	"display MMC info",
>  	"- display info of the current MMC device"
>  );
> +
> +#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
> +U_BOOT_CMD(
> +	mmcboot, 3, 1, do_mmcboot,
> +	"boot from eMMC",
> +	"loadAddr dev:part"

Update the usage which arguments are optional or mandatory with <>, [].


Best Regards,
Jaehoon Chung

> +);
> +#endif
>
Simon Glass Dec. 29, 2020, 3:32 a.m. UTC | #2
On Wed, 23 Dec 2020 at 12:57, Ravik Hasija <rahasij@linux.microsoft.com> wrote:
>
> Similar to usbboot, add command line to boot from raw mmc partition
> using common_diskboot(), which supports legacy or FIT images.
>
> Usage:
> mmcboot loadAaddr dev:part
>
> Where <loadAddr> defaults to CONFIG_SYS_LOAD_ADDR, and <dev:part>
> defaults to ${bootdevice}.
>
> Also fixing config macro usage for CONFIG_SUPPORT_EMMC_BOOT (suggested
> by checkpatch.pl).
>
> Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com>
> Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com>
> ---
>  cmd/mmc.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Heinrich Schuchardt Jan. 1, 2021, 9:56 a.m. UTC | #3
On 12/27/20 11:58 PM, Jaehoon Chung wrote:
> Hi Ravik,
>
> On 12/24/20 4:57 AM, Ravik Hasija wrote:
>> Similar to usbboot, add command line to boot from raw mmc partition
>> using common_diskboot(), which supports legacy or FIT images.
>>
>> Usage:
>> mmcboot loadAaddr dev:part
>>
>> Where <loadAddr> defaults to CONFIG_SYS_LOAD_ADDR, and <dev:part>
>> defaults to ${bootdevice}.
>>

Please, add a man-page under doc/usage/. You can use
doc/usage/button.rst as template.

Best regards

Heinrich


>> Also fixing config macro usage for CONFIG_SUPPORT_EMMC_BOOT (suggested
>> by checkpatch.pl).
>
> Could you check a build error?
>
>>
>> Signed-off-by: Ravik Hasija <rahasij@linux.microsoft.com>
>> Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com>
>> ---
>>   cmd/mmc.c | 22 +++++++++++++++++++---
>>   1 file changed, 19 insertions(+), 3 deletions(-)
>>
>> diff --git a/cmd/mmc.c b/cmd/mmc.c
>> index 1529a3e05d..4d134e35a1 100644
>> --- a/cmd/mmc.c
>> +++ b/cmd/mmc.c
>> @@ -711,7 +711,7 @@ static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, int flag,
>>   }
>>   #endif
>>
>> -#ifdef CONFIG_SUPPORT_EMMC_BOOT
>> +#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
>>   static int do_mmc_bootbus(struct cmd_tbl *cmdtp, int flag,
>>   			  int argc, char *const argv[])
>>   {
>> @@ -950,7 +950,7 @@ static struct cmd_tbl cmd_mmc[] = {
>>   #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
>>   	U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""),
>>   #endif
>> -#ifdef CONFIG_SUPPORT_EMMC_BOOT
>> +#if CONFIG_IS_ENABLED(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(partconf, 5, 0, do_mmc_partconf, "", ""),
>> @@ -992,6 +992,14 @@ static int do_mmcops(struct cmd_tbl *cmdtp, int flag, int argc,
>>   	return cp->cmd(cmdtp, flag, argc, argv);
>>   }
>>
>> +#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
>> +static int do_mmcboot(cmd_tbl_t *cmdtp, int flag, int argc,
>> +		char *const argv[])
>
> cmd/mmc.c:996:23: error: unknown type name 'cmd_tbl_t'
>    996 | static int do_mmcboot(cmd_tbl_t *cmdtp, int flag, int argc,
>        |                       ^~~~~~~~~
>
>
>> +{
>> +	return common_diskboot(cmdtp, "mmc", argc, argv);
>
> common_diskboot is depend on CONFIG_CMD_IDE, so i think that you have to enable CMD_IDE.
>
>> +}
>> +#endif
>> +
>>   U_BOOT_CMD(
>>   	mmc, 29, 1, do_mmcops,
>>   	"MMC sub system",
>> @@ -1016,7 +1024,7 @@ U_BOOT_CMD(
>>   	"  WARNING: Partitioning is a write-once setting once it is set to complete.\n"
>>   	"  Power cycling is required to initialize partitions after set to complete.\n"
>>   #endif
>> -#ifdef CONFIG_SUPPORT_EMMC_BOOT
>> +#if CONFIG_IS_ENABLED(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-resize <dev> <boot part size MB> <RPMB part size MB>\n"
>> @@ -1046,3 +1054,11 @@ U_BOOT_CMD(
>>   	"display MMC info",
>>   	"- display info of the current MMC device"
>>   );
>> +
>> +#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
>> +U_BOOT_CMD(
>> +	mmcboot, 3, 1, do_mmcboot,
>> +	"boot from eMMC",
>> +	"loadAddr dev:part"
>
> Update the usage which arguments are optional or mandatory with <>, [].
>
>> +);
>> +#endif
>>
>
diff mbox series

Patch

diff --git a/cmd/mmc.c b/cmd/mmc.c
index 1529a3e05d..4d134e35a1 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -711,7 +711,7 @@  static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, int flag,
 }
 #endif
 
-#ifdef CONFIG_SUPPORT_EMMC_BOOT
+#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
 static int do_mmc_bootbus(struct cmd_tbl *cmdtp, int flag,
 			  int argc, char *const argv[])
 {
@@ -950,7 +950,7 @@  static struct cmd_tbl cmd_mmc[] = {
 #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
 	U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""),
 #endif
-#ifdef CONFIG_SUPPORT_EMMC_BOOT
+#if CONFIG_IS_ENABLED(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(partconf, 5, 0, do_mmc_partconf, "", ""),
@@ -992,6 +992,14 @@  static int do_mmcops(struct cmd_tbl *cmdtp, int flag, int argc,
 	return cp->cmd(cmdtp, flag, argc, argv);
 }
 
+#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
+static int do_mmcboot(cmd_tbl_t *cmdtp, int flag, int argc,
+		char *const argv[])
+{
+	return common_diskboot(cmdtp, "mmc", argc, argv);
+}
+#endif
+
 U_BOOT_CMD(
 	mmc, 29, 1, do_mmcops,
 	"MMC sub system",
@@ -1016,7 +1024,7 @@  U_BOOT_CMD(
 	"  WARNING: Partitioning is a write-once setting once it is set to complete.\n"
 	"  Power cycling is required to initialize partitions after set to complete.\n"
 #endif
-#ifdef CONFIG_SUPPORT_EMMC_BOOT
+#if CONFIG_IS_ENABLED(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-resize <dev> <boot part size MB> <RPMB part size MB>\n"
@@ -1046,3 +1054,11 @@  U_BOOT_CMD(
 	"display MMC info",
 	"- display info of the current MMC device"
 );
+
+#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
+U_BOOT_CMD(
+	mmcboot, 3, 1, do_mmcboot,
+	"boot from eMMC",
+	"loadAddr dev:part"
+);
+#endif