blob: 599d0b23f88658ed9a9585228c23484de0018cdb [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk47d1a6e2002-11-03 00:01:44 +00002/*
Detlev Zundelca95c9d2009-07-13 16:01:18 +02003 * (C) Copyright 2000-2009
wdenk47d1a6e2002-11-03 00:01:44 +00004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenk47d1a6e2002-11-03 00:01:44 +00005 */
6
7/*
8 * Boot support
9 */
10#include <common.h>
Simon Glassb6396402014-06-12 07:24:46 -060011#include <bootm.h>
wdenk47d1a6e2002-11-03 00:01:44 +000012#include <command.h>
Simon Glass7b51b572019-08-01 09:46:52 -060013#include <env.h>
Simon Glass90268b82014-10-19 21:11:24 -060014#include <errno.h>
Simon Glassb6396402014-06-12 07:24:46 -060015#include <image.h>
Simon Glassb6396402014-06-12 07:24:46 -060016#include <malloc.h>
17#include <nand.h>
wdenk47d1a6e2002-11-03 00:01:44 +000018#include <asm/byteorder.h>
Simon Glass401d1c42020-10-30 21:38:53 -060019#include <asm/global_data.h>
Simon Glassb6396402014-06-12 07:24:46 -060020#include <linux/ctype.h>
21#include <linux/err.h>
22#include <u-boot/zlib.h>
Philippe Reynesae0d12f2019-12-02 15:45:50 +010023#include <mapmem.h>
Mingyen Hung6e468002023-01-04 23:43:04 -080024#include <amlogic/libavb/libavb.h>
25#include <amlogic/partition_table.h>
26#if CONFIG_IS_ENABLED(AML_ANTIROLLBACK) || CONFIG_IS_ENABLED(AML_AVB2_ANTIROLLBACK)
27#include <amlogic/anti-rollback.h>
28#endif
Zhongfu Luo04a29ff2023-07-31 15:53:00 +080029#include <amlogic/aml_efuse.h>
30#include <version.h>
31#include <amlogic/image_check.h>
32#include <asm/amlogic/arch/bl31_apis.h>
Mingyen Hung6e468002023-01-04 23:43:04 -080033#include <amlogic/aml_rollback.h>
Peter Korsgaard20dde482009-11-19 11:37:51 +010034
Marian Balakowicz1ee11802008-01-08 18:17:10 +010035DECLARE_GLOBAL_DATA_PTR;
36
Jon Loeligerbaa26db2007-07-08 17:51:39 -050037#if defined(CONFIG_CMD_IMI)
Stephen Warren712fbcf2011-10-18 11:11:49 +000038static int image_info(unsigned long addr);
wdenk47d1a6e2002-11-03 00:01:44 +000039#endif
wdenk27b207f2003-07-24 23:38:38 +000040
Jon Loeligerbaa26db2007-07-08 17:51:39 -050041#if defined(CONFIG_CMD_IMLS)
wdenk27b207f2003-07-24 23:38:38 +000042#include <flash.h>
Stefan Roeseca5def32010-08-31 10:00:10 +020043#include <mtd/cfi_flash.h>
Vipin Kumar8fdf1e02012-12-16 22:32:48 +000044#endif
45
46#if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
Simon Glass09140112020-05-10 11:40:03 -060047static int do_imls(struct cmd_tbl *cmdtp, int flag, int argc,
48 char *const argv[]);
wdenk27b207f2003-07-24 23:38:38 +000049#endif
50
Kumar Gala49c3a862008-10-21 17:25:45 -050051/* we overload the cmd field with our state machine info instead of a
52 * function pointer */
Simon Glass09140112020-05-10 11:40:03 -060053static struct cmd_tbl cmd_bootm_sub[] = {
Kumar Gala49c3a862008-10-21 17:25:45 -050054 U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""),
55 U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""),
Philippe Reynes7bebc112022-03-28 22:57:07 +020056#ifdef CONFIG_CMD_BOOTM_PRE_LOAD
57 U_BOOT_CMD_MKENT(preload, 0, 1, (void *)BOOTM_STATE_PRE_LOAD, "", ""),
58#endif
John Rigbyfca43cc2010-10-13 13:57:35 -060059#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
Kumar Gala49c3a862008-10-21 17:25:45 -050060 U_BOOT_CMD_MKENT(ramdisk, 0, 1, (void *)BOOTM_STATE_RAMDISK, "", ""),
61#endif
62#ifdef CONFIG_OF_LIBFDT
63 U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)BOOTM_STATE_FDT, "", ""),
64#endif
Kumar Gala49c3a862008-10-21 17:25:45 -050065 U_BOOT_CMD_MKENT(cmdline, 0, 1, (void *)BOOTM_STATE_OS_CMDLINE, "", ""),
Peter Tyser224c90d2009-11-18 19:08:59 -060066 U_BOOT_CMD_MKENT(bdt, 0, 1, (void *)BOOTM_STATE_OS_BD_T, "", ""),
Kumar Gala49c3a862008-10-21 17:25:45 -050067 U_BOOT_CMD_MKENT(prep, 0, 1, (void *)BOOTM_STATE_OS_PREP, "", ""),
Simon Glassd0ae31e2013-06-11 11:14:48 -070068 U_BOOT_CMD_MKENT(fake, 0, 1, (void *)BOOTM_STATE_OS_FAKE_GO, "", ""),
Kumar Gala49c3a862008-10-21 17:25:45 -050069 U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""),
70};
71
Philippe Reynes7bebc112022-03-28 22:57:07 +020072#if defined(CONFIG_CMD_BOOTM_PRE_LOAD)
73static ulong bootm_get_addr(int argc, char *const argv[])
74{
75 ulong addr;
76
77 if (argc > 0)
78 addr = hextoul(argv[0], NULL);
79 else
80 addr = image_load_addr;
81
82 return addr;
83}
84#endif
85
Simon Glass09140112020-05-10 11:40:03 -060086static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc,
87 char *const argv[])
Kumar Gala49c3a862008-10-21 17:25:45 -050088{
89 int ret = 0;
Simon Glass6d6f1232011-10-07 13:53:40 +000090 long state;
Simon Glass09140112020-05-10 11:40:03 -060091 struct cmd_tbl *c;
Kumar Gala49c3a862008-10-21 17:25:45 -050092
Simon Glass983c72f2013-06-11 11:14:46 -070093 c = find_cmd_tbl(argv[0], &cmd_bootm_sub[0], ARRAY_SIZE(cmd_bootm_sub));
94 argc--; argv++;
Kumar Gala49c3a862008-10-21 17:25:45 -050095
96 if (c) {
Simon Glass6d6f1232011-10-07 13:53:40 +000097 state = (long)c->cmd;
Simon Glass983c72f2013-06-11 11:14:46 -070098 if (state == BOOTM_STATE_START)
Philippe Reynes9d46e632022-03-28 22:57:00 +020099 state |= BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOS |
100 BOOTM_STATE_FINDOTHER;
Philippe Reynes7bebc112022-03-28 22:57:07 +0200101#if defined(CONFIG_CMD_BOOTM_PRE_LOAD)
102 if (state == BOOTM_STATE_PRE_LOAD)
103 state |= BOOTM_STATE_START;
104#endif
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200105 } else {
106 /* Unrecognized command */
Simon Glass4c12eeb2011-12-10 08:44:01 +0000107 return CMD_RET_USAGE;
Kumar Gala49c3a862008-10-21 17:25:45 -0500108 }
109
Heiko Schocherff6c0322015-02-24 07:04:38 +0100110 if (((state & BOOTM_STATE_START) != BOOTM_STATE_START) &&
111 images.state >= state) {
Stephen Warren712fbcf2011-10-18 11:11:49 +0000112 printf("Trying to execute a command out of order\n");
Simon Glass4c12eeb2011-12-10 08:44:01 +0000113 return CMD_RET_USAGE;
Kumar Gala49c3a862008-10-21 17:25:45 -0500114 }
115
Simon Glass35fc84f2013-06-11 11:14:47 -0700116 ret = do_bootm_states(cmdtp, flag, argc, argv, state, &images, 0);
Kumar Gala49c3a862008-10-21 17:25:45 -0500117
Philippe Reynes7bebc112022-03-28 22:57:07 +0200118#if defined(CONFIG_CMD_BOOTM_PRE_LOAD)
119 if (!ret && (state & BOOTM_STATE_PRE_LOAD))
120 env_set_hex("loadaddr_verified",
121 bootm_get_addr(argc, argv) + image_load_offset);
122#endif
123
Simon Glassf06443f2022-10-11 09:47:08 -0600124 return ret ? CMD_RET_FAILURE : 0;
Kumar Gala49c3a862008-10-21 17:25:45 -0500125}
126
Mingyen Hung6e468002023-01-04 23:43:04 -0800127#if CONFIG_IS_ENABLED(CMD_BOOTCTOL_AVB)
Xindong Xuac88caf2024-10-28 17:10:12 +0800128#ifdef CONFIG_AVB2
Mingyen Hung6e468002023-01-04 23:43:04 -0800129#if CONFIG_IS_ENABLED(AML_ANTIROLLBACK) || CONFIG_IS_ENABLED(AML_AVB2_ANTIROLLBACK)
130static void bootm_avb_bootctl_anti_rollback(int rc, AvbSlotVerifyData *out_data)
131{
132 if (rc == AVB_SLOT_VERIFY_RESULT_OK && is_avb_arb_available() &&
133 !set_successful_boot() &&
134 out_data) {
135 u32 i = 0;
136 u32 version = 0;
137
138 for (i = 0; i < AVB_MAX_NUMBER_OF_ROLLBACK_INDEX_LOCATIONS; i++) {
139 u64 rb_idx = out_data->rollback_indexes[i];
140
Matthew Shyuf4c93732024-12-04 02:21:24 -0800141 if (rb_idx != 0 && get_avb_antirollback(i, &version) &&
Mingyen Hung6e468002023-01-04 23:43:04 -0800142 version < (u32)rb_idx &&
143 !set_avb_antirollback(i, (u32)rb_idx)) {
144 printf("rollback(%d) = %u failed\n",
145 i, (u32)rb_idx);
146 }
147 }
148 }
149
150 if (is_avb_arb_available() &&
151 rc == AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX &&
152 has_boot_slot == 1) {
153 printf("ab mode\n");
154 update_rollback();
155 env_set("write_boot", "0");
156 run_command("saveenv", 0);
157 run_command("reset", 0);
158 }
159}
160#endif
Xindong Xuac88caf2024-10-28 17:10:12 +0800161#endif
Mingyen Hung6e468002023-01-04 23:43:04 -0800162
163static int bootm_avb_bootctl(void)
164{
165 int rc = 0;
Xindong Xuac88caf2024-10-28 17:10:12 +0800166
167#ifdef CONFIG_AVB2
Mingyen Hung6e468002023-01-04 23:43:04 -0800168 char *newbootargs = NULL;
169 AvbSlotVerifyData *out_data = NULL;
Mingyen Hung6e468002023-01-04 23:43:04 -0800170 char *bootargs = NULL;
171 char *avb_cmdline = "\0";
172 const char *bootstate_o = "androidboot.verifiedbootstate=orange";
173 const char *bootstate_g = "androidboot.verifiedbootstate=green";
174 const char *bootstate = "\0";
175 u8 vbmeta_digest[AVB_SHA256_DIGEST_SIZE];
176 const int is_dev_unlocked = is_device_unlocked();
177
178 rc = avb_verify(&out_data);
179 if (is_dev_unlocked) {
180 printf("unlock state, ignore the avb check\n");
181 bootstate = bootstate_o;
182 /* return ok due to ignore error */
183 rc = AVB_SLOT_VERIFY_RESULT_OK;
184 } else {
185 printf("lock state, need avb check\n");
186 printf("avb verification: locked = %d, result = %d\n",
187 !is_dev_unlocked, rc);
188#if CONFIG_IS_ENABLED(AML_ANTIROLLBACK) || CONFIG_IS_ENABLED(AML_AVB2_ANTIROLLBACK)
189 bootm_avb_bootctl_anti_rollback(rc, out_data);
190#endif
191 if (rc != AVB_SLOT_VERIFY_RESULT_OK)
192 goto out;
193 else
194 bootstate = bootstate_g;
195 }
196
197 if (out_data) {
198 /* Trying to set boot params */
199 keymaster_boot_params boot_params;
200 AvbVBMetaImageHeader toplevel_vbmeta;
201
202 avb_vbmeta_image_header_to_host_byte_order
203 ((const AvbVBMetaImageHeader *)
204 out_data->vbmeta_images[0].vbmeta_data,
205 &toplevel_vbmeta);
206
207 boot_params.boot_patchlevel =
208 avb_get_boot_patchlevel_from_vbmeta(out_data);
209
210 create_csrs();
211
212 boot_params.device_locked = is_dev_unlocked ? 0 : 1;
213 if (is_dev_unlocked ||
214 (toplevel_vbmeta.flags &
215 AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED) ||
216 (toplevel_vbmeta.flags &
217 AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED)) {
218 bootstate = bootstate_o;
219 boot_params.verified_boot_state = 2;
220 } else {
221 bootstate = bootstate_g;
222 boot_params.verified_boot_state = 0;
223 }
224
225 memcpy(boot_params.verified_boot_key, boot_key_hash,
226 sizeof(boot_params.verified_boot_key));
227
228 avb_slot_verify_data_calculate_vbmeta_digest(out_data,
229 AVB_DIGEST_TYPE_SHA256,
230 vbmeta_digest);
231 memcpy(boot_params.verified_boot_hash, vbmeta_digest,
232 sizeof(boot_params.verified_boot_hash));
233
234 if (set_boot_params(&boot_params) < 0)
235 printf("failed to set boot params.\n");
236 }
237
238 /* complete env string */
239 bootargs = env_get("bootconfig");
240 if (!bootargs)
241 bootargs = "\0";
242
243 if (out_data && out_data->cmdline)
244 avb_cmdline = out_data->cmdline;
245
246 newbootargs = malloc(strlen(bootargs) + strlen(avb_cmdline)
247 + strlen(bootstate) + 1 + 1 + 1); // spaces and EOL
248 if (!newbootargs) {
249 printf("failed to allocate buffer for bootarg\n");
250 goto out;
251 }
252 sprintf(newbootargs, "%s %s %s", bootargs,
253 avb_cmdline, bootstate);
254 env_set("bootconfig", newbootargs);
255 free(newbootargs);
Xindong Xuac88caf2024-10-28 17:10:12 +0800256
Mingyen Hung6e468002023-01-04 23:43:04 -0800257out:
258 if (out_data)
259 avb_slot_verify_data_free(out_data);
Xindong Xuac88caf2024-10-28 17:10:12 +0800260#endif
Mingyen Hung6e468002023-01-04 23:43:04 -0800261 return rc;
262}
263#endif
264
Kumar Gala396f6352008-08-15 08:24:41 -0500265/*******************************************************************/
266/* bootm - boot application image from image in memory */
267/*******************************************************************/
Kumar Galabe083152008-10-21 17:25:44 -0500268
Simon Glass09140112020-05-10 11:40:03 -0600269int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Kumar Gala396f6352008-08-15 08:24:41 -0500270{
Simon Glass2c0b61d2022-10-11 09:47:09 -0600271 int states;
Simon Glassf06443f2022-10-11 09:47:08 -0600272 int ret;
Zhigang Yueca9a2e2024-04-18 08:16:09 +0000273
274 if (IS_ENABLED(CONFIG_AMLOGIC_MODIFY)) {
275 /* add reboot_mode in bootargs for kernel command line */
276 char *pbootargs = env_get("bootargs");
277 char *preboot_mode = env_get("reboot_mode");
278 char *recoverystr = "factory_reset";
279 char *precovery_mode = env_get("recovery_mode");
280
281 //if recovery mode need set reboot_mode factory_reset
282 //for drm driver init recovery by reboot_mode
283 if (precovery_mode && !strcmp(precovery_mode, "true"))
284 preboot_mode = recoverystr;
285
286 if (pbootargs && preboot_mode) {
287 int nlen = strlen(pbootargs) + strlen(preboot_mode) + 16;
288 char *pnewargs = malloc(nlen);
289
290 if (pnewargs) {
291 memset((void *)pnewargs, 0, nlen);
292 sprintf(pnewargs, "%s reboot_mode=%s\n", pbootargs, preboot_mode);
293 env_set("bootargs", pnewargs);
294 free(pnewargs);
295 pnewargs = NULL;
296 } else {
297 puts("Error: malloc in pnewbootargs failed!\n");
298 }
299 } else {
300 puts("Error: add reboot_mode in bootargs failed!\n");
301 }
302 }
303
Zhongfu Luodd243f42023-12-20 19:20:54 +0800304#if !defined(CONFIG_SKIP_KERNEL_DTB_SECBOOT_CHECK) && defined(CONFIG_IMAGE_CHECK)
305 char argv0_new[12] = {0};
306 char *argv_new = (char *)&argv0_new;
307#endif
Simon Glassf06443f2022-10-11 09:47:08 -0600308
Wolfgang Denk2e5167c2010-10-28 20:00:11 +0200309#ifdef CONFIG_NEEDS_MANUAL_RELOC
Peter Tyser521af042009-09-21 11:20:36 -0500310 static int relocated = 0;
Kumar Galabe083152008-10-21 17:25:44 -0500311
Kumar Galabe083152008-10-21 17:25:44 -0500312 if (!relocated) {
313 int i;
Daniel Schwierzeck58bd77d2013-01-07 06:54:52 +0000314
Daniel Schwierzeck58bd77d2013-01-07 06:54:52 +0000315 /* relocate names of sub-command table */
316 for (i = 0; i < ARRAY_SIZE(cmd_bootm_sub); i++)
317 cmd_bootm_sub[i].name += gd->reloc_off;
318
Kumar Galabe083152008-10-21 17:25:44 -0500319 relocated = 1;
320 }
Peter Tyser521af042009-09-21 11:20:36 -0500321#endif
Kumar Gala396f6352008-08-15 08:24:41 -0500322
Kumar Gala49c3a862008-10-21 17:25:45 -0500323 /* determine if we have a sub command */
Simon Glass983c72f2013-06-11 11:14:46 -0700324 argc--; argv++;
325 if (argc > 0) {
Kumar Gala49c3a862008-10-21 17:25:45 -0500326 char *endp;
327
Simon Glass7e5f4602021-07-24 09:03:29 -0600328 hextoul(argv[0], &endp);
Simon Glass983c72f2013-06-11 11:14:46 -0700329 /* endp pointing to NULL means that argv[0] was just a
Kumar Gala49c3a862008-10-21 17:25:45 -0500330 * valid number, pass it along to the normal bootm processing
331 *
332 * If endp is ':' or '#' assume a FIT identifier so pass
333 * along for normal processing.
334 *
335 * Right now we assume the first arg should never be '-'
336 */
337 if ((*endp != 0) && (*endp != ':') && (*endp != '#'))
338 return do_bootm_subcommand(cmdtp, flag, argc, argv);
339 }
340
Zhongfu Luo04a29ff2023-07-31 15:53:00 +0800341#if !defined(CONFIG_SKIP_KERNEL_DTB_SECBOOT_CHECK) && defined(CONFIG_IMAGE_CHECK)
342 unsigned int loadaddr = GXB_IMG_LOAD_ADDR; //default load address
343
344 if (argc > 0)
345 {
346 char *endp;
347 loadaddr = simple_strtoul(argv[0], &endp, 16);
348 //printf("aml log : addr = 0x%x\n",loadaddr);
349 }
350
351 if (IS_FEAT_BOOT_VERIFY()) {
352 int ret = 0;
353
Mingyen Hung6e468002023-01-04 23:43:04 -0800354 ret = secure_image_check((u8 *)(unsigned long)loadaddr,
355 GXB_IMG_SIZE, GXB_IMG_DEC_ALL);
Zhongfu Luo04a29ff2023-07-31 15:53:00 +0800356 if (ret) {
357 printf("\naml log : Sig Check %d\n", ret);
358 return ret;
359 }
360 /* Override load address argument to skip secure boot header.
361 * Only skip if secure boot so normal boot can use plain boot.img+
362 */
363 ulong img_addr, ncheckoffset;
Zhongfu Luo04a29ff2023-07-31 15:53:00 +0800364
365 img_addr = genimg_get_kernel_addr(argc < 1 ? NULL : argv[0]);
366 ncheckoffset = android_image_check_offset();
367 img_addr += ncheckoffset;
368 snprintf(argv0_new, sizeof(argv0_new), "%lx", img_addr);
369 argc = 1;
370 argv = (char **)&argv_new;
371 }
372#endif
Xindong Xu22e8daf2024-03-12 18:08:41 +0800373
374#ifdef CONFIG_AMLOGIC_MODIFY
375 char *fastboot_step = env_get("fastboot_step");
376
377 if (fastboot_step && (strcmp(fastboot_step, "2") == 0)) {
378 //come to here, means new burn bootloader.img is OK, reset env
379 printf("new burn bootloader.img is OK, write other bootloader\n");
380 char *gpt_mode = env_get("gpt_mode");
381 char *nocs_mode = env_get("nocs_mode");
382
383 if ((gpt_mode && !strcmp(gpt_mode, "true")) ||
384 (nocs_mode && !strcmp(nocs_mode, "true"))) {
385 printf("gpt or disable user bootloader mode\n");
386 run_command("copy_slot_bootable 2 1", 0);
387 } else {
388 printf("normal mode\n");
389 run_command("copy_slot_bootable 1 0", 0);
390 run_command("copy_slot_bootable 1 2", 0);
391 }
392
393 env_set("fastboot_step", "0");
394#if CONFIG_IS_ENABLED(AML_UPDATE_ENV)
395 run_command("update_env_part -p fastboot_step;", 0);
396#else
397 run_command("defenv_reserve;setenv fastboot_step 0;saveenv;", 0);
398#endif
399 }
400#endif
401
Mingyen Hung6e468002023-01-04 23:43:04 -0800402#if CONFIG_IS_ENABLED(CMD_BOOTCTOL_AVB)
403 ret = bootm_avb_bootctl();
404 if (ret) {
405 printf("bootm_avb_bootctl failed(%d)\n", ret);
406 return CMD_RET_FAILURE;
407 }
408#endif
Simon Glass2c0b61d2022-10-11 09:47:09 -0600409 states = BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD |
410 BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS |
Paul Burton5c427e42013-09-06 11:23:55 +0100411 BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
Simon Glass2c0b61d2022-10-11 09:47:09 -0600412 BOOTM_STATE_OS_GO;
413 if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
414 states |= BOOTM_STATE_RAMDISK;
415 if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_MIPS))
416 states |= BOOTM_STATE_OS_CMDLINE;
417 ret = do_bootm_states(cmdtp, flag, argc, argv, states, &images, 1);
Simon Glassf06443f2022-10-11 09:47:08 -0600418
419 return ret ? CMD_RET_FAILURE : 0;
wdenk47d1a6e2002-11-03 00:01:44 +0000420}
421
Simon Glass09140112020-05-10 11:40:03 -0600422int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd)
Mike Frysinger67d668b2011-06-05 13:43:02 +0000423{
Simon Glass78398652021-10-21 21:08:52 -0600424 if (env_get_autostart()) {
Mike Frysinger67d668b2011-06-05 13:43:02 +0000425 char *local_args[2];
426 local_args[0] = (char *)cmd;
427 local_args[1] = NULL;
Simon Glassbb872dd2019-12-28 10:45:02 -0700428 printf("Automatic boot of image at addr 0x%08lX ...\n",
429 image_load_addr);
Mike Frysinger67d668b2011-06-05 13:43:02 +0000430 return do_bootm(cmdtp, 0, 1, local_args);
431 }
432
433 return 0;
434}
435
Kim Phillips088f1b12012-10-29 13:34:31 +0000436#ifdef CONFIG_SYS_LONGHELP
437static char bootm_help_text[] =
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100438 "[addr [arg ...]]\n - boot application image stored in memory\n"
439 "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
440 "\t'arg' can be the address of an initrd image\n"
Marian Balakowicz4a2ad5f2008-01-31 13:20:07 +0100441#if defined(CONFIG_OF_LIBFDT)
Matthew McClintock98a9c4d2006-06-28 10:41:37 -0500442 "\tWhen booting a Linux kernel which requires a flat device-tree\n"
Detlev Zundel5441f612007-10-19 16:47:26 +0200443 "\ta third argument is required which is the address of the\n"
Matthew McClintock98a9c4d2006-06-28 10:41:37 -0500444 "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
445 "\tuse a '-' for the second argument. If you do not pass a third\n"
446 "\ta bd_info struct will be passed instead\n"
447#endif
Marian Balakowicz6986a382008-03-12 10:01:05 +0100448#if defined(CONFIG_FIT)
449 "\t\nFor the new multi component uImage format (FIT) addresses\n"
Vagrant Cascadianda1a3bd2016-10-23 20:45:18 -0700450 "\tmust be extended to include component or configuration unit name:\n"
Marian Balakowicz6986a382008-03-12 10:01:05 +0100451 "\taddr:<subimg_uname> - direct component image specification\n"
452 "\taddr#<conf_uname> - configuration specification\n"
453 "\tUse iminfo command to get the list of existing component\n"
454 "\timages and configurations.\n"
455#endif
Kumar Gala49c3a862008-10-21 17:25:45 -0500456 "\nSub-commands to do part of the bootm sequence. The sub-commands "
457 "must be\n"
458 "issued in the order below (it's ok to not issue all sub-commands):\n"
459 "\tstart [addr [arg ...]]\n"
Philippe Reynes7bebc112022-03-28 22:57:07 +0200460#if defined(CONFIG_CMD_BOOTM_PRE_LOAD)
461 "\tpreload [addr [arg ..]] - run only the preload stage\n"
462#endif
Kumar Gala49c3a862008-10-21 17:25:45 -0500463 "\tloados - load OS image\n"
Daniel Schwierzeck59af76d2013-02-26 04:54:19 +0000464#if defined(CONFIG_SYS_BOOT_RAMDISK_HIGH)
Kumar Gala49c3a862008-10-21 17:25:45 -0500465 "\tramdisk - relocate initrd, set env initrd_start/initrd_end\n"
466#endif
467#if defined(CONFIG_OF_LIBFDT)
468 "\tfdt - relocate flat device tree\n"
469#endif
Kumar Gala49c3a862008-10-21 17:25:45 -0500470 "\tcmdline - OS specific command line processing/setup\n"
Masahiro Yamadabb5a2cf2020-06-26 15:13:34 +0900471 "\tbdt - OS specific bd_info processing\n"
Kumar Gala49c3a862008-10-21 17:25:45 -0500472 "\tprep - OS specific prep before relocation or go\n"
Michal Simeke3046ba2015-01-15 09:53:13 +0100473#if defined(CONFIG_TRACE)
474 "\tfake - OS specific fake start without go\n"
475#endif
Kim Phillips088f1b12012-10-29 13:34:31 +0000476 "\tgo - start OS";
477#endif
478
479U_BOOT_CMD(
480 bootm, CONFIG_SYS_MAXARGS, 1, do_bootm,
481 "boot application image from memory", bootm_help_text
wdenk8bde7f72003-06-27 21:31:46 +0000482);
483
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100484/*******************************************************************/
485/* bootd - boot default image */
486/*******************************************************************/
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500487#if defined(CONFIG_CMD_BOOTD)
Simon Glass09140112020-05-10 11:40:03 -0600488int do_bootd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
wdenk47d1a6e2002-11-03 00:01:44 +0000489{
Simon Glass00caae62017-08-03 12:22:12 -0600490 return run_command(env_get("bootcmd"), flag);
wdenk47d1a6e2002-11-03 00:01:44 +0000491}
wdenk8bde7f72003-06-27 21:31:46 +0000492
wdenk0d498392003-07-01 21:06:45 +0000493U_BOOT_CMD(
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100494 boot, 1, 1, do_bootd,
Peter Tyser2fb26042009-01-27 18:03:12 -0600495 "boot default, i.e., run 'bootcmd'",
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200496 ""
wdenk9d2b18a2003-06-28 23:11:04 +0000497);
498
499/* keep old command name "bootd" for backward compatibility */
wdenk0d498392003-07-01 21:06:45 +0000500U_BOOT_CMD(
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100501 bootd, 1, 1, do_bootd,
Peter Tyser2fb26042009-01-27 18:03:12 -0600502 "boot default, i.e., run 'bootcmd'",
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200503 ""
wdenk8bde7f72003-06-27 21:31:46 +0000504);
505
wdenk47d1a6e2002-11-03 00:01:44 +0000506#endif
507
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100508
509/*******************************************************************/
510/* iminfo - print header info for a requested image */
511/*******************************************************************/
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500512#if defined(CONFIG_CMD_IMI)
Simon Glass09140112020-05-10 11:40:03 -0600513static int do_iminfo(struct cmd_tbl *cmdtp, int flag, int argc,
514 char *const argv[])
wdenk47d1a6e2002-11-03 00:01:44 +0000515{
516 int arg;
517 ulong addr;
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100518 int rcode = 0;
wdenk47d1a6e2002-11-03 00:01:44 +0000519
520 if (argc < 2) {
Simon Glassbb872dd2019-12-28 10:45:02 -0700521 return image_info(image_load_addr);
wdenk47d1a6e2002-11-03 00:01:44 +0000522 }
523
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100524 for (arg = 1; arg < argc; ++arg) {
Simon Glass7e5f4602021-07-24 09:03:29 -0600525 addr = hextoul(argv[arg], NULL);
Stephen Warren712fbcf2011-10-18 11:11:49 +0000526 if (image_info(addr) != 0)
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100527 rcode = 1;
wdenk47d1a6e2002-11-03 00:01:44 +0000528 }
529 return rcode;
530}
531
Stephen Warren712fbcf2011-10-18 11:11:49 +0000532static int image_info(ulong addr)
wdenk47d1a6e2002-11-03 00:01:44 +0000533{
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100534 void *hdr = (void *)map_sysmem(addr, 0);
wdenk47d1a6e2002-11-03 00:01:44 +0000535
Stephen Warren712fbcf2011-10-18 11:11:49 +0000536 printf("\n## Checking Image at %08lx ...\n", addr);
wdenk47d1a6e2002-11-03 00:01:44 +0000537
Stephen Warren712fbcf2011-10-18 11:11:49 +0000538 switch (genimg_get_format(hdr)) {
Tom Rinic76c93a2019-05-23 07:14:07 -0400539#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100540 case IMAGE_FORMAT_LEGACY:
Stephen Warren712fbcf2011-10-18 11:11:49 +0000541 puts(" Legacy image found\n");
542 if (!image_check_magic(hdr)) {
543 puts(" Bad Magic Number\n");
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100544 unmap_sysmem(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100545 return 1;
546 }
547
Stephen Warren712fbcf2011-10-18 11:11:49 +0000548 if (!image_check_hcrc(hdr)) {
549 puts(" Bad Header Checksum\n");
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100550 unmap_sysmem(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100551 return 1;
552 }
553
Stephen Warren712fbcf2011-10-18 11:11:49 +0000554 image_print_contents(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100555
Stephen Warren712fbcf2011-10-18 11:11:49 +0000556 puts(" Verifying Checksum ... ");
557 if (!image_check_dcrc(hdr)) {
558 puts(" Bad Data CRC\n");
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100559 unmap_sysmem(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100560 return 1;
561 }
Stephen Warren712fbcf2011-10-18 11:11:49 +0000562 puts("OK\n");
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100563 unmap_sysmem(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100564 return 0;
Heiko Schocher21d29f72014-05-28 11:33:33 +0200565#endif
Michael Trimarchi4f1318b2016-06-10 19:54:37 +0200566#if defined(CONFIG_ANDROID_BOOT_IMAGE)
567 case IMAGE_FORMAT_ANDROID:
568 puts(" Android image found\n");
569 android_print_contents(hdr);
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100570 unmap_sysmem(hdr);
Michael Trimarchi4f1318b2016-06-10 19:54:37 +0200571 return 0;
572#endif
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100573#if defined(CONFIG_FIT)
574 case IMAGE_FORMAT_FIT:
Stephen Warren712fbcf2011-10-18 11:11:49 +0000575 puts(" FIT image found\n");
Marian Balakowicze32fea62008-03-11 12:35:20 +0100576
Simon Glassc5819702021-02-15 17:08:09 -0700577 if (fit_check_format(hdr, IMAGE_SIZE_INVAL)) {
Stephen Warren712fbcf2011-10-18 11:11:49 +0000578 puts("Bad FIT image format!\n");
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100579 unmap_sysmem(hdr);
Marian Balakowicze32fea62008-03-11 12:35:20 +0100580 return 1;
581 }
582
Stephen Warren712fbcf2011-10-18 11:11:49 +0000583 fit_print_contents(hdr);
Bartlomiej Siekaa4f24342008-09-09 12:58:16 +0200584
Simon Glassb8da8362013-05-07 06:11:57 +0000585 if (!fit_all_image_verify(hdr)) {
Stephen Warren712fbcf2011-10-18 11:11:49 +0000586 puts("Bad hash in FIT image!\n");
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100587 unmap_sysmem(hdr);
Bartlomiej Siekaa4f24342008-09-09 12:58:16 +0200588 return 1;
589 }
590
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100591 unmap_sysmem(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100592 return 0;
593#endif
594 default:
Stephen Warren712fbcf2011-10-18 11:11:49 +0000595 puts("Unknown image format!\n");
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100596 break;
wdenk47d1a6e2002-11-03 00:01:44 +0000597 }
598
Philippe Reynesae0d12f2019-12-02 15:45:50 +0100599 unmap_sysmem(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100600 return 1;
wdenk47d1a6e2002-11-03 00:01:44 +0000601}
wdenk0d498392003-07-01 21:06:45 +0000602
603U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200604 iminfo, CONFIG_SYS_MAXARGS, 1, do_iminfo,
Peter Tyser2fb26042009-01-27 18:03:12 -0600605 "print header information for application image",
wdenk8bde7f72003-06-27 21:31:46 +0000606 "addr [addr ...]\n"
607 " - print header information for application image starting at\n"
608 " address 'addr' in memory; this includes verification of the\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200609 " image contents (magic number, header and payload checksums)"
wdenk8bde7f72003-06-27 21:31:46 +0000610);
Jon Loeliger90253172007-07-10 11:02:44 -0500611#endif
wdenk47d1a6e2002-11-03 00:01:44 +0000612
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100613
614/*******************************************************************/
615/* imls - list all images found in flash */
616/*******************************************************************/
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500617#if defined(CONFIG_CMD_IMLS)
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000618static int do_imls_nor(void)
wdenk27b207f2003-07-24 23:38:38 +0000619{
620 flash_info_t *info;
621 int i, j;
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100622 void *hdr;
wdenk27b207f2003-07-24 23:38:38 +0000623
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100624 for (i = 0, info = &flash_info[0];
Patrick Delaunay98150e72022-01-04 14:23:58 +0100625 i < CFI_FLASH_BANKS; ++i, ++info) {
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100626
wdenk27b207f2003-07-24 23:38:38 +0000627 if (info->flash_id == FLASH_UNKNOWN)
628 goto next_bank;
Marian Balakowicz1ee11802008-01-08 18:17:10 +0100629 for (j = 0; j < info->sector_count; ++j) {
wdenk27b207f2003-07-24 23:38:38 +0000630
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100631 hdr = (void *)info->start[j];
632 if (!hdr)
wdenk27b207f2003-07-24 23:38:38 +0000633 goto next_sector;
634
Stephen Warren712fbcf2011-10-18 11:11:49 +0000635 switch (genimg_get_format(hdr)) {
Tom Rinic76c93a2019-05-23 07:14:07 -0400636#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100637 case IMAGE_FORMAT_LEGACY:
Stephen Warren712fbcf2011-10-18 11:11:49 +0000638 if (!image_check_hcrc(hdr))
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100639 goto next_sector;
640
Stephen Warren712fbcf2011-10-18 11:11:49 +0000641 printf("Legacy Image at %08lX:\n", (ulong)hdr);
642 image_print_contents(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100643
Stephen Warren712fbcf2011-10-18 11:11:49 +0000644 puts(" Verifying Checksum ... ");
645 if (!image_check_dcrc(hdr)) {
646 puts("Bad Data CRC\n");
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100647 } else {
Stephen Warren712fbcf2011-10-18 11:11:49 +0000648 puts("OK\n");
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100649 }
650 break;
Heiko Schocher21d29f72014-05-28 11:33:33 +0200651#endif
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100652#if defined(CONFIG_FIT)
653 case IMAGE_FORMAT_FIT:
Simon Glassc5819702021-02-15 17:08:09 -0700654 if (fit_check_format(hdr, IMAGE_SIZE_INVAL))
Marian Balakowicze32fea62008-03-11 12:35:20 +0100655 goto next_sector;
656
Stephen Warren712fbcf2011-10-18 11:11:49 +0000657 printf("FIT Image at %08lX:\n", (ulong)hdr);
658 fit_print_contents(hdr);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100659 break;
660#endif
661 default:
wdenk27b207f2003-07-24 23:38:38 +0000662 goto next_sector;
wdenk5bb226e2003-11-17 21:14:37 +0000663 }
Marian Balakowiczd5934ad2008-02-04 08:28:09 +0100664
wdenkbdccc4f2003-08-05 17:43:17 +0000665next_sector: ;
wdenk27b207f2003-07-24 23:38:38 +0000666 }
wdenkbdccc4f2003-08-05 17:43:17 +0000667next_bank: ;
wdenk27b207f2003-07-24 23:38:38 +0000668 }
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000669 return 0;
670}
671#endif
672
673#if defined(CONFIG_CMD_IMLS_NAND)
Scott Wood151c06e2016-05-30 13:57:54 -0500674static int nand_imls_legacyimage(struct mtd_info *mtd, int nand_dev,
675 loff_t off, size_t len)
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000676{
677 void *imgdata;
678 int ret;
679
680 imgdata = malloc(len);
681 if (!imgdata) {
682 printf("May be a Legacy Image at NAND device %d offset %08llX:\n",
683 nand_dev, off);
684 printf(" Low memory(cannot allocate memory for image)\n");
685 return -ENOMEM;
686 }
687
Grygorii Strashkodbe78812017-01-31 15:37:03 -0600688 ret = nand_read_skip_bad(mtd, off, &len, NULL, mtd->size, imgdata);
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000689 if (ret < 0 && ret != -EUCLEAN) {
690 free(imgdata);
691 return ret;
692 }
693
694 if (!image_check_hcrc(imgdata)) {
695 free(imgdata);
696 return 0;
697 }
698
699 printf("Legacy Image at NAND device %d offset %08llX:\n",
700 nand_dev, off);
701 image_print_contents(imgdata);
702
703 puts(" Verifying Checksum ... ");
704 if (!image_check_dcrc(imgdata))
705 puts("Bad Data CRC\n");
706 else
707 puts("OK\n");
708
709 free(imgdata);
710
711 return 0;
712}
713
Scott Wood151c06e2016-05-30 13:57:54 -0500714static int nand_imls_fitimage(struct mtd_info *mtd, int nand_dev, loff_t off,
715 size_t len)
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000716{
717 void *imgdata;
718 int ret;
719
720 imgdata = malloc(len);
721 if (!imgdata) {
722 printf("May be a FIT Image at NAND device %d offset %08llX:\n",
723 nand_dev, off);
724 printf(" Low memory(cannot allocate memory for image)\n");
725 return -ENOMEM;
726 }
727
Grygorii Strashkodbe78812017-01-31 15:37:03 -0600728 ret = nand_read_skip_bad(mtd, off, &len, NULL, mtd->size, imgdata);
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000729 if (ret < 0 && ret != -EUCLEAN) {
730 free(imgdata);
731 return ret;
732 }
733
Simon Glassc5819702021-02-15 17:08:09 -0700734 if (fit_check_format(imgdata, IMAGE_SIZE_INVAL)) {
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000735 free(imgdata);
736 return 0;
737 }
738
739 printf("FIT Image at NAND device %d offset %08llX:\n", nand_dev, off);
740
741 fit_print_contents(imgdata);
742 free(imgdata);
743
744 return 0;
745}
746
747static int do_imls_nand(void)
748{
Scott Wood151c06e2016-05-30 13:57:54 -0500749 struct mtd_info *mtd;
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000750 int nand_dev = nand_curr_device;
751 size_t len;
752 loff_t off;
753 u32 buffer[16];
754
755 if (nand_dev < 0 || nand_dev >= CONFIG_SYS_MAX_NAND_DEVICE) {
756 puts("\nNo NAND devices available\n");
757 return -ENODEV;
758 }
759
760 printf("\n");
761
762 for (nand_dev = 0; nand_dev < CONFIG_SYS_MAX_NAND_DEVICE; nand_dev++) {
Grygorii Strashkof370b512017-06-26 19:12:54 -0500763 mtd = get_nand_dev_by_index(nand_dev);
Scott Wood151c06e2016-05-30 13:57:54 -0500764 if (!mtd->name || !mtd->size)
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000765 continue;
766
Scott Wood151c06e2016-05-30 13:57:54 -0500767 for (off = 0; off < mtd->size; off += mtd->erasesize) {
Simon Glassf3543e62022-09-06 20:26:52 -0600768 const struct legacy_img_hdr *header;
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000769 int ret;
770
Scott Wood151c06e2016-05-30 13:57:54 -0500771 if (nand_block_isbad(mtd, off))
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000772 continue;
773
774 len = sizeof(buffer);
775
Scott Wood151c06e2016-05-30 13:57:54 -0500776 ret = nand_read(mtd, off, &len, (u8 *)buffer);
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000777 if (ret < 0 && ret != -EUCLEAN) {
778 printf("NAND read error %d at offset %08llX\n",
779 ret, off);
780 continue;
781 }
782
783 switch (genimg_get_format(buffer)) {
Tom Rinic76c93a2019-05-23 07:14:07 -0400784#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000785 case IMAGE_FORMAT_LEGACY:
Simon Glassf3543e62022-09-06 20:26:52 -0600786 header = (const struct legacy_img_hdr *)buffer;
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000787
788 len = image_get_image_size(header);
Scott Wood151c06e2016-05-30 13:57:54 -0500789 nand_imls_legacyimage(mtd, nand_dev, off, len);
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000790 break;
Heiko Schocher21d29f72014-05-28 11:33:33 +0200791#endif
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000792#if defined(CONFIG_FIT)
793 case IMAGE_FORMAT_FIT:
794 len = fit_get_size(buffer);
Scott Wood151c06e2016-05-30 13:57:54 -0500795 nand_imls_fitimage(mtd, nand_dev, off, len);
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000796 break;
797#endif
798 }
799 }
800 }
801
802 return 0;
803}
804#endif
805
806#if defined(CONFIG_CMD_IMLS) || defined(CONFIG_CMD_IMLS_NAND)
Simon Glass09140112020-05-10 11:40:03 -0600807static int do_imls(struct cmd_tbl *cmdtp, int flag, int argc,
808 char *const argv[])
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000809{
810 int ret_nor = 0, ret_nand = 0;
811
812#if defined(CONFIG_CMD_IMLS)
813 ret_nor = do_imls_nor();
814#endif
815
816#if defined(CONFIG_CMD_IMLS_NAND)
817 ret_nand = do_imls_nand();
818#endif
819
820 if (ret_nor)
821 return ret_nor;
822
823 if (ret_nand)
824 return ret_nand;
wdenk27b207f2003-07-24 23:38:38 +0000825
826 return (0);
827}
828
829U_BOOT_CMD(
830 imls, 1, 1, do_imls,
Peter Tyser2fb26042009-01-27 18:03:12 -0600831 "list all images found in flash",
wdenk27b207f2003-07-24 23:38:38 +0000832 "\n"
Vipin Kumar8fdf1e02012-12-16 22:32:48 +0000833 " - Prints information about all images found at sector/block\n"
834 " boundaries in nor/nand flash."
wdenk27b207f2003-07-24 23:38:38 +0000835);
Jon Loeliger90253172007-07-10 11:02:44 -0500836#endif