5

I am trying to build the CP210x driver for the 3.x.x kernel on ChrUbuntu.

Build instructions: Ubuntu:

  1. make ( your cp210x driver )
  2. cp cp210x.ko /lib/modules/<kernel-version>/kernel/drivers/usb/serial
  3. insmod /lib/modules/<kernel-version/kernel/drivers/usb/serial/usbserial.ko
  4. insmod cp210x.ko

I started with apt-get install build-essential then:

root@ChrUbuntu:~/Documents/# make
make -C /lib/modules/3.4.0/build M=/home/me/Documents/Linux_3.x.x_VCP_Driver_Source modules
make: *** /lib/modules/3.4.0/build: No such file or directory.  Stop.
make: *** [all] Error 2

But I am confused by the error because the location apparently exists:

root@ChrUbuntu:/lib/modules/3.4.0# ls -la
total 820
lrwxrwxrwx  1 root root    105 Feb  8 17:01 build -> /build/x86-mario/tmp/portage/sys-kernel/chromeos-kernel-3.4-r996/work/chromeos-kernel-3.4/build/x86-mario

How can I resolve this?

6
  • I downloaded the VCP files from SiLabs at silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx
    – MountainX
    May 12, 2013 at 20:52
  • I modified the Makefile and I got the CP210x.ko driver to build. Unfortunately, now I need to build the usbserial driver too and I can't find a download for that one.
    – MountainX
    May 12, 2013 at 20:53
  • This seems relevant, but I'm using ChrUbuntu, so I'm not sure what changes to make. ubuntuforums.org/showthread.php?t=1612392
    – MountainX
    May 12, 2013 at 20:56
  • I'm giving up; too many unknowns. ChrUbuntu is based on Ubuntu 12.04 but it uses kernel 3.4. I'm running into too many obstacles given that I have no experience with this.
    – MountainX
    May 12, 2013 at 21:10
  • @slm you said you intalled the kernel headers. Which version? ChrUbuntu uses a custom kernel, version 3.4.0. The Ubuntu repos don't have matching headers for that kernel, as far as I know.
    – MountainX
    May 12, 2013 at 22:04

3 Answers 3

10

Figured out the steps to compile this kernel module. The version on the website, silabs.com is apparently too old to be used with newer kernels (3.4+).

I was able to compile a newer version of the file, cp210x.c, that I found over on kernel.org for my particular version of the kernel, using the Makefile provided in the VCP Driver Source.

Building cp210x for your kernel version

baseline your kernel

First make note of your major & minor numbers for your kernel you have (i.e. 3.4, 3.5, etc.).

$ uname -r
3.5.0-19-generic

Incidentally I'm on Ubuntu 12.10:

$ lsb_release -r
Release:    12.10

Install the kernel headers & build tools for your kernel version:

sudo apt-get install linux-headers-$(uname -r) build-essential

Get the VCP bundle from silabs.com

Now make yourself a little work area for all this:

mkdir -p $HOME/cp210x && cd $HOME/cp210x

Download the VCP Driver Source:

wget  http://www.silabs.com/Support%20Documents/Software/Linux_3.x.x_VCP_Driver_Source.zip
unzip Linux_3.x.x_VCP_Driver_Source.zip
cd Linux_3.x.x_VCP_Driver_Source
mv cp210x.c cp210x.c_orig

Get kernel.org cp210x.c

Now download the appropriate version of cp210x.c for your kernel:

$ wget https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/drivers/usb/serial/cp210x.c?h=linux-3.5.y -O cp210x.c

NOTE: You can browse the different versions of the kernel here.

Compile

Now we compile using make:

$ make
make -C /lib/modules/3.5.0-19-generic/build M=/home/manny/cp210x/Linux_3.x.x_VCP_Driver_Source modules
make[1]: Entering directory `/usr/src/linux-headers-3.5.0-19-generic'
  CC [M]  /home/manny/cp210x/Linux_3.x.x_VCP_Driver_Source/cp210x.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/manny/cp210x/Linux_3.x.x_VCP_Driver_Source/cp210x.mod.o
  LD [M]  /home/manny/cp210x/Linux_3.x.x_VCP_Driver_Source/cp210x.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-19-generic'

Deploy

Now move any pre-existing cp210x.ko kernel out of the way:

sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/serial/cp210x.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/cp210x.ko.orig

Now copy the newly built kernel module, cp210x.ko in it's place:

sudo cp cp210x.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/cp210x.ko

Load

Now make sure the previous cp210x.ko kernel module wasn't loaded:

$ lsmod | grep cp210x
$

If it is, unload it:

sudo rmmod cp210x

Now let's load our new cp210x.ko module:

sudo modprobe cp210x

Test

Confirm that it loaded correctly:

$ lsmod |grep cp210x
cp210x                 21822  0 
usbserial              42355  1 cp210x

Also check dmesg for any issues:

$ dmesg | tail
...
...
[979772.614394] usbcore: registered new interface driver usbserial
[979772.614410] usbcore: registered new interface driver usbserial_generic
[979772.614456] USB Serial support registered for generic
[979772.614461] usbserial: USB Serial Driver core
[979772.614810] usbcore: registered new interface driver cp210x
[979772.614822] USB Serial support registered for cp210x

Compiling usbserial kernel module

The OP asked about how to accomplish compiling the usbserial.ko module as well, given it's needed by the applications in order to make use of the cp210x kernel module. Here are those instructions.

First make note of which kernel version you're using:

uname -r
3.5.0-19-generic

So we're using 3.5.0, next install the kernel source:

sudo apt-get install linux-source-3.5.0

Now let's make ourselves a work area:

mkdir -p $HOME/src && cd $HOME/src

Unpack the kernel source into our work area:

tar jxvf /usr/src/linux-source-3.5.0.tar.bz2

Now let's compile usbserial.ko:

$ cd linux-source-3.5.0/drivers/usb/serial
$ make -C /usr/src/linux-headers-`uname -r`  M=`pwd` modules
make: Entering directory `/usr/src/linux-headers-3.5.0-19-generic'
  CC [M]  /root/src/linux-source-3.5.0/drivers/usb/serial/usb-serial.o
  ...
  ...
  LD [M]  /root/src/linux-source-3.5.0/drivers/usb/serial/usbserial.o
  ...
  ...
  CC      /root/src/linux-source-3.5.0/drivers/usb/serial/usbserial.mod.o
  LD [M]  /root/src/linux-source-3.5.0/drivers/usb/serial/usbserial.ko
  ...
  ...
make: Leaving directory `/usr/src/linux-headers-3.5.0-19-generic'

Check that usbserial.ko was built:

ls -l |grep usbserial
-rw-r--r-- 1 root root  74822 May 15 09:20 usbserial.ko
-rw-r--r-- 1 root root   4120 May 15 09:20 usbserial.mod.c
-rw-r--r-- 1 root root   8840 May 15 09:20 usbserial.mod.o
-rw-r--r-- 1 root root  74724 May 15 09:20 usbserial.o

Now let's install it, load it, and test it:

# move old driver out of the way
$ mv /lib/modules/`uname -r`/kernel/drivers/usb/serial/usbserial.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/usbserial.ko.orig

# copy newly built one in
$ cp usbserial.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/.

# confirm `usbserial.ko` isn't loaded
$ lsmod | grep usbserial
$

# load it
$ modprobe usbserial

# confirm
$ lsmod |grep usbserial
usbserial              42355  0 

# check dmesg log
$ dmesg | tail -4
[1195955.210920] usbcore: registered new interface driver usbserial
[1195955.210970] usbcore: registered new interface driver usbserial_generic
[1195955.211002] USB Serial support registered for generic
[1195955.211069] usbserial: USB Serial Driver core

References

2
  • Added how to compile usbserial.ko. Pretty straightforward steps. LMK if you have issues.
    – slm
    May 15, 2013 at 13:59
  • This is how all SE answers should be formatted / explained. +1 Dec 28, 2015 at 17:57
0

Just as a comment, this excellent and very detailed recipe almost worked on my ARM chromebook. But I had to change this line:

$ wget https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/drivers/usb/serial/cp210x.c?h=linux-3.5.y -O cp210x.c

To this:

$ wget https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/drivers/usb/serial/cp210x.c?h=linux-3.4.y -O cp210x.c

That is, I had to change "linux-3.5.y" to "linux-3.4.y"; with 3.5.y it did not work.

0

I encountered same problem in ubuntu 12.04 and now using this driver which is heavily documented. Additionally configuration scripts, udev rules etc are also there.

https://github.com/RishiGupta12/serial-communication-manager/tree/master/drivers/cp210x-silicon-labs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.