Get onboard Raspberry Pi CM4 WiFi module working
geerlingguy opened this issue · comments
I just noticed when I went to use the router as an AP... I don't have a WiFi wlan0
interface! Nothing shows up in LuCI nor in the CLI
root@OpenWrt:~# uci show wireless
uci: Entry not found
I can't set up WiFi in OpenWRT at all (set a country code or anything) if I don't even have a WiFi interface...
The chip in the CM4 is a Cypress CYW43455.
One thing I haven't considered is using the OpenWRT Image Builder instead of custom compiling the image... not sure if there's a benefit to that.
root@OpenWrt:~# iw reg get
global
country 00: DFS-UNSET
(755 - 928 @ 2), (N/A, 20), (N/A), PASSIVE-SCAN
(2402 - 2472 @ 40), (N/A, 20), (N/A)
(2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, PASSIVE-SCAN
(2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, PASSIVE-SCAN
(5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW
(5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, PASSIVE-SCAN
(5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, PASSIVE-SCAN
(5735 - 5835 @ 80), (N/A, 20), (N/A), PASSIVE-SCAN
(57240 - 63720 @ 2160), (N/A, 0), (N/A)
root@OpenWrt:~# wifi status
{
}
root@OpenWrt:~# uci show wireless
root@OpenWrt:~#
lol... I just found this issue about WiFi not working on the CM4 in OpenWRT... and guess who's already commented in there?
Yep. Me.
But it looks like that's not the issue; here's my fresh install:
root@OpenWrt:/lib/firmware/brcm# ls
brcmfmac43143.bin brcmfmac43455-sdio.clm_blob
brcmfmac43236b.bin brcmfmac43455-sdio.raspberrypi,4-compute-module.txt
brcmfmac43455-sdio.bin brcmfmac43455-sdio.raspberrypi,4-model-b.txt
I am seeing the following in dmesg:
[ 6.307836] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43456-sdio.raspberrypi,4-compute-module.bin failed with error -2
[ 6.320167] brcmfmac mmc1:0001:1: Falling back to sysfs fallback for: brcm/brcmfmac43456-sdio.raspberrypi,4-compute-module.bin
[ 7.887907] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43456-sdio.bin failed with error -2
[ 7.897693] brcmfmac mmc1:0001:1: Falling back to sysfs fallback for: brcm/brcmfmac43456-sdio.bin
[ 11.367451] usbcore: registered new interface driver brcmfmac
[ 12.378410] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50
Oh... it's looking for brcm/brcmfmac43456-sdio
. The file in the filesystem is brcmfmac43455-sdio.raspberrypi,4-compute-module.txt
.
Attempted fix:
cd /lib/firmware/brcm
cp brcmfmac43455-sdio.raspberrypi,4-compute-module.txt brcmfmac43456-sdio.raspberrypi,4-compute-module.txt
After a reboot, everything's the same :(
Testing a new image build with:
diff --git a/package/firmware/cypress-nvram/Makefile b/package/firmware/cypress-nvram/Makefile
index f8b45fbef2..62345b469a 100644
--- a/package/firmware/cypress-nvram/Makefile
+++ b/package/firmware/cypress-nvram/Makefile
@@ -103,6 +103,9 @@ define Package/cypress-nvram-43455-sdio-rpi-4b/install
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/brcmfmac43455-sdio.raspberrypi,4-model-b.txt \
$(1)/lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-compute-module.txt
+ $(INSTALL_DATA) \
+ $(PKG_BUILD_DIR)/brcmfmac43455-sdio.raspberrypi,4-model-b.txt \
+ $(1)/lib/firmware/brcm/brcmfmac43456-sdio.raspberrypi,4-compute-module.txt
endef
$(eval $(call BuildPackage,cypress-nvram-43455-sdio-rpi-4b))
Edit: That didn't work. Caused compile error. I think that's barking up the wrong tree anyways.
Huh. It looks like some CM4 models might come with Cypress 43455. Some with Cypress 43456—though I thought only the Pi 400 came with the 43456...?
Related:
- Pi Forum topic: BCM43456 (Pi 400) WiFi feedback thread
- Linux firmware patch (not yet merged): https://lore.kernel.org/linux-firmware/20210117074817.1721-2-alistair@alistair23.me/
- Pi Forum topic: CYW43455 (3B+, 4B, CM4) WiFi feedback thread (this comment seems to indicate the CM4 might not match what the datasheet says...? And this comment indicates the firmware is stored in https://github.com/RPi-Distro/firmware-nonfree/)
Opened an issue in the Pi Forums: Do some Compute Module 4s use the Cypress 43456 WiFi chip?
What a tangled web we weave... going to also boot Pi OS and see what happens there. Maybe it's an OpenWRT issue.
WiFi is working in Pi OS:
pi@waveshare:~ $ dmesg | grep brcmfmac
[ 8.397884] brcmfmac: F1 signature read @0x18000000=0x15294345
[ 8.408768] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43456-sdio for chip BCM4345/9
[ 8.410016] usbcore: registered new interface driver brcmfmac
[ 8.411611] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43456-sdio.raspberrypi,4-compute-module.bin failed with error -2
[ 8.631519] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43456-sdio for chip BCM4345/9
[ 8.631690] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43456-sdio for chip BCM4345/9
[ 8.645283] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4345/9 wl0: May 14 2020 17:26:08 version 7.84.17.1 (r871554) FWID 01-3d9e1d87
[ 14.099173] brcmfmac: brcmf_cfg80211_set_power_mgmt: power save enabled
If I boot into Pi OS, the firmware directory contains:
$ ls /lib/firmware/brcm/brcmfmac43456*
/lib/firmware/brcm/brcmfmac43456-sdio.bin
/lib/firmware/brcm/brcmfmac43456-sdio.clm_blob
/lib/firmware/brcm/brcmfmac43456-sdio.txt
So maybe if I just copy those files over to the build, it should work... going to try that out next.
I copied the three files into the files
directory in my OpenWRT buildroot:
build@7ab894427b56:/build/openwrt$ ls files/lib/firmware/brcm/
brcmfmac43456-sdio.bin brcmfmac43456-sdio.clm_blob brcmfmac43456-sdio.txt
And I'm rebuilding the image...
Would you look at that!
root@OpenWrt:~# wifi status
{
"radio0": {
"up": false,
"pending": false,
"autostart": true,
"disabled": true,
"retry_setup_failed": false,
"config": {
"path": "platform/soc/fe300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1",
"channel": "36",
"band": "5g",
"htmode": "VHT80",
"disabled": true
},
"interfaces": [
{
"section": "default_radio0",
"config": {
"mode": "ap",
"ssid": "OpenWrt",
"encryption": "none",
"network": [
"lan"
],
"mode": "ap"
},
"vlans": [
],
"stations": [
]
}
]
}
}
And:
root@OpenWrt:~# dmesg | grep brcmfmac
[ 6.452131] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43456-sdio for chip BCM4345/9
[ 6.463485] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43456-sdio.raspberrypi,4-compute-module.bin failed with error -2
[ 6.477449] brcmfmac mmc1:0001:1: Falling back to sysfs fallback for: brcm/brcmfmac43456-sdio.raspberrypi,4-compute-module.bin
[ 8.059987] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43456-sdio.raspberrypi,4-compute-module.txt failed with error -2
[ 8.074325] brcmfmac mmc1:0001:1: Falling back to sysfs fallback for: brcm/brcmfmac43456-sdio.raspberrypi,4-compute-module.txt
[ 8.273493] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43456-sdio for chip BCM4345/9
[ 8.291811] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4345/9 wl0: May 14 2020 17:26:08 version 7.84.17.1 (r871554) FWID 01-3d9e1d87
[ 8.336672] usbcore: registered new interface driver brcmfmac
So I'll wait to hear back on WiFi doesn’t work on Raspberry Pi CM4 with Cypress 43456 before closing out this issue. It would be nice to get this fixed upstream instead of relying on copying stuff into the files
directory in buildroot.
So far I'm not able to connect to the OpenWrt
SSID I set up on the router from my Mac (I saw it in the AirPort menu but it disappeared when I tried connecting). Maybe a signal issue, not sure. I'm using an external antenna, but I don't think I set the config.txt option to use the external antenna: Enable the external antenna connector on the Raspberry Pi Compute Module 4.
Some other tests performed now that I have WiFi working...
iperf3 speed test using WiFi between Mac and the router:
$ iperf3 -c 192.168.1.1
Connecting to host 192.168.1.1, port 5201
[ 5] local 192.168.1.199 port 57152 connected to 192.168.1.1 port 5201
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 9.85 MBytes 82.6 Mbits/sec
[ 5] 1.00-2.00 sec 10.4 MBytes 87.5 Mbits/sec
[ 5] 2.00-3.00 sec 10.2 MBytes 85.6 Mbits/sec
[ 5] 3.00-4.00 sec 10.4 MBytes 87.3 Mbits/sec
[ 5] 4.00-5.00 sec 9.97 MBytes 83.6 Mbits/sec
[ 5] 5.00-6.00 sec 10.2 MBytes 85.8 Mbits/sec
[ 5] 6.00-7.00 sec 9.97 MBytes 83.6 Mbits/sec
[ 5] 7.00-8.00 sec 10.6 MBytes 89.1 Mbits/sec
[ 5] 8.00-9.00 sec 10.4 MBytes 87.3 Mbits/sec
[ 5] 9.00-10.00 sec 10.6 MBytes 88.5 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 103 MBytes 86.1 Mbits/sec sender
[ 5] 0.00-10.02 sec 102 MBytes 85.4 Mbits/sec receiver
iperf Done.
Quick speedtest because I don't see a super-quick way to run speedtest-cli
on here:
root@OpenWrt:~# time wget -O /dev/null http://speedtest.tele2.net/10MB.zip
Downloading 'http://speedtest.tele2.net/10MB.zip'
Connecting to 90.130.70.73:80
Writing to '/dev/null'
/dev/null 100% |*******************************| 10240k 0:00:00 ETA
Download completed (10485760 bytes)
real 0m 9.95s
user 0m 0.10s
sys 0m 0.10s
So 1.01 MB/sec, or 8.04 Mbps for that test at least. Still leaving a bit of performance on the table, but signal strength is my big issue:
Status | unlock retries: sim-pin2 (10)
| state: connected
| power state: on
| access tech: lte
| signal quality: 25% (cached)
I can't get the Internet connection from wwan0
to share through to wlan0
, must need to do some extra routing there (I just have the settings for the AP configured under Network > Wireless).
Looks like I should have a go at Dumb AP with OpenWrt.
I use this dongle for faster wifi in my setup.
Alfa Long-Range Dual-Band AC1200 USB 3.0 Wi-Fi Adapter w/ 2X 5dBi External Antennas - 2.4GHz 300Mbps/5GHz 867Mbps - 802.11ac & A, B, G, N - Windows, MacOS & Kali Linux Supported - (AWUS036ACM) https://a.co/d/e2VFUNu
It seems like I had to add the wlan0 interface to the Network > Interfaces section, and put it in the lan
firewall zone, for it to start routing requests through to the WWAN connection. But now I'm hitting issues with connections dropping, and I wonder if it has to do with the APN or some other setting on the modem :(
So heading back over to #1 for the time being.
And I'm rebuilding the image...
Can i get a copy of this build?
Ive spent hours trying to get wifi working and am making little progress.
I'm currently running openwrt-21.02.3-bcm27xx-bcm2711-rpi-4-ext4-factory on the cm4
Attached is a build, it's not official and it's to be considered alpha! It's my latest development build.
It includes:
- openwrt 22.03 from https://github.com/openwrt/openwrt openwrt-22.03 a couple of days ago
- shayne's cm4io-fan patch
- config for pi wlan external antenna
- qmi, mbim, qserial, modemmanager, rtl8152 drivers, minicom
- config hasn't been changed in the image from upstream - except
/boot/config.txt
for the fan and external antenna
It's kinda bare bones and specific to getting this cm4 router going well on the waveshare board.
Thanks for the quick reply!
I installed your build but cant seem to connect to the cm4 at 192.168.1.1 not through browser or ssh.
Any ideas?
I installed your build but cant seem to connect to the cm4 at 192.168.1.1 not through browser or ssh.
You need to be connected to ETH0. The other interface is not yet configured in my build.
It may not be handing out DHCP addresses, set a static ip in the 192.168.1.1/24 range e.g. 192.168.1.20.
Drivers are specifically added for this carrier board, https://www.waveshare.com/cm4-dual-eth-4g-5g-base.htm and the cm4 lite.
I installed your build but cant seem to connect to the cm4 at 192.168.1.1 not through browser or ssh.
You need to be connected to ETH0. The other interface is not yet configured in my build. It may not be handing out DHCP addresses, set a static ip in the 192.168.1.1/24 range e.g. 192.168.1.20. Drivers are specifically added for this carrier board, https://www.waveshare.com/cm4-dual-eth-4g-5g-base.htm and the cm4 lite.
Thanks very much :)
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
jeff can you share you build image mine also internal cm4 wifi is Not working
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.