diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index 3a946b5d295..87fe3c11d32 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -8,7 +8,7 @@
NuttX RTOS
- Last Updated: December 3, 2010
+ Last Updated: December 4, 2010
|
@@ -2011,6 +2011,10 @@ nuttx-5.15 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
or data. This is typical, for example, in "9-bit" displays where the 9th bit
is the CMD/DATA bit. The cmddata method provides selection of command or data.
* drivers/lcd/p14201.c -- Now used the cmddata() method of the SPI interface.
+ * arch/arm/src/lpc17xx/lpc17_usbdev.c -- LPC17xx USB driver is not functional.
+ * drivers/usbdev/usbserial.c and usbstorage.c -- All USB class drivers need
+ to call DEV_CONNECT() when they are ready to be enumerated. That is,
+ (1) initially when bound to the USB driver, and (2) after a USB reset.
pascal-2.1 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
diff --git a/TODO b/TODO
index 6bed0714dee..256a2509f86 100644
--- a/TODO
+++ b/TODO
@@ -716,13 +716,8 @@ o ARM/LPC17xx (arch/arm/src/lpc17xx/)
Status: Open
Priority: High
- Description: a) USB DMA not fully implemented. Partial logic is in place but it is
- fragmentary and bogus. (Leveraged from the lpc214x)
- b) Possible errors in USB device driver reported "I suspect there's a few
- issues in the lpc214x USB driver -- in particular it doesn't stall both
- in/out endpoints for unsupported setup requests and it doesn't call
- CLASS_DISCONNCET on a USB reset -- I don't have any access to that hardware
- so can't pursue it really."
+ Description: USB DMA not fully implemented. Partial logic is in place but it is
+ fragmentary and bogus. (Leveraged from the lpc214x)
Status: Open
Priority: Low
diff --git a/arch/arm/src/lpc17xx/lpc17_usbdev.c b/arch/arm/src/lpc17xx/lpc17_usbdev.c
index a3bf002a729..8633751ad1a 100755
--- a/arch/arm/src/lpc17xx/lpc17_usbdev.c
+++ b/arch/arm/src/lpc17xx/lpc17_usbdev.c
@@ -1487,6 +1487,15 @@ static void lpc17_usbreset(struct lpc17_usbdev_s *priv)
lpc17_putreg(USB_SLOW_INT|USB_DEVSTATUS_INT|USB_FAST_INT|USB_FRAME_INT|USB_ERROR_INT,
LPC17_USBDEV_INTEN);
+
+ /* Tell the class driver that we are disconnected. The class
+ * driver should then accept any new configurations.
+ */
+
+ if (priv->driver)
+ {
+ CLASS_DISCONNECT(priv->driver, &priv->usbdev);
+ }
}
/*******************************************************************************
@@ -1895,8 +1904,8 @@ static inline void lpc17_ep0setup(struct lpc17_usbdev_s *priv)
if (priv->stalled)
{
usbtrace(TRACE_DEVERROR(LPC17_TRACEERR_EP0SETUPSTALLED), priv->ep0state);
- lpc17_epstall(&ep0->ep, false);
- lpc17_epstall(&ep0->ep, false);
+ lpc17_epstall(&priv->eplist[LPC17_EP0_IN].ep, false);
+ lpc17_epstall(&priv->eplist[LPC17_EP0_OUT].ep, false);
}
}
@@ -1957,9 +1966,8 @@ static inline void lpc17_ep0dataoutinterrupt(struct lpc17_usbdev_s *priv)
if (priv->stalled)
{
usbtrace(TRACE_DEVERROR(LPC17_TRACEERR_EP0OUTSTALLED), priv->ep0state);
- ep0 = &priv->eplist[LPC17_EP0_OUT];
- lpc17_epstall(&ep0->ep, false);
- lpc17_epstall(&ep0->ep, false);
+ lpc17_epstall(&priv->eplist[LPC17_EP0_IN].ep, false);
+ lpc17_epstall(&priv->eplist[LPC17_EP0_OUT].ep, false);
}
return;
}
@@ -2024,9 +2032,8 @@ static inline void lpc17_ep0dataininterrupt(struct lpc17_usbdev_s *priv)
if (priv->stalled)
{
usbtrace(TRACE_DEVERROR(LPC17_TRACEERR_EP0INSTALLED), priv->ep0state);
- ep0 = &priv->eplist[LPC17_EP0_IN];
- lpc17_epstall(&ep0->ep, false);
- lpc17_epstall(&ep0->ep, false);
+ lpc17_epstall(&priv->eplist[LPC17_EP0_IN].ep, false);
+ lpc17_epstall(&priv->eplist[LPC17_EP0_OUT].ep, false);
}
}
diff --git a/arch/arm/src/lpc313x/lpc313x_usbdev.c b/arch/arm/src/lpc313x/lpc313x_usbdev.c
index 323648fa945..c3faecee1bc 100755
--- a/arch/arm/src/lpc313x/lpc313x_usbdev.c
+++ b/arch/arm/src/lpc313x/lpc313x_usbdev.c
@@ -2604,7 +2604,11 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
/* FIXME: nothing seems to call DEV_CONNECT(), but we need to set
* the RS bit to enable the controller. It kind of makes sense
- * to do this after the class has bound to us... */
+ * to do this after the class has bound to us...
+ * GEN: This bug is really in the class driver. It should make the
+ * soft connect when it is ready to be enumerated. I have added
+ * that logic to the class drivers but left this logic here.
+ */
lpc313x_pullup(&g_usbdev.usbdev, true);
}
diff --git a/configs/olimex-lpc1766stk/usbstorage/defconfig b/configs/olimex-lpc1766stk/usbstorage/defconfig
index 0b0e93dda92..6cdd31aeb9f 100755
--- a/configs/olimex-lpc1766stk/usbstorage/defconfig
+++ b/configs/olimex-lpc1766stk/usbstorage/defconfig
@@ -853,6 +853,12 @@ CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n
CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n
CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n
+CONFIG_EXAMPLES_USBSTRG_TRACEINIT=n
+CONFIG_EXAMPLES_USBSTRG_TRACECLASS=n
+CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS=n
+CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER=n
+CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS=n
+
#
# Stack and heap information
#
diff --git a/drivers/usbdev/usbdev_scsi.c b/drivers/usbdev/usbdev_scsi.c
index 7fd9f200fb2..0f1d9dd38be 100644
--- a/drivers/usbdev/usbdev_scsi.c
+++ b/drivers/usbdev/usbdev_scsi.c
@@ -60,6 +60,7 @@
#include
#include
#include
+#include
#include
#include
#include
diff --git a/drivers/usbdev/usbdev_serial.c b/drivers/usbdev/usbdev_serial.c
index 4e7b3890833..a5a25178d7a 100644
--- a/drivers/usbdev/usbdev_serial.c
+++ b/drivers/usbdev/usbdev_serial.c
@@ -1392,6 +1392,10 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver
#ifdef CONFIG_USBDEV_SELFPOWERED
DEV_SETSELFPOWERED(dev);
#endif
+
+ /* And pull-up the data line for the soft connect function */
+
+ DEV_CONNECT(dev);
return OK;
errout:
@@ -1830,6 +1834,12 @@ static void usbclass_disconnect(FAR struct usbdev_s *dev)
priv->serdev.xmit.head = 0;
priv->serdev.xmit.tail = 0;
irqrestore(flags);
+
+ /* Perform the soft connect function so that we will we can be
+ * re-enumerated.
+ */
+
+ DEV_CONNECT(dev);
}
/****************************************************************************
diff --git a/drivers/usbdev/usbdev_storage.c b/drivers/usbdev/usbdev_storage.c
index d714339ebc6..7aa0a388fc4 100644
--- a/drivers/usbdev/usbdev_storage.c
+++ b/drivers/usbdev/usbdev_storage.c
@@ -601,6 +601,10 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_
#ifdef CONFIG_USBDEV_SELFPOWERED
DEV_SETSELFPOWERED(dev);
#endif
+
+ /* And pull-up the data line for the soft connect function */
+
+ DEV_CONNECT(dev);
return OK;
errout:
@@ -1045,6 +1049,12 @@ static void usbstrg_disconnect(FAR struct usbdev_s *dev)
priv->theventset |= USBSTRG_EVENT_DISCONNECT;
pthread_cond_signal(&priv->cond);
irqrestore(flags);
+
+ /* Perform the soft connect function so that we will we can be
+ * re-enumerated.
+ */
+
+ DEV_CONNECT(dev);
}
/****************************************************************************
diff --git a/drivers/usbdev/usbdev_storage.h b/drivers/usbdev/usbdev_storage.h
index 03c07f734d8..75317dcbc4b 100644
--- a/drivers/usbdev/usbdev_storage.h
+++ b/drivers/usbdev/usbdev_storage.h
@@ -367,21 +367,21 @@ struct usbstrg_lun_s
struct usbstrg_dev_s
{
- FAR struct usbdev_s *usbdev; /* usbdev driver pointer (Non-null if registered) */
+ FAR struct usbdev_s *usbdev; /* usbdev driver pointer (Non-null if registered) */
/* Worker thread interface */
- pthread_t thread; /* The worker thread */
- pthread_mutex_t mutex; /* Mutually exclusive access to resources*/
- pthread_cond_t cond; /* Used to signal worker thread */
+ pthread_t thread; /* The worker thread */
+ pthread_mutex_t mutex; /* Mutually exclusive access to resources*/
+ pthread_cond_t cond; /* Used to signal worker thread */
volatile uint8_t thstate; /* State of the worker thread */
volatile uint16_t theventset; /* Set of pending events signaled to worker thread */
volatile uint8_t thvalue; /* Value passed with the event (must persist) */
/* Storage class configuration and state */
- uint8_t nluns:4; /* Number of LUNs */
- uint8_t config; /* Configuration number */
+ uint8_t nluns:4; /* Number of LUNs */
+ uint8_t config; /* Configuration number */
/* Endpoints */
@@ -394,29 +394,29 @@ struct usbstrg_dev_s
struct usbstrg_lun_s *lun; /* Currently selected LUN */
struct usbstrg_lun_s *luntab; /* Allocated table of all LUNs */
uint8_t cdb[USBSTRG_MAXCDBLEN]; /* Command data (cdb[]) from CBW */
- uint8_t phaseerror:1; /* Need to send phase sensing status */
- uint8_t shortpacket:1; /* Host transmission stopped unexpectedly */
- uint8_t cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */
- uint8_t cdblen; /* Length of cdb[] from CBW */
- uint8_t cbwlun; /* LUN from the CBW */
- uint16_t nsectbytes; /* Bytes buffered in iobuffer[] */
- uint16_t nreqbytes; /* Bytes buffered in head write requests */
- uint16_t iosize; /* Size of iobuffer[] */
- uint32_t cbwlen; /* Length of data from CBW */
- uint32_t cbwtag; /* Tag from the CBW */
+ uint8_t phaseerror:1; /* Need to send phase sensing status */
+ uint8_t shortpacket:1; /* Host transmission stopped unexpectedly */
+ uint8_t cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */
+ uint8_t cdblen; /* Length of cdb[] from CBW */
+ uint8_t cbwlun; /* LUN from the CBW */
+ uint16_t nsectbytes; /* Bytes buffered in iobuffer[] */
+ uint16_t nreqbytes; /* Bytes buffered in head write requests */
+ uint16_t iosize; /* Size of iobuffer[] */
+ uint32_t cbwlen; /* Length of data from CBW */
+ uint32_t cbwtag; /* Tag from the CBW */
union
{
- uint32_t xfrlen; /* Read/Write: Sectors remaining to be transferred */
- uint32_t alloclen; /* Other device-to-host: Host allocation length */
+ uint32_t xfrlen; /* Read/Write: Sectors remaining to be transferred */
+ uint32_t alloclen; /* Other device-to-host: Host allocation length */
} u;
- uint32_t sector; /* Current sector (relative to lun->startsector) */
- uint32_t residue; /* Untransferred amount reported in the CSW */
- uint8_t *iobuffer; /* Buffer for data transfers */
+ uint32_t sector; /* Current sector (relative to lun->startsector) */
+ uint32_t residue; /* Untransferred amount reported in the CSW */
+ uint8_t *iobuffer; /* Buffer for data transfers */
/* Write request list */
- struct sq_queue_s wrreqlist; /* List of empty write request containers */
- struct sq_queue_s rdreqlist; /* List of filled read request containers */
+ struct sq_queue_s wrreqlist; /* List of empty write request containers */
+ struct sq_queue_s rdreqlist; /* List of filled read request containers */
/* Pre-allocated write request containers. The write requests will
* be linked in a free list (wrreqlist), and used to send requests to
diff --git a/include/nuttx/usbdev.h b/include/nuttx/usbdev.h
index ed7f0c49628..1f425aa2e44 100644
--- a/include/nuttx/usbdev.h
+++ b/include/nuttx/usbdev.h
@@ -135,7 +135,10 @@
#define DEV_CLRSELFPOWERED(dev) (dev)->ops->selfpowered(dev, false)
-/* Software-controlled connect to USB host */
+/* Software-controlled connect to USB host. All USB class drivers need to call
+ * DEV_CONNECT() when they are ready to be enumerated. That is, (1) initially when
+ * bound to the USB driver, and (2) after a USB reset.
+ */
#define DEV_CONNECT(dev) (dev)->ops->pullup ? (dev)->ops->pullup(dev,true) : -EOPNOTSUPP