]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_usb.c
fdt: allow for builds that don't want env and bd_t nodes
[karo-tx-uboot.git] / common / cmd_usb.c
index 0738f55303352783671b3061ed79f686a9eec279..45e07f175c8792b6c5814c776e51207aa1b482f2 100644 (file)
@@ -28,8 +28,9 @@
 #include <common.h>
 #include <command.h>
 #include <asm/byteorder.h>
+#include <part.h>
 
-#if (CONFIG_COMMANDS & CFG_CMD_USB)
+#if defined(CONFIG_CMD_USB)
 
 #include <usb.h>
 
@@ -186,7 +187,7 @@ void usb_display_conf_desc(struct usb_config_descriptor *config,struct usb_devic
 void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,struct usb_device *dev)
 {
        printf("     Interface: %d\n",ifdesc->bInterfaceNumber);
-       printf("     - Alternate Settings %d, Endpoints: %d\n",ifdesc->bAlternateSetting,ifdesc->bNumEndpoints);
+       printf("     - Alternate Setting %d, Endpoints: %d\n",ifdesc->bAlternateSetting,ifdesc->bNumEndpoints);
        printf("     - Class ");
        usb_display_class_sub(ifdesc->bInterfaceClass,ifdesc->bInterfaceSubClass,ifdesc->bInterfaceProtocol);
        printf("\n");
@@ -362,15 +363,15 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        if (get_partition_info (stor_dev, part, &info)) {
                /* try to boot raw .... */
-               strncpy(&info.type[0], BOOT_PART_TYPE, sizeof(BOOT_PART_TYPE));
-               strncpy(&info.name[0], "Raw", 4);
+               strncpy((char *)&info.type[0], BOOT_PART_TYPE, sizeof(BOOT_PART_TYPE));
+               strncpy((char *)&info.name[0], "Raw", 4);
                info.start=0;
                info.blksz=0x200;
                info.size=2880;
                printf("error reading partinfo...try to boot raw\n");
        }
-       if ((strncmp(info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) &&
-           (strncmp(info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) {
+       if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) &&
+           (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) {
                printf ("\n** Invalid partition type \"%.32s\""
                        " (expect \"" BOOT_PART_TYPE "\")\n",
                        info.type);
@@ -398,7 +399,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        checksum = ntohl(hdr->ih_hcrc);
        hdr->ih_hcrc = 0;
 
-       if (crc32 (0, (char *)hdr, sizeof(image_header_t)) != checksum) {
+       if (crc32 (0, (uchar *)hdr, sizeof(image_header_t)) != checksum) {
                puts ("\n** Bad Header Checksum **\n");
                return 1;
        }
@@ -444,6 +445,7 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        int i;
        struct usb_device *dev = NULL;
+       extern char usb_started;
 #ifdef CONFIG_USB_STORAGE
        block_dev_desc_t *stor_dev;
 #endif
@@ -477,6 +479,10 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                usb_stop();
                return 0;
        }
+       if (!usb_started) {
+               printf("USB is stopped. Please issue 'usb start' first.\n");
+               return 1;
+       }
        if (strncmp(argv[1],"tree",4) == 0) {
                printf("\nDevice Tree:\n");
                usb_show_tree(usb_get_dev_index(0));
@@ -603,10 +609,10 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 }
 
 
-#endif /* (CONFIG_COMMANDS & CFG_CMD_USB) */
+#endif
 
 
-#if (CONFIG_COMMANDS & CFG_CMD_USB)
+#if defined(CONFIG_CMD_USB)
 
 #ifdef CONFIG_USB_STORAGE
 U_BOOT_CMD(