1

So I'm having a bit of an issue with a usb to serial device, when my raspberry pi compute module boots up it enumerates this specific usb to serial device first which "bumps" the other usb to serial ports which are created later and represent multiple ports to a modem/gps.

So by default my ports look like this without this usb to serial device connected:

/dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3

When I connect this usb to serial device it gets added as follows:

/dev/ttyUSB4

If I reboot however or shutdown and then start back up the list appears identical except the usb to serial device I mentioned before that used to be ttyUSB4 is now at ttyUSB0. This is what I meant by the ports getting "bumped".

I have tried editing the udev local.rules file by adding the following line.

ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", SYMLINK+="usbgps"

I also tried this line as well but this one didn't seem to work.

ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", NAME+="usbgps"

The first line that creates the symlink works and it creates a new device/link located at /dev/usbgps.

This works but the original device still remains ie it creates the usbgps symlink but it also creates the /dev/ttyUSB4 device. On reboot it then shows up as /dev/ttyUSB0 and "bumps" up the other ports which messes up other pieces of software I have.

In the long run I will try to use specific static names for the devices that my software is accessing. The problem with this is that the ttyUSB0/1/2/3 ports get created by a special driver from the modem manufacturer. So I will likely need to modify the code to be able to have the four usb to serial ports show up with direct symlinks. ie ttyUSB2 is for pppd/cellular so I'd name it cellport and ttyUSB1 is for gps so I'd name that gpsport and so on.

If anyone knows how I could make the ttyUSB0/1/2/3 ports have direct symlinks without modifying the driver please do tell.

So the ultimate question that I'm asking is:

How do I make my usb device appear as usbgps without making it also appear as a ttyUSB4 or ttyUSB0 port name. I only want the device to show up as usbgps. If I can stop it from being added to the list of ttyUSB devices then I can stop it from bumping the ports and messing up the other applications that depend on the ports having a specific name.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

2

Ok so I think I solved the problem by following this post.

udev rules for USB serial 'by path' not working

I booted up the compute module with everything connected and the ports appeared as follows along with a description for what the port represents.

ttyUSB0 -> usb gps ttyUSB1 -> modem port 0 ttyUSB2 -> modem gps port ttyUSB3 -> modem cellular port for pppd ttyUSB4 -> modem at command port

I then ran the following commands and recorded the output:

udevadm info /dev/ttyUSB0 | grep "ID_PATH="
udevadm info /dev/ttyUSB1 | grep "ID_PATH="
udevadm info /dev/ttyUSB2 | grep "ID_PATH="
udevadm info /dev/ttyUSB3 | grep "ID_PATH="
udevadm info /dev/ttyUSB4 | grep "ID_PATH="

The output from these commands looks like this:

platform-fe980000.usb-usb-0:1.1:1.0
platform-fe980000.usb-usb-0:1.3:1.0
platform-fe980000.usb-usb-0:1.3:1.1
platform-fe980000.usb-usb-0:1.3:1.2
platform-fe980000.usb-usb-0:1.3:1.3

Then I took down this information and added the following lines to the /etc/udev/rules.d/local.rules file. In the future I will add these rules in another rules file in the same rules.d folder rather than placing it in the local.rules file.

SUBSYSTEM=="tty",ENV{ID_PATH}=="platform-fe980000.usb-usb- 
0:1.1:1.0",SYMLINK+="usbgps"
SUBSYSTEM=="tty",ENV{ID_PATH}=="platform-fe980000.usb-usb- 
0:1.3:1.0",SYMLINK+="modemport0"
SUBSYSTEM=="tty",ENV{ID_PATH}=="platform-fe980000.usb-usb- 
0:1.3:1.1",SYMLINK+="modemgpsport"
SUBSYSTEM=="tty",ENV{ID_PATH}=="platform-fe980000.usb-usb- 
0:1.3:1.2",SYMLINK+="modemcellularport"
SUBSYSTEM=="tty",ENV{ID_PATH}=="platform-fe980000.usb-usb- 
0:1.3:1.3",SYMLINK+="modemcommandport"

Now when the compute module boots up the ttyUSB0/1/2/3/4/5 ports can shift around but because the symlinks point to the ID_PATH of the usb device it doesn't seem to matter. I can reboot the module or shut down and startup fresh and everything works as I would expect it to.

So just as an example, if I want to open up and view the gps data coming from the usbgps port.

I used to run this command to view the usb gps data:

picocom /dev/ttyUSB0 -b 9600

Now I can run the same command but have it point to the symlink instead and it works perfectly.

picocom /dev/usbgps -b 9600

I'm not sure if this is the best solution all around but at least I have a solution that seems to work well.

If you have any thoughts on a better solution please post.