This is the project page for the Linux driver for CP2101, CP2102 and CP2103 based USB to serial bridges. The driver discussed here is 100% open source, and is licensed under the terms of the GNU General Public License.

Project History

The CP210x driver is now distributed with 2.6 series kernels, and should be compiled and part of the default installation for most modern Linux distributions. In the majority of cases, no further action is required to use CP210x based devices.

The project began in December 2004, after purchasing a CP2101 based USB to RS232 converter cable. The cable was advertised as having Linux support however this was far from the case since the only Linux driver that was provided was in binary form, and for a specific Red Hat Linux kernel. For some reason the manufacturers try to keep the protocol used for configuring this device secret. Well, it’s out in the open now!

After writing the first version of the open source driver, I received feedback from numerous companies, some with names we all recognise. This feedback has only reinforced my belief that using an open standard protocol for this type of device would have made it more appealing to many product designers. With no data-sheets available, this driver had to be produced by tediously analysing the protocol used by the windows drivers.

Supported Features

The open source driver supports the majority of the features of the CP210x devices, and should in theory be compatible with the basic functionality of the CP2103. FIXME THIS NEEDS TO BE UPDATED

  • 600 to 921600 Baud
  • 5, 6, 7 or 8 Data bits
  • None/Odd/Even/Mark/Space Parity modes
  • 1, 1.5 or 2 Stop bits
  • Optional RTS-CTS Flow control
  • TIOCMGET/TIOCMSET ioctls enable flow control lines to be fully programmed
  • Break on/off support

CP210x Driver Download

The CP210x driver is distributed with the Linux kernels newer than 2.6.12. Almost all Linux distributions have this as part of the default installation. CP210x based devices will be detected automatically, the kernel module will automatically load and the device node /dev/ttyUSBx will be created. The Linux kernel can be downloaded in source form from https://www.kernel.org. Using cp210x devices with older kernels, 2.4 series and 2.6 <2.6.12, is possible by applying the appropriate patch to the kernel source. Note: The driver version numbers for the 2.4 and 2.6 development branches are not related because the two drivers are maintained separately.

2.4.x Kernel Patches

2.6.x Kernel Patches

For newer kernels, the driver is distributed with the source.

Troubleshooting

First, ensure that the driver has loaded, run dmesg There should be a line saying something similar to “cp210x.c: Silicon Labs CP2101/CP2102/CP2103 RS232 serial adaptor driver…” Second, check that the driver has bound to the device, after making a connection to the USB, the following message should be present in dmesg, “CP210x converter detected”, and “CP210x converter now attached to…” If these stages have not happened, ensure the driver is loaded, check the output of lsmod. In order to detect your device, the product and vendor IDs must be recognised. CP210x based devices have vendor programmable device IDs and it is likely that if your device is not being detected, the device IDs are unknown. The device IDs can be obtained by running lsusb and appear as hex numbers in the format vendor:product. Verify that they are present in the list towards the top of drivers/usb/serial/cp210x.c which can be found in the kernel source directory. If modifications to the driver’s device ID list are required, the module must be recompiled, and reinstalled.

After these initial stages, further problems are rare. However if you are still getting trouble, reload the module with the debug option “rmmod cp210x; modprobe cp210x debug”. A diagnostic report can then be manually generated by capturing the output of lsusb -v, and the output of dmesg. Reports showing what happens when the driver is loaded, when the device inserted, and when an attempt is made to use the device are often very useful. Also include the command line parameters/output of the program that was having trouble communicating.

From experience, the most common cause of problems is with misidentification of a device. In other words, the device is not really a CP210x, despite having vendor and product IDs which would make it appear so.

Driver Development

The first version of this driver to go into the Linux kernel entered the bitkeeper patches for 2.6.12-rc1 and was at driver version 0.03. It had very basic support for opening the device, setting the baud rate. Since the flow control lines were not touched, the early version of the driver left them in the wrong state. This caused many problems in devices where the flow control lines were connected. Unfortunately, the cable which was being used for development only had the TX/RX signals connected, so it was impossible for development in this area by myself alone. Karl Hiramoto, a developer with access to a CP2101 evaluation kit, provided excellent information by testing development versions of the driver, and was able to establish the correct bit mappings of all of the flow control lines. Munir Nassar provided further useful informationin the form of USB packet logs, and very kindly sent me a cable which had all of the flow control lines connected. This enabled support for hardware flow control to be implemented in version 0.04 of the driver which was subsequently incorporated into kernel version 2.6.12-rc5 The driver continues to be updated with new device IDs as they emerge. The CP210x driver code which resides in the latest version of the Linux kernel now bears little resemblance to my early releases of the driver due to incremental development and support by the open source community.

Credits

Making this driver wouldn’t have been possible without the community support. I wish to thank Karl Hiramoto, Munir Nassar and Greg Kroah for their help, and also to to Andreas Weinberger for the original 2.4 back-port.

Support

The Linux USB mailing lists are where the active discussion, development and support take place. Searching through the archives can often provide suggestions and potential solutions to most problems. The the people on the users’ list are friendly and very helpful if you need to discuss a problem. Failing this, my contact details are at the bottom of the page, although I can not guarantee a timely response.