Fix broken onboard WiFi on a Raspberry Pi 3 and Arch Linux and systemd

Apparently, it looks like some Raspberry Pi 3 boards are manufactured with a bug in the onboard WiFi chip. After booting, even that the kernel module brcmfmac is loaded, there is no wlan0 showing up. With some googling, I found that if you remove and reload the kernel module, the wifi device will show up. So all I needed to do, is creating a script which runs after every startup which does exactly that.

The script looks like this:

#!/bin/sh
lsmod
sleep 2
modprobe -r brcmfmac
sleep 2
modprobe brcmfmac
sleep 2
ifconfig -a

There are some more commands in it, so it will show up later in journalctl, but you just need the modprobe commands to remove and load the kernel module. Create a file with these commands and try to run it from a terminal and verify that it works manually. If everything works fine, create a systemd service which runs this script once at startup:

$ cat /etc/systemd/system/wifi.service
[Unit]
Description=wifi

[Service]
ExecStart=/root/wifi.sh

[Install]
WantedBy=multi-user.target

After this, you only need a

systemctl enable wifi

and this should make the wifi working automatically after the pi is booted up. You can verify with journalctl -xeu wifi. If you are supercool, you could also add more systemd dependencies and let the wifi service only run if your netctl is asking for it or other fancy things.

Happy wireless networking!