Hotplug event triggered too early
Username: John Daktylidis
Origin: https://bugs.openwrt.org/index.php?do=details&task_id=1903
DEVICE: TP-Link Archer C7 v2
SYSTEM: OpenWRT 18.06.1
PACKAGES: base + luci, ca-certificates, ddns-scripts_no-ip_com, luci-app-ddns, wget, ip, ppp, ppp-mod-pppoe, vim, nano, usbutils, usb-modeswitch, kmod-usb-core,
kmod-usb-serial, kmod-usb-serial-option, kmod-usb-net-cdc-ncm, kmod-usb-net-huawei-cdc-ncm, picocom, sqm-scripts, luci-app-sqm, kmod-ledtrig-heartbeat, htop
If the USB Device (HUAWEI E3372 LTE Stick) is left connected to the router during a reboot/boot, the hotplug event is triggered too early and the device has not yet all interfaces mapped in the /dev directory.
More specifically, my hotplug script wants to find the name of the interface (which is “ttyUSB0” in my case) by looking at the $DEVPATH directory, but during the hotplug script execution the link does not yet exist. Adding a “sleep” inside the script does not help, but executing a subscript via “exec script &” shows that after 3 seconds the link is created.
Attached is a file showing the directory listing of $DEVPATH during the hotplug event, and 3 seconds after the hotplug event.
Note that the hotplug script works as intended during actual hotplugging. This bug only presents itself during boot/reboot.
Also note that this was working on OpenWRT 15.05.1 (same Router, Stick and hotplug script)