summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/ChangeLog8
-rw-r--r--nuttx/arch/arm/src/sama5/sam_udphs.c4
-rw-r--r--nuttx/configs/sama5d3x-ek/README.txt1
-rw-r--r--nuttx/drivers/usbdev/Kconfig6
-rw-r--r--nuttx/drivers/usbdev/cdcacm.c27
-rw-r--r--nuttx/drivers/usbdev/pl2303.c31
-rw-r--r--nuttx/include/nuttx/usb/cdcacm.h6
7 files changed, 68 insertions, 15 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index fc7312045..c49f6bea8 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5495,3 +5495,11 @@
de Assis. This is still very much a work in progress (2013-9-3).
* configs/*/usbmsc: Renamed from config/*/usbstorage to match the
change in naming in apps/examples submitted by CCTSAO (2013-9-5).
+ * drivers/usbdev.c and pl2303.c: Don't use max packetsize assigned to
+ the endpoint when allocating request buffers; The default value of
+ the endpoint max packetsize may be incorrect because the endpoint
+ has not yet been configured. Verified on CDC/ACM. Corresponding
+ changes made to pl2303, but untested (2013-9-5).
+ * arch/arm/src/sama5/sam_udphs.c: The high-speed device side driver
+ is now functional (although more testing is always needed) (2013-9-5).
+
diff --git a/nuttx/arch/arm/src/sama5/sam_udphs.c b/nuttx/arch/arm/src/sama5/sam_udphs.c
index 641bda596..f02fcea8d 100644
--- a/nuttx/arch/arm/src/sama5/sam_udphs.c
+++ b/nuttx/arch/arm/src/sama5/sam_udphs.c
@@ -3505,7 +3505,7 @@ static void sam_ep_freereq(struct usbdev_ep_s *ep, struct usbdev_req_s *req)
}
/****************************************************************************
- * Name: sam_ep_submit
+ * Name: sam_ep_allocbuffer
*
* Description:
* This is the allocbuffer() method of the USB device endpoint structure.
@@ -3522,7 +3522,7 @@ static void *sam_ep_allocbuffer(struct usbdev_ep_s *ep, uint16_t nbytes)
#endif
/****************************************************************************
- * Name: sam_ep_submit
+ * Name: sam_ep_freebuffer
*
* Description:
* This is the freebuffer() method of the USB device endpoint structure.
diff --git a/nuttx/configs/sama5d3x-ek/README.txt b/nuttx/configs/sama5d3x-ek/README.txt
index ce7993e0d..803a78774 100644
--- a/nuttx/configs/sama5d3x-ek/README.txt
+++ b/nuttx/configs/sama5d3x-ek/README.txt
@@ -1240,6 +1240,7 @@ Configurations
Device Drivers -> USB Device Driver Support
CONFIG_CDCACM=y : Enable the CDC/ACM device
+ CONFIG_CDCACM_BULKIN_REQLEN=768 : Default too small for high-speed
The following setting enables an example that can can be used to
control the CDC/ACM device. It will add two new NSH commands:
diff --git a/nuttx/drivers/usbdev/Kconfig b/nuttx/drivers/usbdev/Kconfig
index ca1d175b2..56e45ccf8 100644
--- a/nuttx/drivers/usbdev/Kconfig
+++ b/nuttx/drivers/usbdev/Kconfig
@@ -210,7 +210,8 @@ config PL2303_NRDREQS
config PL2303_BULKIN_REQLEN
int "Size of one write request buffer"
- default 96
+ default 768 if USBDEV_DUALSPEED
+ default 96 if !USBDEV_DUALSPEED
---help---
Ideally, the BULKOUT request size should *not* be the same size as
the maxpacket size. That is because IN transfers of exactly the
@@ -376,7 +377,8 @@ config CDCACM_NRDREQS
config CDCACM_BULKIN_REQLEN
int "Size of one write request buffer"
- default 96
+ default 768 if USBDEV_DUALSPEED
+ default 96 if !USBDEV_DUALSPEED
---help---
Ideally, the BULKOUT request size should *not* be the same size as
the maxpacket size. That is because IN transfers of exactly the
diff --git a/nuttx/drivers/usbdev/cdcacm.c b/nuttx/drivers/usbdev/cdcacm.c
index 81319e30c..5920a6beb 100644
--- a/nuttx/drivers/usbdev/cdcacm.c
+++ b/nuttx/drivers/usbdev/cdcacm.c
@@ -1006,9 +1006,13 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
priv->epbulkout->priv = priv;
- /* Pre-allocate read requests */
+ /* Pre-allocate read requests. The buffer size is one full packet. */
- reqlen = priv->epbulkout->maxpacket;
+#ifdef CONFIG_USBDEV_DUALSPEED
+ reqlen = CONFIG_CDCACM_EPBULKOUT_HSSIZE;
+#else
+ reqlen = CONFIG_CDCACM_EPBULKOUT_FSSIZE;
+#endif
for (i = 0; i < CONFIG_CDCACM_NRDREQS; i++)
{
@@ -1025,9 +1029,24 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver,
reqcontainer->req->callback = cdcacm_rdcomplete;
}
- /* Pre-allocate write request containers and put in a free list */
+ /* Pre-allocate write request containers and put in a free list.
+ * The buffer size should be larger than a full packet. Otherwise,
+ * we will send a bogus null packet at the end of each packet.
+ *
+ * Pick the larger of the max packet size and the configured request
+ * size.
+ */
- reqlen = MAX(CONFIG_CDCACM_BULKIN_REQLEN, priv->epbulkin->maxpacket);
+#ifdef CONFIG_USBDEV_DUALSPEED
+ reqlen = CONFIG_CDCACM_EPBULKIN_HSSIZE;
+#else
+ reqlen = CONFIG_CDCACM_EPBULKIN_FSSIZE;
+#endif
+
+ if (CONFIG_CDCACM_BULKIN_REQLEN > reqlen)
+ {
+ reqlen = CONFIG_CDCACM_BULKIN_REQLEN;
+ }
for (i = 0; i < CONFIG_CDCACM_NWRREQS; i++)
{
diff --git a/nuttx/drivers/usbdev/pl2303.c b/nuttx/drivers/usbdev/pl2303.c
index 71918ca41..4f75275e2 100644
--- a/nuttx/drivers/usbdev/pl2303.c
+++ b/nuttx/drivers/usbdev/pl2303.c
@@ -472,7 +472,7 @@ static const struct usb_epdesc_s g_epbulkoutdesc =
USB_DESC_TYPE_ENDPOINT, /* type */
PL2303_EPOUTBULK_ADDR, /* addr */
PL2303_EPOUTBULK_ATTR, /* attr */
- { LSBYTE(64), MSBYTE(64) }, /* maxpacket -- might change to 512*/
+ { LSBYTE(64), MSBYTE(64) }, /* maxpacket -- might change to 512 */
0 /* interval */
};
@@ -482,7 +482,7 @@ static const struct usb_epdesc_s g_epbulkindesc =
USB_DESC_TYPE_ENDPOINT, /* type */
PL2303_EPINBULK_ADDR, /* addr */
PL2303_EPINBULK_ATTR, /* attr */
- { LSBYTE(64), MSBYTE(64) }, /* maxpacket -- might change to 512*/
+ { LSBYTE(64), MSBYTE(64) }, /* maxpacket -- might change to 512 */
0 /* interval */
};
@@ -1381,9 +1381,13 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
}
priv->epbulkout->priv = priv;
- /* Pre-allocate read requests */
+ /* Pre-allocate read requests. The buffer size is one full packet. */
- reqlen = priv->epbulkout->maxpacket;
+#ifdef CONFIG_USBDEV_DUALSPEED
+ reqlen = 512;
+#else
+ reqlen = 64;
+#endif
for (i = 0; i < CONFIG_PL2303_NRDREQS; i++)
{
@@ -1400,9 +1404,24 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver,
reqcontainer->req->callback = usbclass_rdcomplete;
}
- /* Pre-allocate write request containers and put in a free list */
+ /* Pre-allocate write request containers and put in a free list.
+ * The buffer size should be larger than a full packet. Otherwise,
+ * we will send a bogus null packet at the end of each packet.
+ *
+ * Pick the larger of the max packet size and the configured request
+ * size.
+ */
+
+#ifdef CONFIG_USBDEV_DUALSPEED
+ reqlen = 512;
+#else
+ reqlen = 64;
+#endif
- reqlen = max(CONFIG_PL2303_BULKIN_REQLEN, priv->epbulkin->maxpacket);
+ if (CONFIG_PL2303_BULKIN_REQLEN > reqlen)
+ {
+ reqlen = CONFIG_CDCACM_BULKIN_REQLEN;
+ }
for (i = 0; i < CONFIG_PL2303_NWRREQS; i++)
{
diff --git a/nuttx/include/nuttx/usb/cdcacm.h b/nuttx/include/nuttx/usb/cdcacm.h
index 4e331b569..165d38fb3 100644
--- a/nuttx/include/nuttx/usb/cdcacm.h
+++ b/nuttx/include/nuttx/usb/cdcacm.h
@@ -140,7 +140,11 @@
#endif
#ifndef CONFIG_CDCACM_BULKIN_REQLEN
-# define CONFIG_CDCACM_BULKIN_REQLEN 96
+# ifdef CONFIG_USBDEV_DUALSPEED
+# define CONFIG_CDCACM_BULKIN_REQLEN (3 * CONFIG_CDCACM_EPBULKIN_FSSIZE / 2)
+# else
+# define CONFIG_CDCACM_BULKIN_REQLEN (3 * CONFIG_CDCACM_EPBULKIN_FSSIZE / 2)
+# endif
#endif
/* Endpoint number and size (in bytes) of the CDC host-to-device (OUT) data