Add wireless reprobe service for post-mount firmware loading
This commit is contained in:
parent
6645a6d36a
commit
b691318ecf
6 changed files with 79 additions and 2 deletions
|
|
@ -287,7 +287,8 @@ PRODUCT_PACKAGES += \
|
||||||
com.android.hardware.wifi.hostapd.opi5 \
|
com.android.hardware.wifi.hostapd.opi5 \
|
||||||
com.android.hardware.wifi.supplicant.opi5 \
|
com.android.hardware.wifi.supplicant.opi5 \
|
||||||
libwpa_client \
|
libwpa_client \
|
||||||
wificond
|
wificond \
|
||||||
|
wireless_reprobe.sh
|
||||||
|
|
||||||
PRODUCT_COPY_FILES += \
|
PRODUCT_COPY_FILES += \
|
||||||
frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml
|
frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml
|
||||||
|
|
|
||||||
|
|
@ -49,4 +49,6 @@
|
||||||
/dev/block/by-name/boot u:object_r:boot_block_device:s0
|
/dev/block/by-name/boot u:object_r:boot_block_device:s0
|
||||||
|
|
||||||
#V4L2
|
#V4L2
|
||||||
/vendor/bin/hw/android\.hardware\.media\.c2@1\.2-service-v4l2(.*)? u:object_r:mediacodec_exec:s0
|
/vendor/bin/hw/android\.hardware\.media\.c2@1\.2-service-v4l2(.*)? u:object_r:mediacodec_exec:s0
|
||||||
|
# WiFi
|
||||||
|
/vendor/bin/wireless_reprobe\.sh u:object_r:wireless_reprobe_exec:s0
|
||||||
|
|
|
||||||
16
sepolicy/wireless_reprobe.te
Normal file
16
sepolicy/wireless_reprobe.te
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Domain for wireless_reprobe.sh: re-probes wireless drivers via sysfs after
|
||||||
|
# /vendor is mounted (see wifi/wireless_reprobe.sh). Runs once from init at
|
||||||
|
# post-fs as a oneshot service.
|
||||||
|
type wireless_reprobe, domain;
|
||||||
|
type wireless_reprobe_exec, exec_type, vendor_file_type, file_type;
|
||||||
|
|
||||||
|
init_daemon_domain(wireless_reprobe)
|
||||||
|
|
||||||
|
# Execute the vendor shell and toybox for the script interpreter
|
||||||
|
allow wireless_reprobe vendor_shell_exec:file rx_file_perms;
|
||||||
|
allow wireless_reprobe vendor_toolbox_exec:file rx_file_perms;
|
||||||
|
|
||||||
|
# Walk /sys/bus/{usb,serial}/devices and write to drivers_probe/unbind
|
||||||
|
allow wireless_reprobe sysfs:dir r_dir_perms;
|
||||||
|
allow wireless_reprobe sysfs:file rw_file_perms;
|
||||||
|
allow wireless_reprobe sysfs:lnk_file read;
|
||||||
|
|
@ -3,6 +3,15 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
// Re-probes wireless drivers after /vendor mounts so firmware-dependent
|
||||||
|
// probes that failed during early kernel init get a working second chance.
|
||||||
|
sh_binary {
|
||||||
|
name: "wireless_reprobe.sh",
|
||||||
|
src: "wireless_reprobe.sh",
|
||||||
|
vendor: true,
|
||||||
|
init_rc: ["init.tart.wifi.rc"],
|
||||||
|
}
|
||||||
|
|
||||||
prebuilt_etc {
|
prebuilt_etc {
|
||||||
name: "android.hardware.wifi.hostapd-service.rc",
|
name: "android.hardware.wifi.hostapd-service.rc",
|
||||||
src: "android.hardware.wifi.hostapd-service.rc",
|
src: "android.hardware.wifi.hostapd-service.rc",
|
||||||
|
|
|
||||||
11
wifi/init.tart.wifi.rc
Normal file
11
wifi/init.tart.wifi.rc
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Re-probe wireless drivers whose early firmware requests failed because
|
||||||
|
# /vendor was not yet mounted. See wireless_reprobe.sh for details.
|
||||||
|
service wireless_reprobe /vendor/bin/wireless_reprobe.sh
|
||||||
|
class core
|
||||||
|
user root
|
||||||
|
group root
|
||||||
|
oneshot
|
||||||
|
disabled
|
||||||
|
|
||||||
|
on post-fs
|
||||||
|
start wireless_reprobe
|
||||||
38
wifi/wireless_reprobe.sh
Normal file
38
wifi/wireless_reprobe.sh
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue