LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 11-10-2020, 09:17 AM   #1
jtliu
LQ Newbie
 
Registered: Nov 2020
Posts: 3

Rep: Reputation: Disabled
Problem with CP210x kernel module


I have a Raspberry Pi 4 model B 4GB. I have installed Linux raspberrypi 5.4.72-v7l+ and everything works fine.

I try to use the cp210x.ko kernel module which come with the kernel to connect a temperature monitor device through a virtual Serial-over-USB port created by the cp210x driver.

The kernel modules, usbserial.ko and cp210x.ko come with the raspberrypi 5.4.72-v7l+ can be loaded without problem:

Code:
pi@raspberrypi:~ $ lsmod

Module                 Size     Used by
cmac                   16384  1
rfcomm                 49152  4
.......
cp210x                 24576  0                                   
usbserial              36864  1 cp210x
.......
And run the "dmesg" command and got the following (Everything seems OK):

Code:
pi@raspberrypi:~ $ dmesg | grep cp210x
........
[ 2.749477] usbcore: registered new interface driver usbserial_generic
[ 2.749553] usbserial: USB Serial support registered for generic
[ 2.754191] usbcore: registered new interface driver cp210x                                           
[ 2.754266] usbserial: USB Serial support registered for cp210x
........
But the problem is that I can not find a way to get the corresponding device file or node.

There is no device file created in the /dev/ directory after load the kernel module(a /dev/tty.SLAB_USBtoUART or similar device file should be created when I plug in the device into an USB port. And the device does not appear in the /proc/devices file).

I searched the internet, one suggestion is to use the following command to create a "new_id" file in the driver's directory with the vendor ID and product ID:

Code:
sudo sh -c 'echo 10c4 ea60 > /sys/bus/usb/drivers/cp210x/new_id'
But, when I run this commad, i got the flowing error:

Code:
sh: 1: cannot create /sys/bus/usb/drivers/cp210x/new_id: Permission denied
It seems that in the /sys/bus/usb/drivers/ directory, all folders are all 0 sized folders. How can one create a file in a 0 sized directory?

Code:
pi@raspberrypi:~ $ ls -l /sys/bus/usb/drivers/
total 0
drwxr-xr-x 2 root root 0 Nov 7 20:11 brcmfmac
drwxr-xr-x 2 root root 0 Nov 7 20:11 cp210x
drwxr-xr-x 2 root root 0 Nov 7 20:11 hub
drwxr-xr-x 2 root root 0 Nov 7 20:11 lan78xx
drwxr-xr-x 2 root root 0 Nov 7 20:11 r8152
drwxr-xr-x 2 root root 0 Nov 7 20:11 smsc95xx
drwxr-xr-x 2 root root 0 Nov 7 20:11 uas
drwxr-xr-x 2 root root 0 Nov 7 20:11 usb
drwxr-xr-x 2 root root 0 Nov 7 20:11 usbfs
drwxr-xr-x 2 root root 0 Nov 7 20:11 usbhid
drwxr-xr-x 2 root root 0 Nov 7 20:11 usbserial_generic
drwxr-xr-x 2 root root 0 Nov 7 20:11 usb-storage
Following is the contents of the /proc/devices file ( this device seems not in /proc/devices. If it appears here, the device major number can be used with the "mknod" command to create a device file in /dev/ directory ??):

Code:
pi@raspberrypi:~ $ cat /proc/devices
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  5 ttyprintk
  7 vcs
 10 misc
 13 input
 14 sound
 29 fb
 81 video4linux
 89 i2c
116 alsa
128 ptm
136 pts
153 spi
162 raw
180 usb
188 ttyUSB
189 usb_device
204 ttyAMA
216 rfcomm
226 drm
235 cec
236 media
237 rpivid-vp9mem
238 rpivid-h264mem
239 rpivid-intcmem
240 rpivid-hevcmem
241 uio
242 vcsm
243 vchiq
244 hidraw
245 rpmb
246 bcm2835-gpiomem
247 vcio
248 vc-mem
249 bsg
250 watchdog
251 BaseRemoteCtl
252 rtc
253 dma_heap
254 gpiochip

Block devices:
And the /proc/moudles file contains some strange things:

Code:
more /proc/modules
......
wire 40960 1 w1_gpio, Live 0x00000000
cn 16384 1 wire, Live 0x00000000
uio_pdrv_genirq 16384 0 - Live 0x00000000
uio 20480 1 uio_pdrv_genirq, Live 0x00000000
cp210x 24576 0 - Live 0x00000000
usbserial 36864 1 cp210x, Live 0x00000000
i2c_dev 20480 0 - Live 0x00000000
ip_tables 28672 0 - Live 0x00000000
x_tables 32768 1 ip_tables, Live 0x00000000
ipv6 466944 26 [permanent], Live 0x00000000
......

Can anyone help to figure out where might be the problem?
Any helps are highly appreciated!
 
Old 11-12-2020, 10:03 AM   #2
jtliu
LQ Newbie
 
Registered: Nov 2020
Posts: 3

Original Poster
Rep: Reputation: Disabled
Now, it is working.
The thing is that the CP210x.c driver use USB vendor-ID and product-ID to probe the presence of the device.
The USB vendor-ID and product-ID of the device, if it is not already in the "struct usb_device_id it_table[]" table, must be added into the table in the code to let that happen.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux-kernel-modul cp210x Adurna17 Linux - Kernel 2 08-06-2015 07:15 AM
CP210x module didn't receive data beparas Linux - Networking 0 04-13-2012 08:14 AM
CP210x USB to UART Bridge VCP Linux Drivers(SILICON Labs) perfectpol7 Linux - Hardware 4 09-02-2010 11:59 AM
compile cp210x-3.0.0 Driver error in Ubuntu 9.10! cigogo Programming 0 12-12-2009 11:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 04:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration