Hard coding /dev/tty/USB0

Every so often, I run into this problem where the port cannot be found.

E:serial error 2 opening /dev/ttyUSB0: No such file or directory
E:serial Open serial port failed

When this happens, sometimes I can unplug and plug the device back into the USB port then it can be found, other times, this doesn't work and a full reboot is needed. It gets weirder when a reboot without anything connected to the USB port works and other times it does not. And even stranger is sometimes, once this is working, it survives across reboots.

I do not understand the seemingly (to me) random behavior so wondered if there is some way to hard code this in some way so that when openwrt reboots, the serial/USB port would always be ready no matter if something is connected to the USB or not.

I currently have this in my rc.local to get things started but the above happens.

modprobe ftdi_sio (this usually only needs to run once)
echo 0400 000f1 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id
exit 0

Maybe the problem is that I should not be doing this from the rc.local? I really don't know as searching for days has not revealed anything obvious which is why I'm posting here at this point.

1 Like

Thank you. That's a bit over my head at the moment but I'll see if I can try to understand what you're showing me. One more problem I just noticed this morning is that I left the device running overnight and the USB0 was there but this morning, it's gone again.

Oddly, the ID is still as it was yesterday.

% cat /sys/bus/usb-serial/drivers/ftdi_sio/new_id
0400 000f1

where did you get this value from?

Please show the output of cat /sys/kernel/debug/usb/devices

I made up the value as an example. I don't have access to that device right now. Just thought I'd post to see if there is some way to hard code the USB0 port to remain no matter what.

I was playing around with something else and found a simple solution, usbreset.
However, I would still like to understand how to statically map /dev/tty/USB0 using hotplug but it seems over my head when looking at the shared page. Maybe I can find a post where someone is showing some simpler examples that I can start learning from.