diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-12-31 20:59:23 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-12-31 20:59:23 +0000 |
commit | 9bdb91ec537f8a7889a816cf989e6d91054effe5 (patch) | |
tree | f05fe58bed011e432506fefdea124c1f9372b27b /nuttx/drivers | |
parent | 714575b61092daa986ffdc535bec98d181114509 (diff) | |
download | px4-nuttx-9bdb91ec537f8a7889a816cf989e6d91054effe5.tar.gz px4-nuttx-9bdb91ec537f8a7889a816cf989e6d91054effe5.tar.bz2 px4-nuttx-9bdb91ec537f8a7889a816cf989e6d91054effe5.zip |
Initial debug fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3226 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers')
-rwxr-xr-x | nuttx/drivers/usbhost/usbhost_enumerate.c | 40 | ||||
-rw-r--r-- | nuttx/drivers/usbhost/usbhost_findclass.c | 11 | ||||
-rw-r--r-- | nuttx/drivers/usbhost/usbhost_registerclass.c | 3 | ||||
-rw-r--r-- | nuttx/drivers/usbhost/usbhost_storage.c | 4 |
4 files changed, 37 insertions, 21 deletions
diff --git a/nuttx/drivers/usbhost/usbhost_enumerate.c b/nuttx/drivers/usbhost/usbhost_enumerate.c index 16a5802f0..cb82b6b14 100755 --- a/nuttx/drivers/usbhost/usbhost_enumerate.c +++ b/nuttx/drivers/usbhost/usbhost_enumerate.c @@ -139,6 +139,8 @@ static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc, id->base = devdesc->class; id->subclass = devdesc->subclass; id->proto = devdesc->protocol; + uvdbg("class:%d subclass:%d protocol:%d\n", + id->base, id->subclass, id->proto); /* Check if we have enough of the structure to see the VID/PID */ @@ -148,6 +150,7 @@ static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc, id->vid = usbhost_getle16(devdesc->vendor); id->pid = usbhost_getle16(devdesc->product); + uvdbg("vid:%d pid:%d\n", id->vid, id->pid); } } @@ -163,38 +166,33 @@ static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc, * *******************************************************************************/ -static inline int usbhost_configdesc(const uint8_t *configdesc, int desclen, +static inline int usbhost_configdesc(const uint8_t *configdesc, int cfglen, struct usbhost_id_s *id) { struct usb_cfgdesc_s *cfgdesc; struct usb_ifdesc_s *ifdesc; int remaining; - DEBUGASSERT(configdesc != NULL && - desclen >= sizeof(struct usb_cfgdesc_s)); - + DEBUGASSERT(configdesc != NULL && cfglen >= USB_SIZEOF_CFGDESC); + /* Verify that we were passed a configuration descriptor */ cfgdesc = (struct usb_cfgdesc_s *)configdesc; + uvdbg("cfg len:%d total len:%d\n", cfgdesc->len, cfglen); + if (cfgdesc->type != USB_DESC_TYPE_CONFIG) { return -EINVAL; } - /* Get the total length of the configuration descriptor (little endian). - * It might be a good check to get the number of interfaces here too. - */ - - remaining = (int)usbhost_getle16(cfgdesc->totallen); - /* Skip to the next entry descriptor */ configdesc += cfgdesc->len; - remaining -= cfgdesc->len; + remaining = cfglen - cfgdesc->len; /* Loop where there are more dscriptors to examine */ - memset(&id, 0, sizeof(FAR struct usb_desc_s)); + memset(id, 0, sizeof(FAR struct usb_desc_s)); while (remaining >= sizeof(struct usb_desc_s)) { /* What is the next descriptor? Is it an interface descriptor? */ @@ -212,6 +210,8 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int desclen, id->base = ifdesc->class; id->subclass = ifdesc->subclass; id->proto = ifdesc->protocol; + uvdbg("class:%d subclass:%d protocol:%d\n", + id->base, id->subclass, id->proto); return OK; } @@ -319,8 +319,8 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, struct usb_ctrlreq_s *ctrlreq; struct usbhost_id_s id; size_t maxlen; - unsigned int len; - uint16_t maxpacketsize; + unsigned int cfglen; + uint8_t maxpacketsize; uint8_t *buffer; int ret; @@ -370,6 +370,9 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, /* Extract the max packetsize for endpoint 0 */ + maxpacketsize = devdesc->mxpacketsize; + uvdbg("maxpacksetsize: %d\n", maxpacketsize); + DRVR_EP0CONFIGURE(drvr, 0, maxpacketsize); /* Get class identification information from the device descriptor. Most @@ -426,7 +429,8 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, /* Extract the full size of the configuration data */ - len = ((struct usb_cfgdesc_s *)buffer)->len; + cfglen = (unsigned int)usbhost_getle16(((struct usb_cfgdesc_s *)buffer)->totallen); + uvdbg("sizeof config data: %d\n", cfglen); /* Get all of the configuration descriptor data, index == 0 */ @@ -434,7 +438,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, ctrlreq->req = USB_REQ_GETDESCRIPTOR; usbhost_putle16(ctrlreq->value, (USB_DESC_TYPE_CONFIG << 8)); usbhost_putle16(ctrlreq->index, 0); - usbhost_putle16(ctrlreq->len, len); + usbhost_putle16(ctrlreq->len, cfglen); ret = DRVR_CTRLIN(drvr, ctrlreq, buffer); if (ret != OK) @@ -477,7 +481,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, * case of multiple interface descriptors. */ - ret = usbhost_configdesc(buffer, len, &id); + ret = usbhost_configdesc(buffer, cfglen, &id); if (ret != OK) { udbg("ERROR: usbhost_configdesc returned %d\n", ret); @@ -494,7 +498,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, * will begin configuring the device. */ - ret = usbhost_classbind(drvr, buffer, len, &id, class); + ret = usbhost_classbind(drvr, buffer, cfglen, &id, class); if (ret != OK) { udbg("ERROR: usbhost_classbind returned %d\n", ret); diff --git a/nuttx/drivers/usbhost/usbhost_findclass.c b/nuttx/drivers/usbhost/usbhost_findclass.c index 1b2a7edae..d4438d814 100644 --- a/nuttx/drivers/usbhost/usbhost_findclass.c +++ b/nuttx/drivers/usbhost/usbhost_findclass.c @@ -41,6 +41,7 @@ #include <sys/types.h> #include <stdbool.h> +#include <debug.h> #include <nuttx/usb/usb.h> #include <nuttx/usb/usbhost.h> @@ -86,6 +87,9 @@ static bool usbhost_idmatch(const struct usbhost_id_s *classid, const struct usbhost_id_s *devid) { + uvdbg("Compare to class:%d subclass:%d protocol:%d\n", + classid->base, classid->subclass, classid->proto); + /* The base class ID, subclass and protocol have to match up in any event */ if (devid->base == classid->base && @@ -151,6 +155,10 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id irqstate_t flags; int ndx; + DEBUGASSERT(id); + uvdbg("Looking for class:%d subclass:%d protocol:%d\n", + id->base, id->subclass, id->proto); + /* g_classregistry is a singly-linkedlist of class ID information added by * calls to usbhost_registerclass(). Since this list is accessed from USB * host controller interrupt handling logic, accesses to this list must be @@ -167,7 +175,8 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id * protocol, then try each. */ - for (ndx = 0; ndx < class->nids; ndx++) + uvdbg("Checking class:%p nids:%d\n", class, class->nids); + for (ndx = 0; ndx < class->nids; ndx++) { /* Did we find a matching ID? */ diff --git a/nuttx/drivers/usbhost/usbhost_registerclass.c b/nuttx/drivers/usbhost/usbhost_registerclass.c index 0c8d3b20d..76ef511af 100644 --- a/nuttx/drivers/usbhost/usbhost_registerclass.c +++ b/nuttx/drivers/usbhost/usbhost_registerclass.c @@ -41,6 +41,7 @@ #include <sys/types.h> #include <errno.h> +#include <debug.h> #include <arch/irq.h> #include <nuttx/usb/usbhost.h> @@ -95,6 +96,8 @@ int usbhost_registerclass(struct usbhost_registry_s *class) { irqstate_t flags; + uvdbg("Registering class:%p nids:%d\n", class, class->nids); + /* g_classregistry is a singly-linkedlist of class ID information added by * calls to usbhost_registerclass(). Since this list is accessed from USB * host controller interrupt handling logic, accesses to this list must be diff --git a/nuttx/drivers/usbhost/usbhost_storage.c b/nuttx/drivers/usbhost/usbhost_storage.c index cfe6af668..89b969b30 100644 --- a/nuttx/drivers/usbhost/usbhost_storage.c +++ b/nuttx/drivers/usbhost/usbhost_storage.c @@ -1343,7 +1343,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, case USB_DESC_TYPE_INTERFACE: { - DEBUGASSERT(remaining >= sizeof(struct usb_ifdesc_s)); + DEBUGASSERT(remaining >= USB_SIZEOF_IFDESC); if ((found & USBHOST_IFFOUND) != 0) { /* Oops.. more than one interface. We don't know what to do with this. */ @@ -1358,7 +1358,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, case USB_DESC_TYPE_ENDPOINT: { FAR struct usb_epdesc_s *epdesc = (FAR struct usb_epdesc_s *)configdesc; - DEBUGASSERT(remaining >= sizeof(struct usb_epdesc_s)); + DEBUGASSERT(remaining >= USB_SIZEOF_EPDESC); /* Check for a bulk endpoint. We only support the bulk-only * protocol so I suppose anything else should really be an error. |