summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-09-27 17:05:24 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-09-27 17:05:24 +0000
commite12519aa64b4c4b4e6271f66368da57913540db1 (patch)
treef633b94ac4242bb63caef367632d8dacb495f89c
parent93b4f58e8d5ea52729e37982e0fe743581ba22cd (diff)
downloadnuttx-e12519aa64b4c4b4e6271f66368da57913540db1.tar.gz
nuttx-e12519aa64b4c4b4e6271f66368da57913540db1.tar.bz2
nuttx-e12519aa64b4c4b4e6271f66368da57913540db1.zip
CDC ACM fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3981 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--apps/examples/README.txt16
-rw-r--r--apps/examples/usbterm/usbterm_main.c16
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html7
-rw-r--r--nuttx/configs/README.txt9
-rwxr-xr-xnuttx/configs/stm3210e-eval/usbserial/defconfig9
-rw-r--r--nuttx/drivers/usbdev/cdc_serial.c17
-rw-r--r--nuttx/include/nuttx/usb/cdc_serial.h19
7 files changed, 73 insertions, 20 deletions
diff --git a/apps/examples/README.txt b/apps/examples/README.txt
index 0327d6b61..ca58fbb27 100644
--- a/apps/examples/README.txt
+++ b/apps/examples/README.txt
@@ -975,6 +975,22 @@ examples/usbterm
the local target serial console are received and forwarded to the
remote host via USB serial.
+ Usage:
+ - Build the example and load into the target FLASH
+ - Connect on terminal to the target RS-232 connect and configure
+ for 115200 8N1. For example, suppose this Tera Term on a Windows
+ box.
+ - Power up the target board
+ - Connect the USB to a Linux box. Use the Linux dmesg command to
+ assure that the connect was successful. The USB CDC ACM device
+ should appear as /dev/ttyACM0
+ - On the Linux box, open minicom with tty=/dev/ttyACM0.
+ Configure minicom so that (1) local characters are echoed and (2)
+ so that no CR is required.
+ - Now what you type on the target Tera Term window should echo on
+ the Linux minicom window and, conversely, what you type on the
+ minicom winow should be echo in the target Tera Term window.
+
Configuration options:
CONFIG_EXAMPLES_UBSTERM_BUILTIN - Build the usbterm example as an NSH
diff --git a/apps/examples/usbterm/usbterm_main.c b/apps/examples/usbterm/usbterm_main.c
index 3cac73c5c..00161d0d2 100644
--- a/apps/examples/usbterm/usbterm_main.c
+++ b/apps/examples/usbterm/usbterm_main.c
@@ -134,9 +134,13 @@ FAR void *usbterm_listener(FAR void *parameter)
if (fgets(g_usbterm.inbuffer, CONFIG_EXAMPLES_USBTERM_BUFLEN, g_usbterm.instream))
{
- /* Send the line of input via USB */
+ /* Echo the line on the local stdout */
+
+ fputs(g_usbterm.inbuffer, stdout);
+
+ /* Display the prompt string on stdout */
- fputs(g_usbterm.outbuffer, stdout);
+ fputs("usbterm> ", stdout);
fflush(stdout);
}
@@ -235,14 +239,14 @@ int MAIN_NAME(int argc, char *argv[])
dumptrace();
}
- while (g_usbterm.outstream < 0);
+ while (g_usbterm.outstream == NULL);
/* Open the USB serial device for reading. Since we are already connected, this
* should not fail.
*/
g_usbterm.instream = fopen("/dev/ttyUSB0", "r");
- if (g_usbterm.instream < 0)
+ if (g_usbterm.instream == NULL)
{
message(MAIN_STRING "ERROR: Failed to open /dev/ttyUSB0 for reading: %d\n", errno);
goto errout_with_outstream;
@@ -286,6 +290,10 @@ int MAIN_NAME(int argc, char *argv[])
/* Send the line of input via USB */
fputs(g_usbterm.outbuffer, g_usbterm.outstream);
+
+ /* Display the prompt string on the remote USB serial connection */
+
+ fputs("usbterm> ", g_usbterm.outstream);
fflush(g_usbterm.outstream);
}
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index 9fda53426..20f6778ca 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -4816,10 +4816,13 @@ build
Default 4.
</li>
<li>
- <code>CONFIG_CDCSER_VENDORID</code> and <code>CONFIG_CDCSER_VENDORSTR</code>: The vendor ID code/string. Default 0x03eb and &quot;NuttX&quot;
+ <code>CONFIG_CDCSER_VENDORID</code> and <code>CONFIG_CDCSER_VENDORSTR</code>: The vendor ID code/string. Default 0x0525 and &quot;NuttX,&quot;
+ 0x0525 is the Netchip vendor and should not be used in any products.
+ This default VID was selected for compatibility with the Linux CDC ACM default VID.
</li>
<li>
- <code>CONFIG_CDCSER_PRODUCTID</code> and <code>CONFIG_CDCSER_PRODUCTSTR</code>: The product ID code/string. Default 0x204b and &quot;CDC/ACM Serial&quot;
+ <code>CONFIG_CDCSER_PRODUCTID</code> and <code>CONFIG_CDCSER_PRODUCTSTR</code>: The product ID code/string. Default 0xa4a7 and &quot;CDC/ACM Serial&quot;
+ 0xa4a7 was selected for compatibility with the Linux CDC ACM default PID.
</li>
<li>
<code>CONFIG_CDCSER_RXBUFSIZE</code> and <code>CONFIG_CDCSER_TXBUFSIZE</code>: Size of the serial receive/transmit buffers. Default 256.
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index 8958ee874..0ea753b6a 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -982,9 +982,14 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_CDCSER_NWRREQS includes write requests used for both the
interrupt and bulk IN endpoints. Default 4.
CONFIG_CDCSER_VENDORID and CONFIG_CDCSER_VENDORSTR
- The vendor ID code/string. Default 0x03eb and "NuttX"
+ The vendor ID code/string. Default 0x0525 and "NuttX"
+ 0x0525 is the Netchip vendor and should not be used in any
+ products. This default VID was selected for compatibility with
+ the Linux CDC ACM default VID.
CONFIG_CDCSER_PRODUCTID and CONFIG_CDCSER_PRODUCTSTR
- The product ID code/string. Default 0x204b and "CDC/ACM Serial"
+ The product ID code/string. Default 0xa4a7 and "CDC/ACM Serial"
+ 0xa4a7 was selected for compatibility with the Linux CDC ACM
+ default PID.
CONFIG_CDCSER_RXBUFSIZE and CONFIG_CDCSER_TXBUFSIZE
Size of the serial receive/transmit buffers. Default 256.
diff --git a/nuttx/configs/stm3210e-eval/usbserial/defconfig b/nuttx/configs/stm3210e-eval/usbserial/defconfig
index a23ef58f7..228c70b20 100755
--- a/nuttx/configs/stm3210e-eval/usbserial/defconfig
+++ b/nuttx/configs/stm3210e-eval/usbserial/defconfig
@@ -706,9 +706,14 @@ CONFIG_USBSER_TXBUFSIZE=512
# The number of write/read requests that can be in flight.
# Default 256.
# CONFIG_CDCSER_VENDORID and CONFIG_CDCSER_VENDORSTR
-# The vendor ID code/string. Default 0x03eb and "NuttX"
+# The vendor ID code/string. Default 0x0525 and "NuttX"
+# 0x0525 is the Netchip vendor and should not be used in any
+# products. This default VID was selected for compatibility with
+# the Linux CDC ACM default VID.
# CONFIG_CDCSER_PRODUCTID and CONFIG_CDCSER_PRODUCTSTR
-# The product ID code/string. Default 0x204b and "CDC/ACM Serial"
+# The product ID code/string. Default 0xara7 and "CDC/ACM Serial"
+# 0xa4a7 was selected for compatibility with the Linux CDC ACM
+# default PID.
# CONFIG_CDCSER_RXBUFSIZE and CONFIG_CDCSER_TXBUFSIZE
# Size of the serial receive/transmit buffers. Default 256.
#
diff --git a/nuttx/drivers/usbdev/cdc_serial.c b/nuttx/drivers/usbdev/cdc_serial.c
index bab4e3951..a4b549d27 100644
--- a/nuttx/drivers/usbdev/cdc_serial.c
+++ b/nuttx/drivers/usbdev/cdc_serial.c
@@ -338,13 +338,16 @@ static const struct usb_devdesc_s g_devdesc =
CDC_SUBCLASS_NONE, /* subclass */
CDC_PROTO_NONE, /* protocol */
CONFIG_CDCSER_EP0MAXPACKET, /* maxpacketsize */
- { LSBYTE(CONFIG_CDCSER_VENDORID), /* vendor */
+ {
+ LSBYTE(CONFIG_CDCSER_VENDORID), /* vendor */
MSBYTE(CONFIG_CDCSER_VENDORID)
},
- { LSBYTE(CONFIG_CDCSER_PRODUCTID), /* product */
+ {
+ LSBYTE(CONFIG_CDCSER_PRODUCTID), /* product */
MSBYTE(CONFIG_CDCSER_PRODUCTID)
},
- { LSBYTE(CDCSER_VERSIONNO), /* device */
+ {
+ LSBYTE(CDCSER_VERSIONNO), /* device */
MSBYTE(CDCSER_VERSIONNO)
},
CDCSER_MANUFACTURERSTRID, /* imfgr */
@@ -550,7 +553,10 @@ static const struct usb_qualdesc_s g_qualdesc =
{
USB_SIZEOF_QUALDESC, /* len */
USB_DESC_TYPE_DEVICEQUALIFIER, /* type */
- {LSBYTE(0x0200), MSBYTE(0x0200) }, /* USB */
+ { /* usb */
+ LSBYTE(0x0200),
+ MSBYTE(0x0200)
+ },
USB_CLASS_VENDOR_SPEC, /* class */
0, /* subclass */
0, /* protocol */
@@ -733,6 +739,9 @@ static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv,
uint16_t nexthead;
uint16_t nbytes = 0;
+ uvdbg("head=%d tail=%d nrdq=%d reqlen=%d\n",
+ priv->serdev.recv.head, priv->serdev.recv.tail, priv->nrdq, reqlen);
+
/* Get the next head index. During the time that RX interrupts are disabled, the
* the serial driver will be extracting data from the circular buffer and modifying
* recv.tail. During this time, we should avoid modifying recv.head; Instead we will
diff --git a/nuttx/include/nuttx/usb/cdc_serial.h b/nuttx/include/nuttx/usb/cdc_serial.h
index 92ae62b20..8a975666a 100644
--- a/nuttx/include/nuttx/usb/cdc_serial.h
+++ b/nuttx/include/nuttx/usb/cdc_serial.h
@@ -84,9 +84,14 @@
* CONFIG_CDCSER_NWRREQS includes write requests used for both the
* interrupt and bulk IN endpoints. Default 4.
* CONFIG_CDCSER_VENDORID and CONFIG_CDCSER_VENDORSTR
- * The vendor ID code/string. Default 0x03eb and "NuttX"
+ * The vendor ID code/string. Default 0x0525 and "NuttX"
+ * 0x0525 is the Netchip vendor and should not be used in any
+ * products. This default VID was selected for compatibility with
+ * the Linux CDC ACM default VID.
* CONFIG_CDCSER_PRODUCTID and CONFIG_CDCSER_PRODUCTSTR
- * The product ID code/string. Default 0x204b and "CDC/ACM Serial"
+ * The product ID code/string. Default 0xa4a7 and "CDC/ACM Serial"
+ * 0xa4a7 was selected for compatibility with the Linux CDC ACM
+ * default PID.
* CONFIG_CDCSER_RXBUFSIZE and CONFIG_CDCSER_TXBUFSIZE
* Size of the serial receive/transmit buffers. Default 256.
*/
@@ -171,14 +176,16 @@
# define CONFIG_CDCSER_TXBUFSIZE 256
#endif
-/* Vendor and product IDs and strings */
+/* Vendor and product IDs and strings. The default is the Linux Netchip
+ * CDC ACM VID and PID.
+ */
#ifndef CONFIG_CDCSER_VENDORID
-# define CONFIG_CDCSER_VENDORID 0x03eb
+# define CONFIG_CDCSER_VENDORID 0x0525
#endif
#ifndef CONFIG_CDCSER_PRODUCTID
-# define CONFIG_CDCSER_PRODUCTID 0x204b
+# define CONFIG_CDCSER_PRODUCTID 0xa4a7
#endif
#ifndef CONFIG_CDCSER_VENDORSTR
@@ -186,7 +193,7 @@
#endif
#ifndef CONFIG_CDCSER_PRODUCTSTR
-# define CONFIG_CDCSER_PRODUCTSTR "USBdev Serial"
+# define CONFIG_CDCSER_PRODUCTSTR "CDC ACM Serial"
#endif
#undef CONFIG_CDCSER_SERIALSTR