OpenWrt Forum Archive

Topic: How to assign a constant symlink for an USB device on cold boot

The content of this topic has been archived on 27 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I want to use an USB device with OpenWrt router.

To assign constant symlink for an USB device, I put an script to /etc/hotplug.d/usb/ .

But, procd doesn't invoke the script if an USB device is plugged on cold boot. When I boot router with an plugged USB storage, Linux kernel detects the USB storage but procd doesn't invoke scripts in /etc/hotplug.d/usb/ . And procd invoke scripts when I removed the USB device, procd invoke scripts with remove event only.

The USB device I want to use may be unplugged on booting. I want to assign a constant symlink for the USB device for cold boot and hotplug. How to?

You could try /etc/rc.local and see if that works.

I looked up the way to find port of an USB. The way I found used udevadm command.
unix.stackexchange.com/questions/144029/command-to-determine-ports-of-a-device-like-dev-ttyusb0

How can I do similar operation on OpenWrt without udevadm?

You didn't say what you were running, but I am hoping you are running the latest available openwrt or LEDE for your router as the usb.id that defines devices needs to be current.

there are some examples here that may help you in any case:

https://lede-project.org/docs/user-guide/hotplug_lede

Sorry about I have not describe the environment. I use older version packaged by a board vendor.

> You could try /etc/rc.local and see if that works.

I put script as described by below.

by TLS) unix.stackexchange.com/questions/81754/how-can-i-match-a-ttyusbx-device-to-a-usb-serial-device

> $ lsusb
> Bus 003 Device 016: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
> $ ls -l /sys/bus/usb-serial/devices
> lrwxrwxrwx 1 root root 0 Jul  4 17:37 ttyUSB0 -> ../../../devices/pci0000:00/0000:00:1c.0/0000:02:00.0/usb3/3-1/3-1:1.0/ttyUSB0
> $ $ grep PRODUCT= /sys/bus/usb-serial/devices/ttyUSB0/../uevent
> PRODUCT=67b/2303/300

Thanks.

The discussion might have continued from here.