Skip to content

Instantly share code, notes, and snippets.

@cx-sawyer
Last active June 29, 2023 06:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cx-sawyer/f4f0a6198f738a986acbb71632af446a to your computer and use it in GitHub Desktop.
Save cx-sawyer/f4f0a6198f738a986acbb71632af446a to your computer and use it in GitHub Desktop.
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
@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