How to Access SOM9331 Serial Console in Linux

I got this old hackable mini router board. It comes with OpenWRT but I can’t seem to connect this via USB Serial. It turns out that the driver is not installed. Installation is quick but there is a minor change needed in order to build the driver on a recent kernel. So will write here in case someone facing the same problem.

Connect the micro-USB of SOM9331 to your Linux PC. This module has Silicon Labs CP2104 USB to TTL serial converter chip built-in. Go to the vendor website and download the CP210x USB to UART Bridge VCP Drivers.

Extract it with

$ unzip -d cp210xdriver

And move to that folder

$ cd cp210xdriver

Unfortunately, there is a minor issue with compilation on my Kernel 5.17. The int is not compatible with void. So we have to do minor modifications.

In cp210x.c file, this line at 52:

static int cp210x_port_remove(struct usb_serial_port *);

needs to be changed to:

static void cp210x_port_remove(struct usb_serial_port *);

and this one is also in the same file at line 2414:

static int cp210x_port_remove(struct usb_serial_port *port)

change it to:

static void cp210x_port_remove(struct usb_serial_port *port)

Also in the same function, line 2421, comment the
//return 0;

Now we can start building the driver.

$ make
$ sudo cp cp210x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial
$ sudo insmod /lib/modules/$(uname -r)/kernel/drivers/usb/serial/usbserial.ko
$ sudo insmod cp210x.ko

Now if you can’t find /dev/ttyUSB0 and you have this message:

$ sudo dmesg | tail
usbfs: interface 0 claimed by cp210x while 'brltty' sets config #1

The problem here is BRLTTY, a program that “provides access to the Linux/Unix console (when in text mode) for a blind person using a refreshable braille display”.

If you’re not blind then you can disable it.

We can find out about brltty service:

$ systemctl list-units | grep brltty

In my case its brltty-udev.service. Then let’s disable them

$ sudo systemctl mask brltty-udev.service
$ sudo systemctl stop brltty-udev.service

Now check again my kernel message

$ sudo dmesg | tail
[sudo] password for derry:
[58966.197632] usb 1-8: Product: CP2104 USB to UART Bridge Controller
[58966.197633] usb 1-8: Manufacturer: Silicon Labs
[58966.197633] usb 1-8: SerialNumber: 00E2684C
[58966.198805] cp210x 1-8:1.0: cp210x converter detected
[58966.199598] usb 1-8: cp210x converter now attached to ttyUSB0
[58967.773130] e1000e 0000:05:00.0 enp5s0: NIC Link is Up 100 Mbps Full Duplex, Flow Control: Rx/Tx
[58967.773252] e1000e 0000:05:00.0 enp5s0: 10/100 speed: disabling TSO
[58973.180382] e1000e 0000:05:00.0 enp5s0: NIC Link is Down
[58975.025293] e1000e 0000:05:00.0 enp5s0: NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
[58975.025415] e1000e 0000:05:00.0 enp5s0: 10/100 speed: disabling TSO

Check the serial

$ ls /dev/ttyUSB0

Seems good, and now login:

$ sudo picocom -b 115200 /dev/ttyUSB0                                                  
picocom v3.1

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
stopbits are   : 1
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
hangup is      : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv -E
imap is        : 
omap is        : 
emap is        : crcrlf,delbs,
logfile is     : none
initstring     : none
exit_after is  : not set
exit is        : no

Type [C-a] [C-h] to see available commands
Terminal ready

root@OpenWrt:/# uname -a
Linux OpenWrt 3.3.8 #1 Sat Mar 23 16:49:30 UTC 2013 mips GNU/Linux

Hope this helps! 🙂

Leave a Reply

Your email address will not be published.