Wifi

Enabling Wi-Fi hardware

Qualcomm

Wifi is fairly easy to get going on most Qualcomm devices. The following should enable your device’s Wi-Fi hardware:

echo 1 > /dev/wcnss_wlan
echo sta > /sys/module/wlan/parameters/fwpath

Errors

If the first command line fails with /dev/wcnss_wlan: Bad address

This is not an error condition; don’t get put off — try the second command.

If /sys/module/wlan is missing (not found)

Try to load the wlan kernel module first:

insmod /system/lib/modules/wlan.ko

If insmod fails with Required key is not found, you could temporarily disable all the CONFIG_MODULE_SIG** options in your defconfig and then re-build hybris-boot (or halium-boot) and system.img. Beware: this disables kernel module signatures (a security feature) — consider fixing it later.

If insmod fails with Invalid module format, then you need to ensure that you build your hybris-boot (or halium-boot) and system.img with the same kernel configuration (e.g. perhaps you forgot to re-install system.img after disabling kernel module signatures above, it contains kernel modules).

Broadcom bcmdhd

It is recommended to build Broadcom drivers as a module since that will ensure use of the device’s MAC address.

In the kernel defconfigs, make sure these settings are set:

CONFIG_MODULES=y
CONFIG_BCMDHD=m

Then add this to your device’s init.rc file, it’s recommended to set this in early stages to avoid race condition with network manager (on post-fs-data is a good place for this):

insmod /system/lib/modules/bcmdhd.ko

Testing Wi-Fi functionality

You may run the following command to see if your Wi-Fi hardware has come up:

nmcli d

Your device should show up as wlan0 and have a state of “Disconnected” when it is ready. At that point, run the following command to enter an interface that you can use to connect to Wi-Fi:

nmtui

Once you are connected to Wi-Fi, try pinging an Internet device:

ping 8.8.8.8

If all of this is successful, you have successfully brought up your Wi-Fi hardware. If not, check your device’s Logcat for possible errors.

Common errors

Kernel 3.10 ping: socket: Permission denied

This error is most common on devices which shipped with Linux kernel 3.10. To resolve it, apply the following patches:

  1. Introduce the SECURITY_ANDROID_GID_CAPABILITIES option
  2. Select SECURITY_ANDROID_GID_CAPABILITIES when enabling paranoid network
  3. Enable the CONFIG_SECURITY_ANDROID_GID_CAPABILITIES option