Page 1 of 1

[RPi3B+] brcmfmac driver doesn't load properly on Raspbian initrd, missing firmware files

Posted: Wed Oct 31, 2018 1:04 am
by Mimomimo
On a regular Raspbian installation (latest update as of 2018/10/30 with kernel 4.14.78-v7+, original image file is 2018-10-09-raspbian-stretch-lite),
I use an initrd (initramfs), and I would like to load the brcmfmac kernel driver to enable Wifi during that early stage.

When using mkinitramfs, the modules are copied into the initrd, but it's still missing some firmware files, namely brcmfmac43455-sdio.clm_blob and brcmfmac43455-sdio.txt. I assume these files are missing because they are not listed in modinfo -k $(uname -r) brcmfmac.

Here is the syslog complaining about the missing file:

Code: Select all

$> dmesg | grep -i brcmfmac
[    3.334553] brcmfmac: F1 signature read @0x18000000=0x15264345
[    3.342690] brcmfmac: brcmf_fw_map_chip_to_name: using brcm/brcmfmac43455-sdio.bin for chip 0x004345(17221) rev 0x000006
[    3.352440] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43455-sdio.txt failed with error -2
[    3.360937] usbcore: registered new interface driver brcmfmac
[    4.467976] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50
[    5.499272] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50
To include these files with mkinitramfs without editing the initrd "manually" (decompressing the with cpio, adding, then recompressing) I made this hacky script below. Let me know if there's a better way to fix this. I initially had a look at `/usr/share/initramfs-tools/hook-functions` but hacking this script doesn't sound like a good idea at all.

Placed in /etc/initramfs-tools/hooks/fix_brcm_missing_fiirmware (and chmod +x):

Code: Select all

#!/bin/sh -e                                                                                                                                                                 
# Copy missing firmware files for brcmfmac driver                                                                                                                            
prereqs () { echo "${PREREQ}"; }                                                                                                                                              
case "${1}" in prereqs) prereqs; exit 0 ;; esac ;                                                                                                                            
. /usr/share/initramfs-tools/hook-functions                                                                                                                                  
echo "Copying missing firmware files for brcmfmac..."                                                                                                                        
cp /lib/firmware/brcm/brcmfmac43455-sdio.bin ${DESTDIR}/lib/firmware/brcm/                                                                                                   
cp /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob ${DESTDIR}/lib/firmware/brcm/                                                                                              
cp /lib/firmware/brcm/brcmfmac43455-sdio.txt ${DESTDIR}/lib/firmware/brcm/ 
Then sudo mkinitramfs -o /boot/initrd.img -k -v 4.14.78-v7+. And we can check our files are indeed there now:

Code: Select all

$> lsinitramfs /boot/initrd.img | grep -i brcmfmac43455                      
Rebooting and it works fine now, no more error!

Other reports for this issue:

I hope this helps someone, and I hope this can be fixed upstream too.
I had some other issues loading this brcmfmac driver before with 4.14.71+, had to `rmmod brcmfmac` then `insmod /lib/modules/4.14.71-v7+/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko` to reload it and then it works fine. Very weird: Fortunately, this doesn't seem to happen with 4.14.78.