]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_usb.c
[new uImage] Update naming convention for bootm/uImage related code
[karo-tx-uboot.git] / common / cmd_usb.c
index c6b17c2ab7ad2af8d74ac4ce4c55c63e07f60dac..8ee7d27675eb18393e7cd1b790cb95375ad68194 100644 (file)
@@ -311,7 +311,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        char *boot_device = NULL;
        char *ep;
        int dev, part=1, rcode;
-       ulong addr, cnt, checksum;
+       ulong addr, cnt;
        disk_partition_t info;
        image_header_t *hdr;
        block_dev_desc_t *stor_dev;
@@ -386,25 +386,34 @@ int do_usbboot (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_magic (hdr)) {
+                       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);
 
-       if (crc32 (0, (uchar *)hdr, sizeof(image_header_t)) != checksum) {
-               puts ("\n** Bad Header Checksum **\n");
+               cnt = image_get_image_size (hdr);
+               break;
+#if defined(CONFIG_FIT)
+       case IMAGE_FORMAT_FIT:
+               fit_unsupported ("usbboot");
+               return 1;
+#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;