38 lines
1.7 KiB
Bash
38 lines
1.7 KiB
Bash
#!/vendor/bin/sh
|
|
#
|
|
# wireless_reprobe.sh - re-probe wireless drivers once /vendor is mounted.
|
|
#
|
|
# Built-in wireless drivers probe during early kernel init, before /vendor
|
|
# (which holds all firmware; see the kernel's patched fw_path[]) is mounted.
|
|
# Their firmware requests fail fast with ENOENT and the kernel never retries,
|
|
# leaving the hardware driverless or degraded. Run from init at post-fs
|
|
# (i.e. after /vendor is mounted) via init.tart.wifi.rc, this script:
|
|
#
|
|
# 1. Re-probes every driverless USB interface, so a USB WiFi adapter that
|
|
# was plugged in at power-on (and whose driver probe failed on the
|
|
# missing firmware) gets a second probe that can now load firmware.
|
|
# 2. Rebinds the Broadcom Bluetooth serdev device, so hci_bcm reloads its
|
|
# .hcd patch firmware (e.g. brcm/SYN43711A0.hcd). Without the patch the
|
|
# controller runs with unpatched defaults, which cripples TX power/range.
|
|
#
|
|
# Both operations are idempotent and safe: already-bound USB interfaces are
|
|
# skipped, and the BT rebind simply re-registers hci0 before the Bluetooth
|
|
# stack starts.
|
|
|
|
# 1. USB: ask the kernel to re-run driver matching for unbound interfaces
|
|
# (directories like 1-1:1.0 without a "driver" symlink).
|
|
for intf in /sys/bus/usb/devices/*:*; do
|
|
[ -e "$intf/driver" ] && continue
|
|
echo "${intf##*/}" > /sys/bus/usb/drivers_probe 2>/dev/null
|
|
done
|
|
|
|
# 2. Bluetooth: unbind + re-probe serdev devices so the hci_bcm driver's
|
|
# firmware patch request runs again with /vendor/firmware available.
|
|
for dev in /sys/bus/serial/devices/*; do
|
|
[ -e "$dev/driver" ] || continue
|
|
name="${dev##*/}"
|
|
echo "$name" > "$dev/driver/unbind" 2>/dev/null
|
|
echo "$name" > /sys/bus/serial/drivers_probe 2>/dev/null
|
|
done
|
|
|
|
exit 0
|