Newer
Older
printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
offset);
Bartlomiej Sieka
committed
if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset,
SECTORSIZE, NULL, (u_char *)addr)) {
printf ("** Read error on %d\n", dev);
switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
Marian Balakowicz
committed
image_print_contents (hdr);
Marian Balakowicz
committed
cnt = image_get_image_size (hdr);
cnt -= SECTORSIZE;
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
Marian Balakowicz
committed
fit_hdr = (const void *)addr;
if (!fit_check_format (fit_hdr)) {
show_boot_progress (-150);
Marian Balakowicz
committed
puts ("** Bad FIT image format\n");
return 1;
}
show_boot_progress (151);
Marian Balakowicz
committed
puts ("Fit image detected...\n");
cnt = fit_get_size (fit_hdr);
break;
#endif
default:
Marian Balakowicz
committed
show_boot_progress (-57);
puts ("** Unknown image type\n");
Bartlomiej Sieka
committed
if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ,
offset + SECTORSIZE, cnt, NULL,
(u_char *)(addr+SECTORSIZE))) {
printf ("** Read error on %d\n", dev);
Marian Balakowicz
committed
#if defined(CONFIG_FIT)
/* This cannot be done earlier, we need complete FIT image in RAM first */
if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
fit_print_contents ((const void *)addr);
#endif
/* Loading ok, update default load address */
load_addr = addr;
/* Check if we should attempt an auto-start */
if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
char *local_args[2];
extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
local_args[0] = argv[0];
local_args[1] = NULL;
printf ("Automatic boot of image at addr 0x%08lx ...\n", addr);
do_bootm (cmdtp, 0, 1, local_args);
rcode = 1;
}
return rcode;
}
U_BOOT_CMD(
nboot, 4, 1, do_nandboot,
"nboot - boot from NAND device\n",
"loadAddr dev\n"
);
#endif
Bartlomiej Sieka
committed
#endif /* CFG_NAND_LEGACY */