diff options
author | Philippe Reynes <philippe.reynes@softathome.com> | 2022-03-28 22:57:07 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-03-31 14:12:23 -0400 |
commit | 7bebc11c42351c8f0364f0e3eb922f5af7b6e826 (patch) | |
tree | cb370025bcc386ef741cce94bda1b4dd58fe2d76 /cmd | |
parent | 776db4fa96bb606b88740ea2017c3c66a8394e86 (diff) | |
download | u-boot-7bebc11c42351c8f0364f0e3eb922f5af7b6e826.zip u-boot-7bebc11c42351c8f0364f0e3eb922f5af7b6e826.tar.gz u-boot-7bebc11c42351c8f0364f0e3eb922f5af7b6e826.tar.bz2 |
cmd: bootm: add subcommand preload
Add a subcommand preload to bootm that execute the preload
stage on the image. Right now, it checks the signature
of the image with the pre-load header. If the check
succeed, the u-boot env variable 'loadaddr_verified'
is set to the address of the image (without the header).
It allows to run such commands:
tftp script.img && bootm preload $loadaddr && source $loadaddr_verified
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/bootm.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cmd/bootm.c b/cmd/bootm.c index 87d40d4..1f70ee9 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -44,6 +44,9 @@ static int do_imls(struct cmd_tbl *cmdtp, int flag, int argc, static struct cmd_tbl cmd_bootm_sub[] = { U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""), U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""), +#ifdef CONFIG_CMD_BOOTM_PRE_LOAD + U_BOOT_CMD_MKENT(preload, 0, 1, (void *)BOOTM_STATE_PRE_LOAD, "", ""), +#endif #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH U_BOOT_CMD_MKENT(ramdisk, 0, 1, (void *)BOOTM_STATE_RAMDISK, "", ""), #endif @@ -57,6 +60,20 @@ static struct cmd_tbl cmd_bootm_sub[] = { U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""), }; +#if defined(CONFIG_CMD_BOOTM_PRE_LOAD) +static ulong bootm_get_addr(int argc, char *const argv[]) +{ + ulong addr; + + if (argc > 0) + addr = hextoul(argv[0], NULL); + else + addr = image_load_addr; + + return addr; +} +#endif + static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -72,6 +89,10 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, if (state == BOOTM_STATE_START) state |= BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER; +#if defined(CONFIG_CMD_BOOTM_PRE_LOAD) + if (state == BOOTM_STATE_PRE_LOAD) + state |= BOOTM_STATE_START; +#endif } else { /* Unrecognized command */ return CMD_RET_USAGE; @@ -85,6 +106,12 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, ret = do_bootm_states(cmdtp, flag, argc, argv, state, &images, 0); +#if defined(CONFIG_CMD_BOOTM_PRE_LOAD) + if (!ret && (state & BOOTM_STATE_PRE_LOAD)) + env_set_hex("loadaddr_verified", + bootm_get_addr(argc, argv) + image_load_offset); +#endif + return ret; } @@ -177,6 +204,9 @@ static char bootm_help_text[] = "must be\n" "issued in the order below (it's ok to not issue all sub-commands):\n" "\tstart [addr [arg ...]]\n" +#if defined(CONFIG_CMD_BOOTM_PRE_LOAD) + "\tpreload [addr [arg ..]] - run only the preload stage\n" +#endif "\tloados - load OS image\n" #if defined(CONFIG_SYS_BOOT_RAMDISK_HIGH) "\tramdisk - relocate initrd, set env initrd_start/initrd_end\n" |