[Solved] Wireless config for same USB Wifi dongle on different USB ports of the device

I have a Raspberry Zero. The Zero has a single USB port for devices. I am using a USB Wifi mt7601u dongle on this port in Wifi client mode.

But I am facing the situation that I occasionally need to additionally plug in a USB-LAN adapter for maintenance access. I do so via USB Hub, to have both Wifi and LAN connected to the single Zero's USB port.

Is there by chance a best practice, how to deal with such a situation, if the same USB Wifi dongle is sometimes directly attached via the single port and sometimes indirectly via USB hub, as both connection variants end up in having different path-addresses for the same Wifi dongle in the wireless file. As the wireless config references the relative address of the USB port, not an unique device ID of the Wifi USB dongle. (I am practically facing the same issue, when using the dongle on my Pi4, which has 4 USB ports - I have to remember to reuse the same port for the Wifi dongle)

  • In the following wireless excerpt, I have excluded "radio0" (that is the Zero's internal Broadcom radio that I have disabled)
  • radio1 is the mt7601u USB dongle, when attached via USB hub
  • radio2 is the same mt7601u USB dongle, when attached without USB hub, directly to the single USB port of the device. It has a different "path" when not using the USB hub.
config wifi-device 'radio1'
	option type 'mac80211'
	option path 'platform/soc/20980000.usb/usb1/1-1/1-1.1/1-1.1:1.0'
	option channel '1'
	option band '2g'
	option htmode 'HT20'
	option cell_density '0'
	option country 'DE'

config wifi-iface 'wifinet2'
	option device 'radio1'
	option mode 'sta'
	...

config wifi-device 'radio2'
	option type 'mac80211'
	option path 'platform/soc/20980000.usb/usb1/1-1/1-1:1.0'
	option channel '1'
	option band '2g'
	option htmode 'HT20'
	option disabled '1'

Hi

you could try

config wifi-device 'radio0'
        option type 'mac80211'
        option phy 'phy0'

so phy0 is for first radio, whatever path is used

Thank you. That does it.

I only had to test whether it is phy0 or phy1.

It also has the nice effect that once I configure:

config wifi-device '...'
        option phy 'phy0'

instead of

config wifi-device '...'
        option path 'platform/soc/20980000.usb/usb....'

OpenWRT will no longer readd another default radio wireless config, once i switch between connection with/without USB hub.

Another less elegant workaround that seems to work is, to have the same USB wireless dongle added twice to the wireless config (e.g. as radio 1 and radio2, one via hub, one via direct USB), each connection manually enabled once, both linked to the same interface and both with the same wireless SSID and Wifi key. Then whichever of the 2 connection variant it is, the matching one will be automatically enabled, come up and work in my wireless-client scenario.

But the variant with "phy" instead of "path" is more flexible and elegant, as it does not care about which USB port is used.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.