twojstary
Posts: 7
Joined: Mon Feb 27, 2017 11:21 pm

HOWTO: using more recent WIFI firmware

Sat Jun 19, 2021 9:46 am

Debian/Raspberry Pi OS is very conservative with its choice of firmware drivers (terribly obsolete). Some bugs may be resolved in more recent firmware. Using the latest firmware probably won't break anything but in any case make sure you have a backup for roll back!

There are two ways to install more recent WIFI firmware.

First uninstall firmware-brcm80211, which contains your current firmware files.

NOTE: uninstalling firmware may cause your system to be unreachable after reboot via WIFI, if firmware is not installed. Make sure NOT to reboot your environment without re-installing the firmware (item 1 or 2 below).

1. Download & install more recent firmware from debian sid: https://packages.debian.org/pl/sid/firmware-brcm80211

However, as of today, the latest broadcom firmware in debian from 15th March 2021 still contains last year's firmware files: (http://ftp.us.debian.org/debian/pool/no ... -2_all.deb).

Code: Select all

$ strings cyfmac43430-sdio.bin | grep 202
Feb 16 2020
2020-02-16 22:32:23
43430a1-roml/sdio-g-pool-p2p-idsup-idauth-pktfilter-keepalive-aoe-lpc-swdiv-srfast-fuart-btcxhybridhw-noclminc-clm_min-fbt-mfp-sae-tko Version: 7.45.98.97 (r724416 CY) CRC: 588b07d3 Date: Sun 2020-02-16 22:41:02 PST Ucode Ver: 1043.2137 FWID 01-bf41ed64
$ strings cypress/cyfmac43430-sdio.clm_blob | grep 202
2020-06-01 03:44:00
2. You can also download the latest files from linux-firmware cypress (cypress = more recent broadcom drivers) directory from https://git.kernel.org/pub/scm/linux/ke ... ee/cypress to /lib/firmware/brcm.

NOTE: Only rpi0w/rpi3b firmware downloaded here (firmware type: 43430):
NOTE: Firmware for other models may be downloaded using a similar process, first identify the firmware for your, see Q&A below
NOTE: For rpi0w/rpi 3b, the kernel looks for the files /lib/firmware/brcm/brcmfmac43430-sdio.bin & /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob so those need to be renamed/links set up.

Code: Select all

$ sudo wget -P /lib/firmware/brcm https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/cypress/cyfmac43430-sdio.clm_blob
$ sudo wget -P /lib/firmware/brcm https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/cypress/cyfmac43430-sdio.bin
Make sure to link the downloaded files to the filenames the kernel expects (example applicable to rpi0w/rpi3b):

Code: Select all

$ sudo ln -sf /lib/firmware/brcm/cyfmac43430-sdio.bin /lib/firmware/brcm/brcmfmac43430-sdio.bin 
$ sudo ln -sf /lib/firmware/brcm/cyfmac43430-sdio.clm_blob /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob 
The driver may use additional nvram settings (txt files), I'm downloading the stuff myself from openwrt/cypress-nvram

Code: Select all

$ cat /home/tools/fix_brcmfmac.sh
#!/bin/sh
[ $(id -u) -gt 0 ] && sudo -E $0 && return $?
echo 'brcmfmac43430-sdio.raspberrypi,model-zero-w.txt brcmfmac43430-sdio.raspberrypi,3-model-b.txt brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt brcmfmac43455-sdio.raspberrypi,4-model-b.txt ' | xargs -d' ' -i sudo wget -NP /lib/firmware/brcm https://raw.githubusercontent.com/openwrt/cypress-nvram/master/{}
Q&A:
1. What firmware am I running?

Code: Select all

$ dmesg | grep -i firmware
[    0.150952] raspberrypi-firmware soc:firmware: Attached to firmware from 2021-05-27T14:04:13, variant start
[    0.160969] raspberrypi-firmware soc:firmware: Firmware hash is 7d9a298cda813f747b51fe17e1e417e7bf5ca94d
[  198.305993] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Mar 3[b]0 2021 01:12:21 version 7.45.98.118 [/b](7d96287 CY) FWID 01-32059766
In the above example, the firmware is BCM43430 from Mar 31st 2021.
43430 is the firmware type to help identify the firmware files.

2. Where do I find the firmware files?
Broadcom firmware are found under /lib/firmware/brcm. They have a .bin or a .clm_blob extension.

3. How do I find out the date of a firmware file?
The firmware timestamp can be inspected with the strings command, it will tell when the firmware was compiled, e.g.

Code: Select all

$ strings cyfmac43430-sdio.bin | grep 2020
4. What is cypress firmware?
More recent broadcom firmware. It needs to be linked to renamed to the files the kernel expects to find, however.

5. How to make firmware names more user friendly (contain version numbers)?

I'm running the following script that copies the files from /lib/firmware/brcm to a temporary directory where the files receive names based on internal version. Also, the script sets the date of the file to the compilation timestamp.

Those may be linked to the firmware file name that the kernel expects to find (e.g. for rpi0w/3b it is /lib/firmware/brcm/brcmfmac43430-sdio.bin & /lib/firmware/brcm/brcmfmac43430-sdio.clm_blob).

Code: Select all

#!/bin/ksh
SOURCE=${1:-/lib/firmware/brcm}
TARGET=${2:-/misc/firmware}
debug(){
  [ -n "${DEBUG}" ] && echo "${@}" || :
}
mkdir -p ${TARGET}
[ -n "${SOURCE}" ] && cd ${SOURCE} && for f in *.bin *.clm_blob; do cp -pr ${f} ${TARGET}/; done 
for f in ${TARGET}/*.bin; do strings ${f} | grep -Pom1 '(Version:|Ucode Ver:) [0-9.]*' | sed -e ':a;N;h;s/\n//g;$!ba;g;s/\n/_/g' | sed -e 's|Version: |v|g;s|Ucode Ver: |ucode|g' | read v; case $f in *${v}*) :;; *) fv=${f%.bin}${v:+_${v}}.bin && mv ${f} ${fv}; debug "${f} -> ${fv}";; esac; strings ${fv:-${f}} | grep -Pom1 'Date: \K[A-Za-z]{3} [0-9-]{10} [0-9:]{8} [A-Z]*' | xargs -i date -d{} +%Y%m%d%H%M.%S | while read t; do touch -t ${t} ${fv:-${f}}; debug "${fv:-${f}}: ${t}"; done; ls -la ${fv:-${f}}; unset fv f; done
for f in ${TARGET}/*.clm_blob; do strings ${f} | egrep '[0-9]{2}:' | tail -1 | xargs -i date -d{} +%Y%m%d%H%M.%S | while read t; do touch -t ${t} ${f}; debug "${f}: ${t}"; done; done
Last edited by twojstary on Sat Jun 19, 2021 10:29 am, edited 3 times in total.

User avatar
kerry_s
Posts: 2153
Joined: Thu Jan 30, 2020 7:14 pm

Re: HOWTO: using more recent WIFI firmware

Sat Jun 19, 2021 9:56 am

Debian/Raspberry Pi OS is very conservative with its choice of firmware drivers (terribly obsolete). Some bugs may be resolved in more recent firmware.
they use the stable branch.
your installing from the unstable branch(sid), that branch is for testing purposes.

twojstary
Posts: 7
Joined: Mon Feb 27, 2017 11:21 pm

Re: HOWTO: using more recent WIFI firmware

Sat Jun 19, 2021 10:07 am

kerry_s wrote:
Sat Jun 19, 2021 9:56 am
Debian/Raspberry Pi OS is very conservative with its choice of firmware drivers (terribly obsolete). Some bugs may be resolved in more recent firmware.
they use the stable branch.
your installing from the unstable branch(sid), that branch is for testing purposes.
That's the point: provide instructions how to try more recent firmware. It may help with some bugs like wifi becoming unresponsive when running for days or under heavy traffic.
I've yet to note improvements with this year's firmware (March 30 2021) for rpi0w/3b, using the following files:

Code: Select all

$ cd /lib/firmware/brcm
$ ls -lr *mac43430*
-rw-r--r-- 1 root root 421158 Feb 17  2020 cyfmac43430-sdio_v7.45.98.97_ucode1043.2137.bin
-rw-r--r-- 1 root root   4733 Jun  1  2020 cyfmac43430-sdio.clm_blob
-rw-r--r-- 1 root root    870 Jul 26  2020 brcmfmac43430-sdio.raspberrypi,model-zero-w.txt
-rw-r--r-- 1 root root    873 Jul 26  2020 brcmfmac43430-sdio.raspberrypi,3-model-b.txt
-rw-r--r-- 1 root root   1121 Nov 26  2020 brcmfmac43430-sdio.txt
lrwxrwxrwx 1 root root     44 Jan  1 22:12 brcmfmac43430-sdio.clm_blob -> /lib/firmware/brcm/cyfmac43430-sdio.clm_blob
-rw-r--r-- 1 root root 419798 Jun 19 11:07 cyfmac43430-sdio_v7.45.98.118_ucode1043.2137.bin
lrwxrwxrwx 1 root root     67 Jun 19 11:28 brcmfmac43430-sdio.bin -> /lib/firmware/brcm/cyfmac43430-sdio_v7.45.98.118_ucode1043.2137.bin
$ dmesg |grep -i firmware
[    0.150952] raspberrypi-firmware soc:firmware: Attached to firmware from 2021-05-27T14:04:13, variant start
[    0.160969] raspberrypi-firmware soc:firmware: Firmware hash is 7d9a298cda813f747b51fe17e1e417e7bf5ca94d
[  198.305993] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Mar 30 2021 01:12:21 version 7.45.98.118 (7d96287 CY) FWID 01-32059766

thatchunkylad198966
Posts: 576
Joined: Thu Jul 04, 2019 10:21 am
Location: UK, Birmingham

Re: HOWTO: using more recent WIFI firmware

Sun Jun 20, 2021 7:55 am

kerry_s wrote:
Sat Jun 19, 2021 9:56 am
Debian/Raspberry Pi OS is very conservative with its choice of firmware drivers (terribly obsolete). Some bugs may be resolved in more recent firmware.
they use the stable branch.
your installing from the unstable branch(sid), that branch is for testing purposes.
A thanks would've been nice, too.
Thanks OP, I don't have the need for this tut but I'm sure someone will find it helpful.
[NEW] Ubuntu - CM4/RPi4B custom image(s)! XFCE4, LXQt, i3-WM, WireGuard, Samba, Kodi, Latest MESA graphics drivers!

Code: Select all

https://www.raspberrypi.org/forums/viewtopic.php?f=131&t=314419

pyavitz
Posts: 20
Joined: Thu Aug 09, 2018 7:23 pm
Location: Earth
Contact: Website

Re: HOWTO: using more recent WIFI firmware

Mon Jun 21, 2021 4:07 am

There is no reason to purge the old firmware to test the new, as the kernel its self has default search paths.

So for example you could

Code: Select all

sudo mkdir -p /lib/firmware/updates/brcm
and add said firmware to the directory and reboot.

If you really wanted to be specific, you could add the following to the cmdline:

Code: Select all

 firmware_class.path=/lib/firmware/updates/brcm

twojstary
Posts: 7
Joined: Mon Feb 27, 2017 11:21 pm

Re: HOWTO: using more recent WIFI firmware

Thu Jul 01, 2021 12:32 pm

pyavitz wrote:
Mon Jun 21, 2021 4:07 am
There is no reason to purge the old firmware to test the new, as the kernel its self has default search paths.

So for example you could

Code: Select all

sudo mkdir -p /lib/firmware/updates/brcm
and add said firmware to the directory and reboot.

If you really wanted to be specific, you could add the following to the cmdline:

Code: Select all

 firmware_class.path=/lib/firmware/updates/brcm
Thanks though the specifics of how the parameter work isn't documented.

1) How the kernel picks firmware from one directory over the defaults based on some an internal set of priorities. Would the old firmware path still be valid?
2) The firmware files need to have appropriate names or they won't load at all.
3) Risk of inadvertently disabling other firmware as a side-effect when using the option.

Purging dated firmware has the benefit of avoiding both of these. Renaming the directory would work just as well, if purging doesn't suit you.

Having had the firmware on for several days, I haven't seen any noticable side-effects. It is reporting 'Tx excessive retries' as the old one though no missed ARP replies recorded yet. The unresponded ARP replies is what originally prompted me to seek alternative to the dated broadcom firmware.

Return to “Raspberry Pi OS”