Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BCM43454/6 kernel driver patch
From 7ee21e611e94186196fc8ac4df1b41ded3e15cf3 Mon Sep 17 00:00:00 2001
From: sawyer <cx@radxa.com>
Date: Fri, 11 Feb 2022 10:39:56 +0800
Subject: [PATCH] brcmfmac: Add BCM43454/6 support
BCM43454/6 is an old variant of BCM4345 and it is exactly identical to
BCM4345/6, except the initial chip id is 0xa9be. After newer firmware
is loaded, the chip id becomes 0x4345. This patch handles the 0xa9be
chips in the same way as BCM4345.
https://gist.github.com/kagurazakakotori/ea952c539109f5b5a78112f47084708b
This patch is provided by kagurazakakotori@gmail.com
---
brcmfmac/Makefile | 4 ++--
brcmfmac/chip.c | 2 ++
brcmfmac/feature.c | 3 ++-
brcmfmac/sdio.c | 1 +
include/brcm_hw_ids.h | 1 +
5 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/brcmfmac/Makefile b/brcmfmac/Makefile
index 9b15bc3..3f13c75 100644
--- a/brcmfmac/Makefile
+++ b/brcmfmac/Makefile
@@ -6,8 +6,8 @@
#
ccflags-y += \
- -I $(srctree)/$(src) \
- -I $(srctree)/$(src)/../include
+ -I $(brcmfmac_src) \
+ -I $(brcmfmac_src)/../include
obj-$(CONFIG_BRCMFMAC) += brcmfmac.o
brcmfmac-objs += \
diff --git a/brcmfmac/chip.c b/brcmfmac/chip.c
index a3a2570..04d70ee 100644
--- a/brcmfmac/chip.c
+++ b/brcmfmac/chip.c
@@ -702,6 +702,7 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
{
switch (ci->pub.chip) {
case BRCM_CC_4345_CHIP_ID:
+ case BRCM_CC_43454_CHIP_ID:
return 0x198000;
case BRCM_CC_4335_CHIP_ID:
case BRCM_CC_4339_CHIP_ID:
@@ -1388,6 +1389,7 @@ bool brcmf_chip_sr_capable(struct brcmf_chip *pub)
case BRCM_CC_4354_CHIP_ID:
case BRCM_CC_4356_CHIP_ID:
case BRCM_CC_4345_CHIP_ID:
+ case BRCM_CC_43454_CHIP_ID:
/* explicitly check SR engine enable bit */
pmu_cc3_mask = BIT(2);
/* fall-through */
diff --git a/brcmfmac/feature.c b/brcmfmac/feature.c
index 0dcefbd..d8a6808 100644
--- a/brcmfmac/feature.c
+++ b/brcmfmac/feature.c
@@ -247,7 +247,8 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)
brcmf_feat_firmware_capabilities(ifp);
memset(&gscan_cfg, 0, sizeof(gscan_cfg));
if (drvr->bus_if->chip != BRCM_CC_43430_CHIP_ID &&
- drvr->bus_if->chip != BRCM_CC_4345_CHIP_ID)
+ drvr->bus_if->chip != BRCM_CC_4345_CHIP_ID &&
+ drvr->bus_if->chip != BRCM_CC_43454_CHIP_ID)
brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN,
"pfn_gscan_cfg",
&gscan_cfg, sizeof(gscan_cfg));
diff --git a/brcmfmac/sdio.c b/brcmfmac/sdio.c
index 3d43e03..354843f 100644
--- a/brcmfmac/sdio.c
+++ b/brcmfmac/sdio.c
@@ -641,6 +641,7 @@ static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = {
BRCMF_FW_ENTRY(BRCM_CC_43430_CHIP_ID, 0xFFFFFFFE, 43430A1),
BRCMF_FW_ENTRY(BRCM_CC_4345_CHIP_ID, 0x00000200, 43456),
BRCMF_FW_ENTRY(BRCM_CC_4345_CHIP_ID, 0xFFFFFDC0, 43455),
+ BRCMF_FW_ENTRY(BRCM_CC_43454_CHIP_ID, 0x00000040, 43455),
BRCMF_FW_ENTRY(BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, 4354),
BRCMF_FW_ENTRY(BRCM_CC_4356_CHIP_ID, 0xFFFFFFFF, 4356),
BRCMF_FW_ENTRY(BRCM_CC_4359_CHIP_ID, 0xFFFFFFFF, 4359),
diff --git a/include/brcm_hw_ids.h b/include/brcm_hw_ids.h
index c6c4be0..182808c 100644
--- a/include/brcm_hw_ids.h
+++ b/include/brcm_hw_ids.h
@@ -32,6 +32,7 @@
#define BRCM_CC_4339_CHIP_ID 0x4339
#define BRCM_CC_43430_CHIP_ID 43430
#define BRCM_CC_4345_CHIP_ID 0x4345
+#define BRCM_CC_43454_CHIP_ID 43454
#define BRCM_CC_43465_CHIP_ID 43465
#define BRCM_CC_4350_CHIP_ID 0x4350
#define BRCM_CC_43525_CHIP_ID 43525
--
2.25.1
  1. install needed tools
sudo apt-get install -y make gcc dpkg-dev git vim
  1. enable deb-src of kernel module
sudo vi /etc/apt/sources.list
# uncommont deb-src, delete '#'
# change
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# to 
deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates main restricted
  1. download kernel source
sudo apt update && sudo apt-get source linux-image-unsigned-$(uname -r)
# If you see error: "couldn't be accessed by user '_apt'", execute: 
#  sudo chown -R _apt /var/lib/update-notifier/package-data-downloads/partial/
# then try again.
  1. get and apply patch
cd linux-hwe-*/drivers/net/wireless/broadcom/brcm80211
sudo wget https://gist.githubusercontent.com/cx-sawyer/f4f0a6198f738a986acbb71632af446a/raw/ec64af77768d443a8d87954bf094ee6bb55d8d59/0001-brcmfmac-Add-BCM43454-6-support.patch

# maybe some conflict, please add --reject option and edit manually.
sudo git apply 0001-brcmfmac-Add-BCM43454-6-support.patch
  1. make brcmfmac.ko
cd brcmfmac
sudo make -C /lib/modules/$(uname -r)/build M=$(pwd) brcmfmac_src=$(pwd) modules
  1. backup existing brcmfmac.ko and override new one
sudo cp /lib/modules/$(uname -r)/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko  /lib/modules/$(uname -r)/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko.bak
sudo cp brcmfmac.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko
  1. replace nv file and fw files
# Download radxa nvram
sudo wget https://raw.githubusercontent.com/radxa/rkwifibt/master/firmware/broadcom/AP6254/wifi/nvram_ap6254.txt -O "/lib/firmware/brcm/brcmfmac43455-sdio.Radxa-ROCK Pi X.txt"

# Backup existing firmware file
sudo mv /lib/firmware/brcm/brcmfmac43455-sdio.bin /lib/firmware/brcm/brcmfmac43455-sdio.bin.bak
sudo mv /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob.bak

# Download latest 7.45.241 firmware
sudo wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/bullseye/debian/config/brcm80211/cypress/cyfmac43455-sdio.bin -O /lib/firmware/brcm/brcmfmac43455-sdio.bin
sudo wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/bullseye/debian/config/brcm80211/cypress/cyfmac43455-sdio.clm_blob -O /lib/firmware/brcm/brcmfmac43455-sdio.clm_blob
  1. rmmod driver and insmod again
sudo rmmod brcmfmac
sudo insmod /lib/modules/$(uname -r)/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko
@kagurazakakotori
Copy link

I'd like to suggest using the "inbox" firmware (In linux-firmware package) or a newer version of cypress firmware (brcmfmac43455-sdio.bin and brcmfmac43455-sdio.clm_blob). In both cases, only radxa-provided nvram .txt file is needed.

The radxa-provided firmware got some bugs. It will "crossflash" the chip to BCM43455, changing the chip id from 0xa9be to 0x4345 (The chip id can be restored by power cycle/cold reset). And it seems doesn't support the "power management" feature, when the device is idle for some time, it will stop working unless you power cycle the board. The "inbox" or cypress firmware have no such issue, at least in my testing.

The WLAN MAC address is defined in the nvram .txt file. Edit it if you have multiple boards connecting to the same network.

@cx-sawyer
Copy link
Author

@kagurazakakotori I changed step 7. Copied your commands from radxa forum.

@jpswensen
Copy link

Is there any value in providing the community with an tgz with all this done for particular setups? For example, I have a package that was built for a hwe Ubuntu 20.04 installation that also has the .bin and .txt from the Radxa website and a simple script to install everything to the right location and reload the module. I realize that this would likely be outdated the second the kernel version changes, but since it took me a decent amount of time to get to this point, and some RockPiX users will have very little confidence in starting the process of building a kernel module, maybe it is worthwhile?

@Sieger1004
Copy link

Sorry, big noob here
do I understand correctly, that this is a patch that allows you to enable the BCM-43453-support for linux images on the rock pi X? and if yes, how do I do it? I tried to follow all the steps, and for some reasons I had to move the "include-files" to the system path manually, but after that it successfully executed everything. However, the wifi module was still not working. I am probably jusst missing something obvious. If you have time, I'd be glad for some help.

@cx-sawyer
Copy link
Author

do I understand correctly, that this is a patch that allows you to enable the BCM-43453-support for linux images on the rock pi X?

No, It's BCM-43454.

However, the wifi module was still not working. I am probably jusst missing something obvious. If you have time, I'd be glad for some help.

It will be helpful if you can attach terminal output to this topic

@Sieger1004
Copy link

I posted my terminal output on the forum

@LiukDiihMieu
Copy link

Following this tutorial I indeed solved the no Wi-Fi problem with AP6254, but for a normal Linux user who is not a professional developer, I found this procedure quite challenging. It would be better if the manufacturer can pack these trivialities altogether.

@wahoonie76
Copy link

Is there a way to install the driver on a debian 11 system?

@alphafox02
Copy link

On the latest 20.04 Ubuntu HWE just released 5.15 based kernel, it still doesn’t find the WiFi when the stock WiFi files provided on the Radix site are dumped in brcm. I’ll try this solution as I’d like to provide WiFi support for the rock pi x right out of the box when DragonOS Focal (20.04 SDR based distro) is loaded as the OS.

@jasperchua99
Copy link

any updates on this? seam to be not working for me

@LiukDiihMieu
Copy link

sudo wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/bullseye/debian/config/brcm80211/cypress/cyfmac43455-sdio.bin -O /lib/firmware/brcm/brcmfmac43455-sdio.bin

receives 404 Not Found now.

@LiukDiihMieu
Copy link

looks like it has been renamed as cyfmac43455-sdio-standard.bin

@jasperchua99
Copy link

@LiukDiihMieu do provide an update on this, im also unable to update it well

@kagurazakakotori
Copy link

kagurazakakotori commented Sep 20, 2022

@LiukDiihMieu @jasperchua99 You may try this cypress cyfmac43455 firmware blob from linux-firmware

https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/cypress/cyfmac43455-sdio.bin
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/cypress/cyfmac43455-sdio.clm_blob

If you have linux-firmware package installed on your system, these files are also available at /lib/firmware/cypress, both coping it or creating symlink works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment