Use of UART with MC1321x under Linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use of UART with MC1321x under Linux

5,096 Views
CecchiSandrone
Contributor II
Hi all,

In my project I need to use data received from Zigbee sensors and read them via USB UART. The problem is that I must do it under Linux...is this possible or special drivers are needed?
Thanks in advance
Labels (1)
0 Kudos
19 Replies

2,112 Views
snickels
Contributor I
You might also want to check the permission on ttyUSB0.
0 Kudos

2,112 Views
CecchiSandrone
Contributor II
Ok guys...

I sent those commands:

Code:
>> sudo stty -F /dev/ttyUSB0 speed 38400 cs8 speed 38400 baud; line = 0;min = 60; time = 1;ignbrk -brkint -icrnl -imaxbel-opost -onlcr-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke>> sudo stty -F /dev/ttyUSB0 -aspeed 38400 baud; rows 0; columns 0; line = 0;intr = ^C; quit = ^\; erase = ^—; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;werase = ^W; lnext = ^V; flush = ^O; min = 60; time = 1;-parenb -parodd cs8 hupcl -cstopb cread clocal -crtsctsignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke

 I tried to read with:

Code:
>> sudo cat /dev/ttyUSB0

 Nothing...I can't see nothing! Can you post me your stty settings so I can compare? Thanks





Message Edited by Cecchi Sandrone on 2008-02-23 10:19 AM
0 Kudos

2,112 Views
lineage
Contributor III
I'm seeing the same problem. Tried it on a couple of systems with different kernels (2.6.15 and 2.6.20). Forcing usbserial to pick up the port does let me connect but I see no text. Connecting with hyperterminal on a vmware XP system seems to see the text OK though - so its just a driver issue.

If someone has this working on linux, can they let me know exactly how they did it and with what kernel version.
For clarity, this is connecting direct to the USB port on the MC1321x, not the RS232 port. The USB interface is a Digianswer device with USB id 0x08fd:0x000a.

Thanks



Message Edited by lineage on 2008-04-01 01:06 AM
0 Kudos

2,112 Views
lineage
Contributor III
Ok, I have a solution, just needed to work out that the chip is an SILABS  CP2101.

They have a great website with drivers for linux and instructions.

    http://www.silabs.com/products/microcontroller/downloads.asp

Follow the CP210x VCP Drivers link and grab the VCP Driver kit for linux. It built fine for me. Only thing you need to do is add the usb ID to the cp2101.c file. Something like:

    { USB_DEVICE(0x08fd, 0x000a) }, /* Digianswer A/S */

will do the trick. Build it all against your kernel, and insmod it (it needs usbserial loaded too).

Having set the baud rate to 19200 at both ends, so far it seems to be working.

Enjoy.

0 Kudos

2,112 Views
CecchiSandrone
Contributor II
Nice to hear this! Please can you explain better (which unix commands) how build the .rpm contained into the archive for my ubuntu 7.10?
Thanks for help!
0 Kudos

2,112 Views
CecchiSandrone
Contributor II
Ok I have loaded module with: sudo modprobe cp2101
Now when I attach ZigBee I receive this with dmesg:
Code:
[14131.060000] usbcore: registered new interface driver usbserial[14131.060000] /build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/usb-serial.c: USB Serial support registered for generic[14131.060000] usbcore: registered new interface driver usbserial_generic[14131.060000] /build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/usb-serial.c: USB Serial Driver core[14131.072000] /build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/usb-serial.c: USB Serial support registered for cp2101[14131.072000] usbcore: registered new interface driver cp2101[14131.072000] /build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/cp2101.c: Silicon Labs CP2101/CP2102 RS232 serial adaptor driver v0.07[14145.384000] usb 6-2: new full speed USB device using uhci_hcd and address 2[14145.552000] usb 6-2: configuration #1 chosen from 1 choice

 How can I "mount" it to ttyUSB0? Thanks and sorry for stupid questions....


0 Kudos

2,112 Views
lineage
Contributor III
I assume you applied the patch to the cp2101.c file?

I get:
usb 1-3.1: new full speed USB device using ehci_hcd and address 48
drivers/usb/serial/usb-serial.c: USB Serial support registered for cp2101
CP2101 1-3.1:1.0: cp2101 converter detected
usb 1-3.1: reset full speed USB device using ehci_hcd and address 48
usb 1-3.1: cp2101 converter now attached to ttyUSB0
usbcore: registered new driver CP2101
cp2103-0.11.0/cp2101.c: Silicon Labs CP2101/CP2102/CP2103 RS232 serial adaptor driver v0.11

I'd suggest you unplug the device. Unload all the serial modules (including usbserial). install the cp2101.ko file properly then plug the board back in. It should autodetect and load up OK.

To install the module you will need:

    chmod +x installmod
    make -f Makefile.go install

0 Kudos

2,112 Views
CecchiSandrone
Contributor II
Ok it seems to work now...I have to check speed because I can't understand characters. Freescale manual reports 38400 (I use it in windows and Hyperterminal). Do you use 19200?
0 Kudos

2,112 Views
CecchiSandrone
Contributor II
I don't know how can I express my gratitude...it works! Thanks for help lineage!
0 Kudos

2,112 Views
lineage
Contributor III
Yep, mine is 19200
0 Kudos

2,112 Views
lineage
Contributor III
There are probably a lot of ways to do this. The easiest is to look around the office, find a local linux kernel/driver person and offer them gadgets/beer/chocolate etc. If you can't do that, the way I did it was;

You get linux_VCP_v26_driver_src.zip
Un-zip it to get cp2103-0.11.0-1.src.rpm and SIL00205_RNF_20060902.doc
The doc (ms-word) tells you how to build the driver. Read that first.
You need kernel headers etc installed. I'm on fedora and can build without full source. On ubuntu I don't know what the rules are so you need to check on the ubuntu forums.

rpm2cpio cp2103-0.11.0-1.src.rpm | cpio -i
tar -xvzf cp2103-0.11.0.tar.gz
cd cp2103-0.11.0
patch -p0 < path-to/digianswer.patch
./configure
make -f Makefile.go modules   

That will make you the cp2101.ko module.
The patch file is attached. You need it for kernels newer than about 2.6.18. The header structure in the kernel has changed slightly.

Make sure you check the output of the configure - make sure if has all the params set correctly.


0 Kudos

2,112 Views
CecchiSandrone
Contributor II
Hey thanks for now lineage...I'll try it tomorrow because it's very late here.
0 Kudos

2,112 Views
CecchiSandrone
Contributor II
Hi lineage,
when calling: make -f Makefile.go modules
I receive:

make -C /lib/modules/2.6.22-14-generic/build SUBDIRS="`pwd`" modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.22-14-generic'
/home/cecchi/Scrivania/cp2103-0.11.0/Makefile:7: /home/cecchi/Scrivania/cp2103-0.11.0/Makefile.config: Too many open files
/home/cecchi/Scrivania/cp2103-0.11.0/Makefile:8: /home/cecchi/Scrivania/cp2103-0.11.0/Makefile: Too many open files
Building modules, stage 2.
MODPOST 0 modules
make[1]: Leaving directory `/usr/src/linux-headers-2.6.22-14-generic'

and no .ko file is created. What error is it?
0 Kudos

2,112 Views
lineage
Contributor III
Did you check the output of configure?
Should look something like this:

Kernel version        : 2.6.22-14
Module extension      : .ko
Kernel directory      : /lib/modules/2.6.22-14/build
Include directory     : /lib/modules/2.6.22-14/build/include

check the real version with
uname -r

   
0 Kudos

2,112 Views
CecchiSandrone
Contributor II
Code:
cecchi@cecchi-notebook:~/Downloads/cp2103-0.11.0$ uname -r2.6.22-14-genericcecchi@cecchi-notebook:~/Downloads/cp2103-0.11.0$ ./configureKernel version        : ..Module extension      : Kernel directory      : /lib/modules/2.6.22-14-generic/buildInclude directory     : /lib/modules/2.6.22-14-generic/build/includeModule install prefix :

 This is the output...
0 Kudos

2,112 Views
lineage
Contributor III
configure -help
Usage: configure [option ...]

Where 'option' can be one of the following:
  -kinc <path>                 Kernel header files.
  -kpath <path>                Kernel sources.
  -kver <version>              Kernel version.
  -p <install folder>          Prefix for installing the kernel module.

so try

configure -kver 2.6.22-14-generic

rtm :smileywink:


0 Kudos

2,112 Views
topbin
Contributor I
Hi,

Linux kernel comes with drivers for USB to serial adapters. My Ubuntu 7.10 loads automatically the right drivers for my converter, so you shouldn't worry to much about this part. Try just not to buy a really "exotic" adapter, although I don't really know if there are some exotic adapters.

Cheers
0 Kudos

2,112 Views
CecchiSandrone
Contributor II
Hi topbin,

I've connected my MC1321-SRB via USB to Linux (Ubuntu 7.10). I've given these commands:
Code:
>> dmesgusb 4-2: new full speed USB device using uhci_hcd and address 2usb 4-2: configuration #1 chosen from 1 choice>> lsusbBus 004 Device 003: ID 08fd:000a Digianswer A/S >> sudo modprobe usbserial vendor=0x08fd product=0x000a>> dmesgusbserial_generic 4-2:1.0: generic converter detectedusb 4-2: generic converter now attached to ttyUSB0usbcore: registered new interface driver usbserial_generic/build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/serial/usb-serial.c: USB Serial Driver core

 Now if I try to read UART data with serial watchers (GtkTerm, Cutecom) I can't see anything...what's wrong?


0 Kudos

2,112 Views
topbin
Contributor I
Did you check that your UART is set up the same for ttyUSB0 and your terminal it is linked to ? Check the baudrate and other parameters with the command:
stty -F /dev/ttyUSB0

Cheers
0 Kudos