USB device port identification on Linux

categories: pc
tags: linux

Problem description

Sony’s one-board microcomputer, Spresense, and Allystar HD9310 evaluation board, the satellite signal positioning board, both use Silicon Labs. CP210x as a USB UART driver. On Linux such as Raspberry Pi, both are recognized by the device / dev/ttyUSBx (where x is a number).

When I reboot with both of them connected, two devices, /dev/ttyUSB0 and /dev/ttyUSB1, appear, but I don’t know which one will be Spresense depending on the timing.

Many people have set up a mechanism called udev so that it is automatically identified by idVendor and idProduct, but both of them are P10c4 and ea60. It was not possible to distinguish USB ports between Spresense and HD9310. I thought of a way to recognize both of them individually on Linux.


What device was recognized by, for example, the Raspberry Pi as /dev/ttyUSB0, what was the other device recognized as /dev/ttyUSB1, and then we observe the difference between them. To do this, run a folloing command:

udevadm info -a -n /dev/ttyUSB0

Redirect this result to a file called ttyUSB0.txt. The same procedures are repeated with a device /dev/ttyUSB1, and we use the diff command to find the difference between them. Alternatively, you can plug and unplug the device from the USB port by running the following command:

udevadm monitor --environment --udev

The rule file I’m using

In the end, I made the udev rule file as follows:

# u-blox ZED-F9P
    ATTRS{idVendor}=="1546", ATTRS{idProduct}=="01a9",\

# ES920LR
    ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001",\

# Allystar HD9310
    ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60",\

# Sony Spresense
    ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60",\


I can use /dev/ttyDCR (DCR stands for disaster and crisis management report of Michibiki) for accesing Spresense, while /dev/ttyHD9310 for accessing HD9310.

Save this rules file to a file such as /etc/udev/rules.d/00-spresense-hd9310.rules and place it in the /etdc/udev/rules.d/ directory. Then we execute the following command, a link such as /dev/ttyDCR is automatically created in the device file directory.

udevadm control --reload-rules && udevadm trigger

This rule file also describes my favorite u-blox ZED-F9P and EASEL ES920LR.