Posts Tagged CP2101

CP2102 on DNS-323

In one of my personal projects, I needed to connect and use a USB to RS232 (Serial) converter on my D-Link DNS-323. Weird requirements, I know. Anyway… 😐
Plenty of these converters exist out there, but I choose to go for a CP2102:

Innocently, I first tried to compile the code source of this module which can be found on the following page:
http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx

After a few painful and unsuccessful tries, I decided to look around for the already-compiled module. 😉
While wondering why I didn’t think of that before, I used the instructions below to install the required modules on my NAS:

cd /mnt/HD_a2/ffp/lib/
mkdir modules
mkdir modules/2.6.12.6-arm1
cd modules/2.6.12.6-arm1
wget http://dev.skcserver.de/dns323/modules_v1.03/kernel/drivers/usb/serial/usbserial.ko
wget http://dev.skcserver.de/dns323/modules_v1.03/kernel/drivers/usb/serial/cp2101.ko
chmod 755 usbserial.ko
chmod 755 cp2101.ko

Once the modules are installed, the next step is to initialize them.
I wrote the following script for this purpose so you can execute it anytime you need it:

#!/bin/sh

insmod /ffp/lib/modules/2.6.12.6-arm1/usbserial.ko
insmod /ffp/lib/modules/2.6.12.6-arm1/cp2101.ko
mknod /dev/ttyUSB0 c 188 0
chmod 0666 /dev/ttyUSB0

At this point in time, you should have your module initialized on your D-Link DNS-323.
You can check the kernel ring buffer using the dmesg command to verify it loaded properly.
This is a snapshot of what I have in my kernel ring buffer after I ran the script above:

usbcore: registered new driver usbserial
drivers/usb/serial/usb-serial.c: USB Serial support registered for Generic
usbcore: registered new driver usbserial_generic
drivers/usb/serial/usb-serial.c: USB Serial Driver core v2.0
drivers/usb/serial/usb-serial.c: USB Serial support registered for CP2101
CP2101 1-1:1.0: CP2101 converter detected
usb 1-1: reset full speed USB device using ehci_platform and address 5
usb 1-1: CP2101 converter now attached to ttyUSB0
usbcore: registered new driver CP2101
drivers/usb/serial/cp2101.c: Silicon Labs CP2101/CP2102 RS232 serial adaptor driver v0.04

Finally, you can test the communication with your USB to RS232 converter by connecting a LED between the RXD and 3V outputs and running the following script:

#!/bin/sh

while [ true ]
do
echo "hello world!!!" > /dev/ttyUSB0
echo "sent"
sleep 1
done

If you see the LED blinking, it means you succeed! 😀

, , , , , , , , ,

3 Comments