summaryrefslogtreecommitdiff
path: root/common/cmd_usb.c
diff options
context:
space:
mode:
authorGerald Van Baren <vanbaren@cideas.com>2008-03-29 18:08:02 -0400
committerGerald Van Baren <vanbaren@cideas.com>2008-03-29 18:08:02 -0400
commit3596d55eb22703d3f4f1b839fe4b000fabe081b3 (patch)
tree96d1ce693dc72c2fbc63da37928afd4761e82fd2 /common/cmd_usb.c
parent493a2b1dc97367e904bf83869501f6290f3b374e (diff)
parent74d1e66d22dac91388bc538b2fe19f735edc5b82 (diff)
downloadu-boot-imx-3596d55eb22703d3f4f1b839fe4b000fabe081b3.zip
u-boot-imx-3596d55eb22703d3f4f1b839fe4b000fabe081b3.tar.gz
u-boot-imx-3596d55eb22703d3f4f1b839fe4b000fabe081b3.tar.bz2
Merge git://www.denx.de/git/u-boot into uboot
Diffstat (limited to 'common/cmd_usb.c')
-rw-r--r--common/cmd_usb.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index c6b17c2..23413b5 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -311,11 +311,13 @@ 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;
-
+#if defined(CONFIG_FIT)
+ const void *fit_hdr;
+#endif
switch (argc) {
case 1:
@@ -386,25 +388,36 @@ 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_hcrc (hdr)) {
+ puts ("\n** Bad Header Checksum **\n");
+ return 1;
+ }
+
+ image_print_contents (hdr);
- checksum = ntohl(hdr->ih_hcrc);
- hdr->ih_hcrc = 0;
+ cnt = image_get_image_size (hdr);
+ break;
+#if defined(CONFIG_FIT)
+ case IMAGE_FORMAT_FIT:
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("** Bad FIT image format\n");
+ return 1;
+ }
+ 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;
@@ -414,6 +427,13 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
printf ("\n** 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)
+ fit_print_contents ((const void *)addr);
+#endif
+
/* Loading ok, update default load address */
load_addr = addr;
@@ -529,8 +549,7 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
if (strncmp(argv[1], "stor", 4) == 0) {
- usb_stor_info();
- return 0;
+ return usb_stor_info();
}
if (strncmp(argv[1],"part",4) == 0) {