X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fcmd_scsi.c;h=e648f7d6014eb1bf31f8eb972b6d222e6a582bfa;hb=4b13860e746b65e796213f2c97de8a80db8b68be;hp=1cdec159f5a8d71aef09a73292a4bc21dcb48355;hpb=fe08fb658008cd4be54758faa5d382a2b3b1f86a;p=u-boot diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index 1cdec159f5..e648f7d601 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -207,10 +207,13 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) char *boot_device = NULL; char *ep; int dev, part = 0; - ulong addr, cnt, checksum; + ulong addr, cnt; disk_partition_t info; image_header_t *hdr; int rcode = 0; +#if defined(CONFIG_FIT) + const void *fit_hdr = NULL; +#endif switch (argc) { case 1: @@ -273,24 +276,31 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } - hdr = (image_header_t *)addr; + switch (genimg_get_format ((void *)addr)) { + case IMAGE_FORMAT_LEGACY: + hdr = (image_header_t *)addr; - if (ntohl(hdr->ih_magic) == IH_MAGIC) { - printf("\n** Bad Magic Number **\n"); - return 1; - } + if (!image_check_hcrc (hdr)) { + puts ("\n** Bad Header Checksum **\n"); + return 1; + } - checksum = ntohl(hdr->ih_hcrc); - hdr->ih_hcrc = 0; + image_print_contents (hdr); + cnt = image_get_image_size (hdr); + break; +#if defined(CONFIG_FIT) + case IMAGE_FORMAT_FIT: + fit_hdr = (const void *)addr; + puts ("Fit image detected...\n"); - if (crc32 (0, (uchar *)hdr, sizeof(image_header_t)) != checksum) { - puts ("\n** Bad Header Checksum **\n"); + cnt = fit_get_size (fit_hdr); + break; +#endif + default: + puts ("** Unknown image type\n"); return 1; } - hdr->ih_hcrc = htonl(checksum); /* restore checksum for later use */ - print_image_hdr (hdr); - cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t)); cnt += info.blksz - 1; cnt /= info.blksz; cnt -= 1; @@ -300,6 +310,18 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf ("** Read error on %d:%d\n", dev, part); return 1; } + +#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) { + if (!fit_check_format (fit_hdr)) { + puts ("** Bad FIT image format\n"); + return 1; + } + fit_print_contents (fit_hdr); + } +#endif + /* Loading ok, update default load address */ load_addr = addr; @@ -372,7 +394,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } printf ("Usage:\n%s\n", cmdtp->usage); return 1; - case 3: + case 3: if (strncmp(argv[1],"dev",3) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); printf ("\nSCSI device %d: ", dev);