summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-27 21:03:20 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-27 21:03:20 +0000
commita5849bb91060284dc6a7c3cd536ff2210662020e (patch)
treed7ad01379d373d9e56fab0aba06f7ee976fe0491
parentfce09ccb2453443e0083fa9a230d67727d139d8b (diff)
downloadnuttx-a5849bb91060284dc6a7c3cd536ff2210662020e.tar.gz
nuttx-a5849bb91060284dc6a7c3cd536ff2210662020e.tar.bz2
nuttx-a5849bb91060284dc6a7c3cd536ff2210662020e.zip
Most USB Composite device debug
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4344 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--apps/examples/README.txt2
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html17
-rw-r--r--nuttx/configs/README.txt15
-rwxr-xr-xnuttx/configs/stm3210e-eval/composite/defconfig15
-rw-r--r--nuttx/drivers/usbdev/cdcacm.h10
-rw-r--r--nuttx/drivers/usbdev/composite.c33
-rw-r--r--nuttx/drivers/usbdev/composite.h31
-rw-r--r--nuttx/drivers/usbdev/composite_descriptors.c2
-rw-r--r--nuttx/drivers/usbdev/usbmsc.h4
9 files changed, 108 insertions, 21 deletions
diff --git a/apps/examples/README.txt b/apps/examples/README.txt
index d9f30f191..3dc8bdfb2 100644
--- a/apps/examples/README.txt
+++ b/apps/examples/README.txt
@@ -125,6 +125,7 @@ examples/composite
CONFIG_CDCACM=y - USB CDC/ACM serial device support
CONFIG_CDCACM_COMPOSITE=y - USB CDC/ACM serial composite device support
CONFIG_CDCACM_IFNOBASE=0 - CDC/ACM interfaces start with number 0
+ CONFIG_CDCACM_STRBASE=4 - Base of string numbers (not really needed)
CONFIG_CDCACM_EPINTIN=1 - Endpoint numbers must be unique
CONFIG_CDCACM_EPBULKIN=2
CONFIG_CDCACM_EPBULKOUT=3
@@ -132,6 +133,7 @@ examples/composite
CONFIG_USBMSC - USB mass storage device support
CONFIG_USBMSC_COMPOSITE - USB mass storage composite device support
CONFIG_USBMSC_IFNOBASE=2 - USB mass storage interfaces start with number 2
+ CONFIG_USBMSC_STRBASE=4 - Base of string numbers (needed)
CONFIG_USBMSC_EPBULKOUT=4 - Endpoint numbers must be unique
CONFIG_USBMSC_EPBULKIN=5
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index 9c1dd07c9..9b0c60ce7 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -4941,6 +4941,15 @@ build
correct value for this offset is zero.
</li>
<li>
+ <code>CONFIG_CDCACM_STRBASE</code>:
+ If the CDC driver is part of a composite device, then this may need to
+ be defined to offset the CDC/ACM string numbers so that they are
+ unique and contiguous. When used with the Mass Storage driver, the
+ correct value for this offset is four (this value actuallly only needs
+ to be defined if names are provided for the Notification interface,
+ <code>CONFIG_CDCACM_NOTIFSTR</code>, or the data interface, <code>CONFIG_CDCACM_DATAIFSTR</code>).
+ </li>
+ <li>
<code>CONFIG_CDCACM_EP0MAXPACKET</code>: Endpoint 0 max packet size. Default 64.
</li>
<li>
@@ -5011,6 +5020,14 @@ build
interfaces that will precede it).
</li>
<li>
+ <code>CONFIG_USBMSC_STRBASE</code>:
+ If the CDC driver is part of a composite device, then this may need to
+ be defined to offset the mass storage string numbers so that they are
+ unique and contiguous. When used with the CDC/ACM driver, the
+ correct value for this offset is four (or perhaps 5 or 6, depending
+ on if <code>CONFIG_CDCACM_NOTIFSTR</code> or <code>CONFIG_CDCACM_DATAIFSTR</code> are defined).
+ </li>
+ <li>
<code>CONFIG_USBMSC_EP0MAXPACKET</code>:
Max packet size for endpoint 0
</li>
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index f53cb2a82..8154c22c2 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -1010,6 +1010,13 @@ defconfig -- This is a configuration file similar to the Linux
be defined to offset the CDC/ACM interface numbers so that they are
unique and contiguous. When used with the Mass Storage driver, the
correct value for this offset is zero.
+ CONFIG_CDCACM_STRBASE
+ If the CDC driver is part of a composite device, then this may need to
+ be defined to offset the CDC/ACM string numbers so that they are
+ unique and contiguous. When used with the Mass Storage driver, the
+ correct value for this offset is four (this value actuallly only needs
+ to be defined if names are provided for the Notification interface,
+ CONFIG_CDCACM_NOTIFSTR, or the data interface, CONFIG_CDCACM_DATAIFSTR).
CONFIG_CDCACM_EP0MAXPACKET
Endpoint 0 max packet size. Default 64.
CONFIG_CDCACM_EPINTIN
@@ -1067,7 +1074,13 @@ defconfig -- This is a configuration file similar to the Linux
be defined to offset the mass storage interface number so that it is
unique and contiguous. When used with the CDC/ACM driver, the
correct value for this offset is two (because of the two CDC/ACM
- interfaces that will precede it).
+ interfaces that will precede it).
+ CONFIG_USBMSC_STRBASE
+ If the CDC driver is part of a composite device, then this may need to
+ be defined to offset the mass storage string numbers so that they are
+ unique and contiguous. When used with the CDC/ACM driver, the
+ correct value for this offset is four (or perhaps 5 or 6, depending
+ on if CONFIG_CDCACM_NOTIFSTR or CONFIG_CDCACM_DATAIFSTR are defined).
CONFIG_USBMSC_EP0MAXPACKET
Max packet size for endpoint 0
CONFIG_USBMSCEPBULKOUT and CONFIG_USBMSC_EPBULKIN
diff --git a/nuttx/configs/stm3210e-eval/composite/defconfig b/nuttx/configs/stm3210e-eval/composite/defconfig
index 46fa44814..7fb3b3ae8 100755
--- a/nuttx/configs/stm3210e-eval/composite/defconfig
+++ b/nuttx/configs/stm3210e-eval/composite/defconfig
@@ -719,6 +719,12 @@ CONFIG_PL2303_TXBUFSIZE=512
# unique and contiguous. When used with the CDC/ACM driver, the
# correct value for this offset is two (because of the two CDC/ACM
# interfaces that will precede it).
+# CONFIG_USBMSC_STRBASE
+# If the CDC driver is part of a composite device, then this may need to
+# be defined to offset the mass storage string numbers so that they are
+# unique and contiguous. When used with the CDC/ACM driver, the
+# correct value for this offset is four (or perhaps 5 or 6, depending
+# on if CONFIG_CDCACM_NOTIFSTR or CONFIG_CDCACM_DATAIFSTR are defined).
# CONFIG_USBMSC_EP0MAXPACKET
# Max packet size for endpoint 0
# CONFIG_USBMSC_EPBULKOUT and CONFIG_USBMSC_EPBULKIN
@@ -740,6 +746,7 @@ CONFIG_PL2303_TXBUFSIZE=512
CONFIG_USBMSC=y
CONFIG_USBMSC_COMPOSITE=y
CONFIG_USBMSC_IFNOBASE=2
+CONFIG_USBMSC_STRBASE=4
CONFIG_USBMSC_EP0MAXPACKET=64
CONFIG_USBMSC_EPBULKOUT=4
CONFIG_USBMSC_EPBULKIN=5
@@ -767,6 +774,13 @@ CONFIG_USBMSC_REMOVABLE=y
# be defined to offset the CDC/ACM interface numbers so that they are
# unique and contiguous. When used with the Mass Storage driver, the
# correct value for this offset is zero.
+# CONFIG_CDCACM_STRBASE
+# If the CDC driver is part of a composite device, then this may need to
+# be defined to offset the CDC/ACM string numbers so that they are
+# unique and contiguous. When used with the Mass Storage driver, the
+# correct value for this offset is four (this value actuallly only needs
+# to be defined if names are provided for the Notification interface,
+# CONFIG_CDCACM_NOTIFSTR, or the data interface, CONFIG_CDCACM_DATAIFSTR).
# CONFIG_CDCACM_EP0MAXPACKET
# Endpoint 0 max packet size. Default 64
# CONFIG_CDCACM_EPINTIN
@@ -814,6 +828,7 @@ CONFIG_USBMSC_REMOVABLE=y
CONFIG_CDCACM=y
CONFIG_CDCACM_COMPOSITE=y
CONFIG_CDCACM_IFNOBASE=0
+CONFIG_CDCACM_STRBASE=4
#CONFIG_CDCACM_EP0MAXPACKET
CONFIG_CDCACM_EPINTIN=1
#CONFIG_CDCACM_EPINTIN_FSSIZE
diff --git a/nuttx/drivers/usbdev/cdcacm.h b/nuttx/drivers/usbdev/cdcacm.h
index a107fd060..ab9cff92a 100644
--- a/nuttx/drivers/usbdev/cdcacm.h
+++ b/nuttx/drivers/usbdev/cdcacm.h
@@ -140,16 +140,19 @@
# define CDCACM_SERIALSTRID (3)
# define CDCACM_CONFIGSTRID (4)
+# define CDCACM_LASTBASESTRID (4)
# undef CONFIG_CDCACM_STRBASE
-# define CONFIG_CDCACM_STRBASE (4)
+# define CONFIG_CDCACM_STRBASE (0)
+#else
+# define CDCACM_LASTBASESTRID CONFIG_CDCACM_STRBASE
#endif
/* These string IDs only exist if a user-defined string is provided */
#ifdef CONFIG_CDCACM_NOTIFSTR
-# define CDCACM_NOTIFSTRID (CONFIG_CDCACM_STRBASE+1)
+# define CDCACM_NOTIFSTRID (CDCACM_LASTBASESTRID+1)
#else
-# define CDCACM_NOTIFSTRID CONFIG_CDCACM_STRBASE
+# define CDCACM_NOTIFSTRID CDCACM_LASTBASESTRID
#endif
#ifdef CONFIG_CDCACM_DATAIFSTR
@@ -159,6 +162,7 @@
#endif
#define CDCACM_LASTSTRID CDCACM_DATAIFSTRID
+#define CDCACM_NSTRIDS (CDCACM_LASTSTRID - CONFIG_CDCACM_STRBASE)
/* Configuration descriptor size */
diff --git a/nuttx/drivers/usbdev/composite.c b/nuttx/drivers/usbdev/composite.c
index 1c56f79a8..bfd5a0201 100644
--- a/nuttx/drivers/usbdev/composite.c
+++ b/nuttx/drivers/usbdev/composite.c
@@ -470,7 +470,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
case USB_DESC_TYPE_CONFIG:
{
#ifdef CONFIG_USBDEV_DUALSPEED
- ret = composite_mkcfgdesc(ctrlreq->buf, dev->speed, ctrl->value[1]);
+ ret = composite_mkcfgdesc(ctrlreq->buf, dev->speed,
+ ctrl->value[1]);
#else
ret = composite_mkcfgdesc(ctrlreq->buf);
#endif
@@ -479,9 +480,23 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
case USB_DESC_TYPE_STRING:
{
- /* index == language code. */
-
- ret = composite_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf);
+ /* value == string index. Zero is the language ID. */
+
+ uint8_t strid = ctrl->value[0];
+ FAR struct usb_strdesc_s *buf = (FAR struct usb_strdesc_s *)ctrlreq->buf;
+
+ if (strid <= COMPOSITE_NSTRIDS)
+ {
+ ret = composite_mkstrdesc(strid, buf);
+ }
+ else if (strid < DEV1_STRIDBASE + DEV1_NSTRIDS)
+ {
+ ret = DEV1_MKSTRDESC(strid, buf);
+ }
+ else if (strid < DEV2_STRIDBASE + DEV2_NSTRIDS)
+ {
+ ret = DEV2_MKSTRDESC(strid, buf);
+ }
}
break;
@@ -530,7 +545,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
if (ctrl->type == USB_REQ_RECIPIENT_INTERFACE &&
priv->config == COMPOSITE_CONFIGID)
{
- dispatched = (composite_classsetup(priv, dev, ctrl) >= 0);
+ ret = composite_classsetup(priv, dev, ctrl);
+ dispatched = true;
}
}
break;
@@ -540,7 +556,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
if (ctrl->type == (USB_DIR_IN|USB_REQ_RECIPIENT_INTERFACE) &&
priv->config == COMPOSITE_CONFIGIDNONE)
{
- dispatched = (composite_classsetup(priv, dev, ctrl) >= 0);
+ ret = composite_classsetup(priv, dev, ctrl);
+ dispatched = true;
}
}
break;
@@ -565,7 +582,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
recipient = ctrl->type & USB_REQ_RECIPIENT_MASK;
if (recipient == USB_REQ_RECIPIENT_INTERFACE || recipient == USB_REQ_RECIPIENT_ENDPOINT)
{
- dispatched = (composite_classsetup(priv, dev, ctrl) >= 0);
+ ret = composite_classsetup(priv, dev, ctrl);
+ dispatched = true;
}
}
@@ -592,6 +610,7 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
composite_ep0incomplete(dev->ep0, ctrlreq);
}
}
+
return ret;
}
diff --git a/nuttx/drivers/usbdev/composite.h b/nuttx/drivers/usbdev/composite.h
index aaddfad34..0c022427c 100644
--- a/nuttx/drivers/usbdev/composite.h
+++ b/nuttx/drivers/usbdev/composite.h
@@ -118,26 +118,28 @@
#if defined(CONFIG_CDCACM_COMPOSITE)
# define DEV1_IS_CDCACM 1
# define DEV1_MKCFGDESC cdcacm_mkcfgdesc
+# define DEV1_MKSTRDESC cdcacm_mkstrdesc
# define DEV1_CLASSOBJECT board_cdcclassobject
# define DEV1_UNINITIALIZE board_cdcuninitialize
# define DEV1_NCONFIGS CDCACM_NCONFIGS
# define DEV1_CONFIGID CDCACM_CONFIGID
# define DEV1_FIRSTINTERFACE CONFIG_CDCACM_IFNOBASE
# define DEV1_NINTERFACES CDCACM_NINTERFACES
-# define DEV1_FIRSTSTRID CONFIG_CDCACM_STRBASE
-# define DEV1_NSTRIDS (CDCACM_LASTSTRID-CONFIG_CDCACM_STRBASE)
+# define DEV1_STRIDBASE CONFIG_CDCACM_STRBASE
+# define DEV1_NSTRIDS CDCACM_NSTRIDS
# define DEV1_CFGDESCSIZE SIZEOF_CDCACM_CFGDESC
#elif defined(CONFIG_CDCACM_COMPOSITE)
# define DEV1_IS_USBMSC 1
# define DEV1_MKCFGDESC usbmsc_mkcfgdesc
+# define DEV1_MKSTRDESC usbmsc_mkstrdesc
# define DEV1_CLASSOBJECT board_mscclassobject
# define DEV1_UNINITIALIZE board_mscuninitialize
# define DEV1_NCONFIGS USBMSC_NCONFIGS
# define DEV1_CONFIGID USBMSC_CONFIGID
# define DEV1_FIRSTINTERFACE CONFIG_USBMSC_IFNOBASE
# define DEV1_NINTERFACES USBMSC_NINTERFACES
-# define DEV1_FIRSTSTRID CONFIG_USBMSC_IFNOBASE
-# define DEV1_NSTRIDS (USBMSC_LASTSTRID-CONFIG_USBMSC_STRBASE)
+# define DEV1_STRIDBASE CONFIG_USBMSC_IFNOBASE
+# define DEV1_NSTRIDS USBMSC_NSTRIDS
# define DEV1_CFGDESCSIZE SIZEOF_USBMSC_CFGDESC
#else
# error "No members of the composite defined"
@@ -150,26 +152,28 @@
#if defined(CONFIG_CDCACM_COMPOSITE) && !defined(DEV1_IS_CDCACM)
# define DEV2_IS_CDCACM 1
# define DEV2_MKCFGDESC cdcacm_mkcfgdesc
+# define DEV2_MKSTRDESC cdcacm_mkstrdesc
# define DEV2_CLASSOBJECT board_cdcclassobject
# define DEV2_UNINITIALIZE board_cdcuninitialize
# define DEV2_NCONFIGS CDCACM_NCONFIGS
# define DEV2_CONFIGID CDCACM_CONFIGID
# define DEV2_FIRSTINTERFACE CONFIG_CDCACM_IFNOBASE
# define DEV2_NINTERFACES CDCACM_NINTERFACES
-# define DEV2_FIRSTSTRID CONFIG_CDCACM_STRBASE
-# define DEV2_NSTRIDS (CDCACM_LASTSTRID-CONFIG_CDCACM_STRBASE)
+# define DEV2_STRIDBASE CONFIG_CDCACM_STRBASE
+# define DEV2_NSTRIDS CDCACM_NSTRIDS
# define DEV2_CFGDESCSIZE SIZEOF_CDCACM_CFGDESC
#elif defined(CONFIG_CDCACM_COMPOSITE) && !defined(DEV1_IS_USBMSC)
# define DEV2_IS_USBMSC 1
# define DEV2_MKCFGDESC usbmsc_mkcfgdesc
+# define DEV2_MKSTRDESC usbmsc_mkstrdesc
# define DEV2_UNINITIALIZE board_mscuninitialize
# define DEV2_CLASSOBJECT board_mscclassobject
# define DEV2_NCONFIGS USBMSC_NCONFIGS
# define DEV2_CONFIGID USBMSC_CONFIGID
# define DEV2_FIRSTINTERFACE CONFIG_USBMSC_IFNOBASE
# define DEV2_NINTERFACES USBMSC_NINTERFACES
-# define DEV2_FIRSTSTRID CONFIG_CDCACM_STRBASE
-# define DEV2_NSTRIDS (USBMSC_LASTSTRID-CONFIG_USBMSC_STRBASE)
+# define DEV2_STRIDBASE CONFIG_USBMSC_STRBASE
+# define DEV2_NSTRIDS USBMSC_NSTRIDS
# define DEV2_CFGDESCSIZE SIZEOF_USBMSC_CFGDESC
#else
# error "Insufficient members of the composite defined"
@@ -232,6 +236,17 @@
#define COMPOSITE_PRODUCTSTRID (2)
#define COMPOSITE_SERIALSTRID (3)
#define COMPOSITE_CONFIGSTRID (4)
+#define COMPOSITE_NSTRIDS (4)
+
+/* Verify string configuration */
+
+#if COMPOSITE_NSTRIDS != DEV1_STRIDBASE
+# warning "The DEV1 string base should be COMPOSITE_NSTRIDS"
+#endif
+
+#if (DEV1_STRIDBASE + DEV1_NSTRIDS) != DEV2_STRIDBASE
+# warning "String IDs are not contiguous"
+#endif
/* Everpresent MIN/MAX macros ***********************************************/
diff --git a/nuttx/drivers/usbdev/composite_descriptors.c b/nuttx/drivers/usbdev/composite_descriptors.c
index 5c9e586d8..3fbc5d7d3 100644
--- a/nuttx/drivers/usbdev/composite_descriptors.c
+++ b/nuttx/drivers/usbdev/composite_descriptors.c
@@ -183,7 +183,7 @@ int composite_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
return 4;
}
- case COMPOSITE_MANUFACTURERSTRID:
+ case COMPOSITE_MANUFACTURERSTRID:
str = g_compvendorstr;
break;
diff --git a/nuttx/drivers/usbdev/usbmsc.h b/nuttx/drivers/usbdev/usbmsc.h
index a656872a2..4400a3392 100644
--- a/nuttx/drivers/usbdev/usbmsc.h
+++ b/nuttx/drivers/usbdev/usbmsc.h
@@ -298,11 +298,13 @@
# define USBMSC_INTERFACESTRID USBMSC_CONFIGSTRID
# undef CONFIG_USBMSC_STRBASE
-# define CONFIG_USBMSC_STRBASE (4)
+# define CONFIG_USBMSC_STRBASE (0)
#else
# define USBMSC_INTERFACESTRID (CONFIG_USBMSC_STRBASE+1)
#endif
+
#define USBMSC_LASTSTRID USBMSC_INTERFACESTRID
+#define USBMSC_NSTRIDS (USBMSC_LASTSTRID - CONFIG_USBMSC_STRBASE)
#define USBMSC_NCONFIGS (1) /* Number of configurations supported */