Currently, the wifi detection script is executed as part of the (early) boot process. Pluggable wifi USB devices, which are inserted at a later time are not automatically detected and therefore they don't show up in LuCI.
A user has to deal with wifi detection manually, or restart the router. However, the current "sleep 1" window - which the boot process waits for wifi devices to "settle down" - is too short to detect wifi devices for some routers. For example, this can happen with USB WLAN devices on the WNDR4700. This is because the usb controller needs to load its firmware from UBI and initialize, before it can operate. The issue can be seen on a BT HomeHub 5A as well as soon as the caldata are on an ubi volume. This is because the ath9k card has to be initialized by owl-loader first. Which has to wait for the firmware extraction script to retrieve the pci initialization values inside the caldata. This patch moves the wifi detection to hotplug scripts. For mac80211, the wifi detection will now automatically run any time a "ieee80211" device is added. Likewise broadcom-wl's script checks for new "net" devices. As for potential problems: - For devices with more than one wifi device, these scripts will run multiple times during boot (concurrently). For this reason, the script uses file locking to prevent races during discovery. (i.e duplicated radio instances). - The broadcom-wl hotplug script is suboptimal. As it will run for any net devices (ethernet). (- There might be non-wifi drivers that needed this delay) All changes to base-files, mac80211 and broadcom-wl packages have been integrated into a single patch to play nice with git bisect. Thanks to Martin Blumenstingl for helping with the implementation and testing of the patch. Signed-off-by: Mathias Kresin <d...@kresin.me> Signed-off-by: Christian Lamparter <chunk...@gmail.com> --- We would like to hear, if these changes work with broadcom-wl. (Felix removed the hostap, so this isn't included anymore). trap and lock are part of the default busybox setup. --- package/base-files/files/etc/init.d/boot | 9 --------- .../files/etc/hotplug.d/net/00-broadcom-wifi-detect | 16 ++++++++++++++++ package/kernel/mac80211/Makefile | 2 ++ package/kernel/mac80211/files/mac80211.hotplug | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect create mode 100644 package/kernel/mac80211/files/mac80211.hotplug diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot index 904f7db..1d61f2f 100755 --- a/package/base-files/files/etc/init.d/boot +++ b/package/base-files/files/etc/init.d/boot @@ -38,15 +38,6 @@ boot() { /sbin/kmodloader - # allow wifi modules time to settle - sleep 1 - - /sbin/wifi detect > /tmp/wireless.tmp - [ -s /tmp/wireless.tmp ] && { - cat /tmp/wireless.tmp >> /etc/config/wireless - } - rm -f /tmp/wireless.tmp - /bin/config_generate uci_apply_defaults diff --git a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect new file mode 100644 index 0000000..cd7af8b --- /dev/null +++ b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect @@ -0,0 +1,16 @@ +#!/bin/sh + +unlock() { + lock -u /tmp/wireless.lock +} + +[ "${ACTION}" = "add" ] && { + trap unlock EXIT + lock /tmp/wireless.lock + + /sbin/wifi detect > /tmp/wireless.tmp + + [ -s /tmp/wireless.tmp ] && cat /tmp/wireless.tmp >> /etc/config/wireless + + rm -f /tmp/wireless.tmp +} diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile index 91c9362..f320326 100644 --- a/package/kernel/mac80211/Makefile +++ b/package/kernel/mac80211/Makefile @@ -1732,6 +1732,8 @@ define KernelPackage/cfg80211/install $(INSTALL_DIR) $(1)/lib/wifi $(1)/lib/netifd/wireless $(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi $(INSTALL_BIN) ./files/lib/netifd/wireless/mac80211.sh $(1)/lib/netifd/wireless + $(INSTALL_DIR) $(1)/etc/hotplug.d/ieee80211 + $(INSTALL_DATA) ./files/mac80211.hotplug $(1)/etc/hotplug.d/ieee80211/00-wifi-detect endef define KernelPackage/ipw2100/install diff --git a/package/kernel/mac80211/files/mac80211.hotplug b/package/kernel/mac80211/files/mac80211.hotplug new file mode 100644 index 0000000..cd7af8b --- /dev/null +++ b/package/kernel/mac80211/files/mac80211.hotplug @@ -0,0 +1,16 @@ +#!/bin/sh + +unlock() { + lock -u /tmp/wireless.lock +} + +[ "${ACTION}" = "add" ] && { + trap unlock EXIT + lock /tmp/wireless.lock + + /sbin/wifi detect > /tmp/wireless.tmp + + [ -s /tmp/wireless.tmp ] && cat /tmp/wireless.tmp >> /etc/config/wireless + + rm -f /tmp/wireless.tmp +} -- 2.9.3 _______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev