summaryrefslogtreecommitdiff
path: root/common/cmd_usb.c
diff options
context:
space:
mode:
authorwdenk <wdenk>2005-02-03 23:00:49 +0000
committerwdenk <wdenk>2005-02-03 23:00:49 +0000
commit1a344f298d9d334f7bec631432c10c0666d04757 (patch)
tree928b89cfceef24f254bae64ae971f316f9e0a8fb /common/cmd_usb.c
parent436be29cad60a46ed5983120aff71909d8f234a3 (diff)
downloadu-boot-imx-1a344f298d9d334f7bec631432c10c0666d04757.zip
u-boot-imx-1a344f298d9d334f7bec631432c10c0666d04757.tar.gz
u-boot-imx-1a344f298d9d334f7bec631432c10c0666d04757.tar.bz2
* Removed '--no-warn-mismatch' option from Makefile. This option
makes 'ld' to overlook binary objects compatibility. * Moved $(PLATFORM_LIBS) from the library group (--start-group ... --end-group) outside of the group. This will make 'ld' to do _multiple_ search in the library group when resolving symbol references and do only a _single_ seach in libgcc.a after the group search. * Fix stability problems on CPC45 board again. * Make image detection for diskboot / usbboot / scsiboot more robust (also check header checksum)
Diffstat (limited to 'common/cmd_usb.c')
-rw-r--r--common/cmd_usb.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 83004b5..3227db9 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -32,13 +32,6 @@
#include <usb.h>
-#undef CMD_USB_DEBUG
-
-#ifdef CMD_USB_DEBUG
-#define CMD_USB_PRINTF(fmt,args...) printf (fmt ,##args)
-#else
-#define CMD_USB_PRINTF(fmt,args...)
-#endif
static int usb_stor_curr_dev=-1; /* current device */
/* some display routines (info command) */
@@ -317,8 +310,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
char *boot_device = NULL;
char *ep;
int dev, part=0, rcode;
- ulong cnt;
- ulong addr;
+ ulong addr, cnt, checksum;
disk_partition_t info;
image_header_t *hdr;
block_dev_desc_t *stor_dev;
@@ -385,7 +377,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
"Name: %.32s Type: %.32s\n",
dev, part, info.name, info.type);
- printf ("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
+ debug ("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
info.start, info.size, info.blksz);
if (stor_dev->block_read(dev, info.start, 1, (ulong *)addr) != 1) {
@@ -395,17 +387,26 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
hdr = (image_header_t *)addr;
- if (hdr->ih_magic == IH_MAGIC) {
- print_image_hdr (hdr);
- cnt = (hdr->ih_size + sizeof(image_header_t));
- cnt += info.blksz - 1;
- cnt /= info.blksz;
- cnt -= 1;
- } else {
+ if (hdr->ih_magic != IH_MAGIC) {
printf("\n** Bad Magic Number **\n");
return 1;
}
+ checksum = ntohl(hdr->ih_hcrc);
+ hdr->ih_hcrc = 0;
+
+ if (crc32 (0, (char *)hdr, sizeof(image_header_t)) != checksum) {
+ puts ("\n** Bad Header Checksum **\n");
+ return 1;
+ }
+
+ print_image_hdr (hdr);
+
+ cnt = (hdr->ih_size + sizeof(image_header_t));
+ cnt += info.blksz - 1;
+ cnt /= info.blksz;
+ cnt -= 1;
+
if (stor_dev->block_read (dev, info.start+1, cnt,
(ulong *)(addr+info.blksz)) != cnt) {
printf ("\n** Read error on %d:%d\n", dev, part);