Persistent USB wifi device symlink at boot

Hi,

I have openwrt in an amd64 Qemu VM with a mediatek USB wireless module passed-through to it.

The usb devices are initialized by the kernel after netifd starts, and the wifi doesn't start at reboot. basically this bug.
Relevant log lines:

radio0 (2118): WARNING: Variable 'data' does not exist or is not an array/object
radio0 (2118): Phy not found
radio0 (2118): Could not find PHY for device 'radio0'
Wireless device 'radio0' set retry=0
Wireless device 'radio0' setup failed, retry=0
radio0 (2193): WARNING: Variable 'data' does not exist or is not an array/object
radio0 (2193): Bug: PHY is undefined for device 'radio0'
Wireless device 'radio0' is now down

A sleep 10 && wifi in /etc/rc.local "fixes this" .
Also there is the risk that the device gets enumerated to a different buspath...

My goal:
In hotplug.d/usb create a script that reacts on bind events to create a symlink device which is then set in

wireless.radio0.path='$symlink_path'

and then somehow restart wifi once the device is bound.
So the question: I'm completely stumped what to symlink to where, and on which event to reload the wifi subsystem...

Thanks for any advice, or a different suggestion.

There is (still) no persistent device names.
For block devices it is addressed by GUID, something like burnt-in MAC, but then comes bugs with random macs.... Anyway that issue still waits for sound tech proposal. busybox does not support ip altname to emulate systemd's renamings.

Yes, match by mac address is exactly what I'm looking for. I'm actually currently using a self-created .link/.netdev/.network systemd configuration, looking to make something a bit more user friendly, and not having to keep up with hostapd changelogs. It got really complex since 802.11n...

So sleep 10 && wifi && pray .

1 Like

You can extract burned-in macaddress with ethtool on hotplug event.