Skip to content

drivers: wifi: add Bouffalo Lab BL61x WiFi driver#109435

Open
will-tm wants to merge 8 commits into
zephyrproject-rtos:mainfrom
will-tm:feature/bl61x-wifi
Open

drivers: wifi: add Bouffalo Lab BL61x WiFi driver#109435
will-tm wants to merge 8 commits into
zephyrproject-rtos:mainfrom
will-tm:feature/bl61x-wifi

Conversation

@will-tm
Copy link
Copy Markdown
Contributor

@will-tm will-tm commented May 19, 2026

Summary

Add WiFi support for the Bouffalo Lab BL616/BL618 SoC family.

The driver interfaces with the vendor macsw binary blob through the wl80211 layer and implements the Zephyr wifi_mgmt API:

  • Station mode: connect, disconnect, scan (WPA2-PSK, WPA3-SAE)
  • AP mode: start/stop with WPA2-PSK
  • WPA supplicant integration via hostap (including SAE external auth)
  • MACSW variant selection: default, bridge, ack, coex

Supported station security types:

  • WPA2-PSK (AES/CCMP)
  • WPA2-PSK mixed (TKIP+AES)
  • WPA2-PSK-SHA256
  • WPA3-Personal (SAE)
  • WPA2/WPA3 transition mode
  • WEP (WEP-40/WEP-104)
  • Open (no security)

Supported access point security types:

  • WPA2-PSK (AES/CCMP)
  • Open (no security)

Authentication is handled by the upstream hostap/wpa_supplicant subsystem (WIFI_NM_WPA_SUPPLICANT), not the vendor fork. The driver implements zep_wpa_supp_dev_ops to bridge hostap with the vendor MAC layer. This required a lot of reverse engineering and glue which I tried to comment as much as possible.

To facilitate WiFi RAM requirements, legacy ITCM relocations have been moved to RAM, this we be cleaned once rebased on #107223.

Test plan

  • Build for ai_m61_32s_kit, ai_m62_12f_kit, bl618g0, maix_m0s_dock
  • wifi scan
  • wifi connect -s <ssid> -p <passphrase> -k <key type>
  • wifi status
  • net iface
  • net dhcpv4 client start 1 (should be automatic)
  • net ping to gateway and external host
  • AP mode start/stop
  • BLE still functional alongside WiFi (coex)

BL61x WiFi blobs architecture

graph TB
    subgraph Zephyr["Zephyr"]
        APP["Application"]
        MGMT["wifi_mgmt · net_if · net_pkt"]
    end

    WPA["hostap<br/>WPA supplicant · SAE · 4WHS"]

    DRV["WiFi Driver<br/>drivers/wifi/bflb/bl61x/"]

    PORT["Shim<br>wl80211_port.c<br/>blob → driver callbacks"]

    PLAT["Platform — soc/bflb/bl61x/wifi/<br/>wifi_task · IRQ · clock"]

    subgraph Blobs["Binary Blobs"]
        WL80211[/"<b>libwl80211</b><br/>Upper MAC<br/>scan · connect · 802.11 SM"/]
        MACSW[/"<b>libmacsw</b><br/>Lower MAC<br/>TX/RX · DMA · FW event loop<br/><i>default │ bridge │ ack │ coex</i>"/]
        PHYRF[/"<b>libbl616_phyrf</b><br/>PHY · RF calibration<br/><i>shared with BLE</i>"/]
    end

    HW["BL616 WiFi MAC + RF"]

    APP --> MGMT
    MGMT --> DRV
    WPA -- "driver_ops" --> DRV
    DRV -- "events" --> WPA
    DRV -- "wl80211_cntrl · wl80211_mac_*" --> WL80211
    WL80211 -- "wpa_cbs" --> PORT
    PORT -- "eapol_input" --> DRV
    WL80211 -- "ke_msg · MAC ops" --> MACSW
    MACSW -- "task suspend/resume · IRQ" --> PLAT
    PLAT -- "wifi_main · interrupt0_handler" --> MACSW
    MACSW --> PHYRF
    MACSW & PHYRF --> HW

    classDef zephyr fill:#2563eb,color:#fff,stroke:#1d4ed8
    classDef driver fill:#7c3aed,color:#fff,stroke:#6d28d9
    classDef hostap fill:#059669,color:#fff,stroke:#047857
    classDef shim fill:#d97706,color:#fff,stroke:#b45309
    classDef plat fill:#dc2626,color:#fff,stroke:#b91c1c
    classDef blob fill:#4b5563,color:#fff,stroke:#374151
    classDef hw fill:#1f2937,color:#fff,stroke:#111827

    class APP,MGMT zephyr
    class DRV driver
    class WPA hostap
    class PORT shim
    class PLAT plat
    class WL80211,MACSW,PHYRF blob
    class HW hw
Loading

@will-tm will-tm requested review from VynDragon and josuah May 19, 2026 21:50
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_bouffalolab zephyrproject-rtos/hal_bouffalolab@6f8ee38 (main) zephyrproject-rtos/hal_bouffalolab#22 zephyrproject-rtos/hal_bouffalolab#22/files

Additional metadata changed:

Name URL Submodules West cmds module.yml Blobs
hal_bouffalolab 1x ✏, 9x 🆕

DNM label due to: 1 project with PR revision, 1 project with metadata changes and 10 blob changes

Note: This message is automatically posted and updated by the Manifest GitHub Action.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds WiFi support for Bouffalo Lab BL616/BL618-based boards by introducing a new drivers/wifi/bflb driver that interfaces with the vendor WL80211/MACSW blobs (via a shim layer) and integrates with Zephyr’s wifi_mgmt + wifi_nm (hostap/wpa_supplicant) infrastructure. The PR also adjusts BL61x SoC/DT memory layout to reserve WiFi shared RAM, wires up blob linking/selection, and introduces build-only test coverage variants.

Changes:

  • Add BL61x WiFi driver implementation (STA/AP/scan + hostap bridge) under drivers/wifi/bflb/bl61x/.
  • Add BL61x WiFi platform + linker section support in soc/bflb/bl61x/ and a HAL shim for required blob entry points.
  • Enable WiFi device nodes and memory overlays for several BL61x boards; add build-only tests for multiple MACSW variants.

Reviewed changes

Copilot reviewed 52 out of 52 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
west.yml Updates hal_bouffalolab module revision (currently set to a PR ref).
tests/net/wifi/wifi_nm/testcase.yaml Excludes additional BL61x boards from wifi_nm tests due to blob build requirements.
tests/drivers/wifi/bflb/testcase.yaml Adds build-only test matrix for the new BFLB WiFi driver and MACSW variants.
tests/drivers/wifi/bflb/src/main.c Minimal build-only test application entry point.
tests/drivers/wifi/bflb/prj.conf Test config enabling WiFi + networking stack for build coverage.
tests/drivers/wifi/bflb/CMakeLists.txt Test CMake wiring for the build-only application.
soc/bflb/bl61x/wifi/bflb_wl80211_platform.c Implements WL80211 platform hooks (MAC, heap, country, time, randomness).
soc/bflb/bl61x/wifi/bflb_wifi_sections.ld Adds linker sections for WiFi shared RAM and blob version section placement.
soc/bflb/bl61x/wifi/bflb_wifi_platform.c Implements MACSW task/thread + IRQ plumbing and low-power stubs.
soc/bflb/bl61x/Kconfig Adds BL61x PHY/RF retention memory sizing option for BLE/WiFi.
soc/bflb/bl61x/CMakeLists.txt Adds WiFi platform sources/linker sections and linker options when WiFi is enabled.
soc/bflb/bl61x/bflb_rf.c Extends RF init and adds RF TLV parsing/loading support shared by BLE/WiFi.
modules/hal_bouffalolab/src/bl61x/CMakeLists.txt Selects and links WiFi blob libraries (wl80211/macsw variants) and shared phyrf blob.
modules/hal_bouffalolab/shim/wifi/wl80211_rtos_port.c Provides RTOS abstraction layer required by the WiFi blobs.
modules/hal_bouffalolab/shim/wifi/wl80211_port.c Provides supplicant bridge symbols and assoc-IE/hostap-private glue for blobs.
modules/hal_bouffalolab/shim/wifi/CMakeLists.txt Builds WiFi shim sources and no-blob stubs conditionally.
modules/hal_bouffalolab/shim/wifi/blob_stubs.c Link-time stubs for CONFIG_BUILD_ONLY_NO_BLOBS=y builds.
modules/hal_bouffalolab/shim/CMakeLists.txt Adds shim WiFi subdirectory when WiFi is enabled.
modules/hal_bouffalolab/Kconfig Introduces BFLB_WL80211_SHIM Kconfig symbol for the WiFi blob shim.
modules/hal_bouffalolab/CMakeLists.txt Ensures shim subtree is included when CONFIG_BFLB_WIFI is enabled.
dts/riscv/bflb/bl61x.dtsi Adds BL61x WiFi device node and adjusts SRAM region compatibility.
dts/riscv/bflb/bl61x_em_32kb_wifi.dtsi New DT snippet to carve WRAM for WiFi shared RAM and reduce sram1 size.
dts/bindings/wifi/bflb,bl61x-wifi.yaml New devicetree binding for the BL61x WiFi MAC.
drivers/wifi/Kconfig Wires the new BFLB WiFi Kconfig into the WiFi driver menu.
drivers/wifi/CMakeLists.txt Adds BFLB WiFi driver subdirectory to the WiFi build.
drivers/wifi/bflb/Kconfig.bflb_wifi Adds top-level BFLB WiFi enable option and common selects.
drivers/wifi/bflb/CMakeLists.txt Adds include paths and BL61x subdir for the BFLB WiFi driver.
drivers/wifi/bflb/bl61x/Kconfig Adds BL61x WiFi tuning options (MACSW variant, BA params, task settings, etc.).
drivers/wifi/bflb/bl61x/CMakeLists.txt Adds BL61x driver sources (net/mgmt/scan/ap/wpa bridge).
drivers/wifi/bflb/bl61x/bflb_wifi.h Defines driver device context and shared declarations.
drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.h Defines hostap bridge context and ops declarations.
drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c Implements zep_wpa_supp_dev_ops bridge and SAE external-auth handling.
drivers/wifi/bflb/bl61x/bflb_wifi_scan.h Declares scan and beacon/RSN cache helpers.
drivers/wifi/bflb/bl61x/bflb_wifi_scan.c Implements scan result conversion and RSN/RSNXE/privacy caching.
drivers/wifi/bflb/bl61x/bflb_wifi_net.h Declares event posting entry point used by the blob layer.
drivers/wifi/bflb/bl61x/bflb_wifi_net.c Implements net_if offload driver, TX/RX paths, event dispatch, EAPOL handling.
drivers/wifi/bflb/bl61x/bflb_wifi_mgmt.h Declares wifi_mgmt_ops table.
drivers/wifi/bflb/bl61x/bflb_wifi_mgmt.c Implements wifi management APIs: scan/status/reg-domain/version/ps/mode/channel.
drivers/wifi/bflb/bl61x/bflb_wifi_ie.h Provides small helpers for RSN/WPA IE serialization.
drivers/wifi/bflb/bl61x/bflb_wifi_blob_api.h Centralizes extern declarations for blob-facing symbols and callbacks.
drivers/wifi/bflb/bl61x/bflb_wifi_ap.h Declares AP bridge and hostapd ops (guarded by AP config).
drivers/wifi/bflb/bl61x/bflb_wifi_ap.c Implements AP mode bridge + hostapd-related operations.
drivers/bluetooth/hci/Kconfig.bflb Removes duplicated BL61x RF retention memory option (moved to SoC Kconfig).
boards/sipeed/maix_m0s_dock/maix_m0s.dtsi Enables WiFi node and switches to WiFi-capable WRAM partition DT snippet.
boards/sipeed/maix_m0s_dock/maix_m0s_dock.yaml Updates board supported features and test ignore tags (netif:wifi).
boards/bflb/bl61x/bl618g0/bl618g0.dts Enables WiFi node and switches to WiFi-capable WRAM partition DT snippet.
boards/bflb/bl61x/bl618g0/bl618g0.yaml Updates board supported features and test ignore tags (netif:wifi).
boards/aithinker/ai_m62_12f_kit/ai_m62_12f.dtsi Enables WiFi node and switches to WiFi-capable WRAM partition DT snippet.
boards/aithinker/ai_m62_12f_kit/ai_m62_12f_kit.yaml Updates board supported features and test ignore tags (netif:wifi).
boards/aithinker/ai_m61_32s_kit/ai_m61_32s.dtsi Enables WiFi node and switches to WiFi-capable WRAM partition DT snippet.
boards/aithinker/ai_m61_32s_kit/ai_m61_32s_kit.yaml Updates board supported features and test ignore tags (netif:wifi).
boards/qcom/qcc744m_evk/qcc744m.dtsi Removes zephyr,itcm chosen entry consistent with BL61x ITCM usage changes.

Comment thread west.yml
Comment thread soc/bflb/bl61x/bflb_rf.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_net.c
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_net.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c Outdated
Comment thread soc/bflb/bl61x/CMakeLists.txt
@will-tm will-tm force-pushed the feature/bl61x-wifi branch from 398c0d9 to e2fa07d Compare May 25, 2026 14:55
@zephyrbot zephyrbot requested review from alwa-nordic and jhedberg May 25, 2026 14:57
@will-tm will-tm force-pushed the feature/bl61x-wifi branch from e2fa07d to d8f0aee Compare May 26, 2026 23:07
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_ap.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_ap.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_ap.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_net.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_net.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c Outdated
Comment thread modules/hal_bouffalolab/shim/wifi/blob_stubs.c
Comment thread soc/bflb/bl61x/wifi/bflb_wifi_platform.c Outdated
Comment thread soc/bflb/bl61x/bflb_rf.c
Comment thread soc/bflb/bl61x/bflb_rf.c Outdated
Comment thread soc/bflb/bl61x/CMakeLists.txt
jukkar
jukkar previously approved these changes Jun 1, 2026
Copy link
Copy Markdown
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few random things for me who is unaware of all the working of WiFi.

Thank you again for all the work!

Comment thread boards/aithinker/ai_m61_32s_kit/ai_m61_32s.dtsi
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_ap.c
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c Outdated
Comment thread drivers/wifi/bflb/Kconfig.bflb_wifi
Comment thread dts/bindings/wifi/bflb,bl61x-wifi.yaml
Comment thread tests/drivers/wifi/bflb/testcase.yaml
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c Outdated
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c
Comment thread drivers/wifi/bflb/bl61x/bflb_wifi_wpa_supp.c
@josuah
Copy link
Copy Markdown
Contributor

josuah commented Jun 2, 2026

Just confirming that it still works on a ai_m61_32s module:

uart:~$ wifi scan
Scan requested

Num  | SSID                             (len) | Chan (Band)   | RSSI | Security             | BSSID             | MFP     
1    | Freebox-66B335                   14    | 11   (2.4GHz) | -60  | WPA2-PSK             | 22:66:CF:AC:CD:64 | Disable 
2    | Home                             4     | 10   (2.4GHz) | -93  | WPA2-PSK             | 28:EE:52:62:7C:90 | Disable 
3    | Bbox-0724C354                    13    | 11   (2.4GHz) | -46  | WPA2-PSK             | D6:18:47:A3:99:7F | Disable 
Scan request done
uart:~$ wifi connect -k 1 -s Bbox-0724C354 -p hunter2
Connection requested
uart:~$ 
Connected
[00:01:52.714,682] <inf> net_dhcpv4: Received: 10.12.156.3
uart:~$ net ping 10.12.156.3
PING 10.12.156.3
28 bytes from 10.12.156.3 to 10.12.156.3: icmp_seq=1 ttl=64 time=0.55 ms
28 bytes from 10.12.156.3 to 10.12.156.3: icmp_seq=2 ttl=64 time=0.39 ms
28 bytes from 10.12.156.3 to 10.12.156.3: icmp_seq=3 ttl=64 time=0.39 ms
uart:~$ 

@jukkar
Copy link
Copy Markdown
Member

jukkar commented Jun 3, 2026

[00:01:52.714,682] net_dhcpv4: Received: 10.12.156.3
uart:~$ net ping 10.12.156.3
PING 10.12.156.3
28 bytes from 10.12.156.3 to 10.12.156.3: icmp_seq=1 ttl=64 time=0.55 ms

@josuah Note that this will ping your local machine and the packets will not leave the host

@josuah
Copy link
Copy Markdown
Contributor

josuah commented Jun 3, 2026

this is embarrassing... I pasted the wrong snippet.

My ISP filters IPv4 ping somehow, so in the meantime, just pinging the gateway:

uart:~$ net route check 1.1.1.1
IPv4 route to 1.1.1.1 is via 10.12.156.161 (interface 1)
uart:~$ net ping 10.12.156.161
PING 10.12.156.161
28 bytes from 10.12.156.161 to 10.12.156.3: icmp_seq=1 ttl=64 time=8.32 ms
28 bytes from 10.12.156.161 to 10.12.156.3: icmp_seq=2 ttl=64 time=6.36 ms
28 bytes from 10.12.156.161 to 10.12.156.3: icmp_seq=3 ttl=64 time=81.20 ms

josuah
josuah previously approved these changes Jun 3, 2026
will-tm added 8 commits June 3, 2026 10:24
Replace the ITCM memory region with plain RAM for code relocation.
The sram1 region no longer needs a dedicated "ITCM" identity since
WiFi firmware will reclaim part of that address space. Using the
generic RAM relocation target keeps the same XIP-avoidance behavior
while freeing sram1 for flexible partitioning.

Remove the zephyr,itcm chosen node from all bl61x and qcc744m boards.

Signed-off-by: William Markezana <william.markezana@gmail.com>
Add the wifi0 node for the BL61x WiFi MAC peripheral at 0x24b08000
with its devicetree binding.

Introduce bl61x_em_32kb_wifi.dtsi which carves 128 KB from WRAM for
WiFi MAC shared structures (TX/RX descriptors, IPC) via the
non-cached bus-remap alias, and scales sram1 down to 32 KB.

Signed-off-by: William Markezana <william.markezana@gmail.com>
Switch bl61x board DTS includes from bl61x_em_32kb.dtsi to
bl61x_em_32kb_wifi.dtsi to reserve the WiFi shared-memory region,
and enable the wifi0 node on all bl61x-based boards.

Signed-off-by: William Markezana <william.markezana@gmail.com>
Extend bflb_rf_init() to support WiFi mode (WL_API_MODE_ALL) with
TX power targets and country code configuration when CONFIG_BFLB_WIFI
is enabled.

Add WiFi platform glue: MAC ISR wiring, task creation, low-power
stubs, wl80211 RTOS primitives (heap, RNG, timers), and the linker
section for WiFi shared RAM.

Introduce CONFIG_BFLB_BL61X_WL_RMEM_SIZE for PHY/RF retention memory
sizing.

Signed-off-by: William Markezana <william.markezana@gmail.com>
Add wl80211 RTOS shim (semaphores, mutexes, timers, lock/unlock) and
supplicant bridge for the macsw blob.

Refactor bl61x blob linkage: share libbl616_phyrf.a between BLE and
WiFi, add MACSW variant selection (default/bridge/ack/coex), and link
wl80211 and macsw libraries when CONFIG_BFLB_WIFI is enabled.

Signed-off-by: William Markezana <william.markezana@gmail.com>
Add a native Zephyr WiFi driver for the BL616/BL618 SoC family.

The driver interfaces with the vendor macsw blob through wl80211 and
implements the Zephyr wifi_mgmt API for station connect/disconnect,
scanning, and AP mode. WPA supplicant integration is provided via
the hostap subsystem.

Signed-off-by: William Markezana <william.markezana@gmail.com>
Point hal_bouffalolab to pull/22/head which includes the WiFi MAC
software blobs (macsw, wl80211, phyrf) needed by the BL61x WiFi
driver.

Signed-off-by: William Markezana <william.markezana@gmail.com>
Add build-only test suite covering MACSW firmware variants (default,
bridge, ack, coex) and AP mode for all BL61x WiFi-capable boards.

Signed-off-by: William Markezana <william.markezana@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

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

Labels

area: Bluetooth HCI Bluetooth HCI Driver area: Bluetooth area: Boards/SoCs area: Devicetree Binding PR modifies or adds a Device Tree binding area: Networking area: RISCV RISCV Architecture (32-bit & 64-bit) area: Tests Issues related to a particular existing or missing test area: Wi-Fi Wi-Fi Binary Blobs Added Binary Blobs Modified DNM (manifest) This PR should not be merged (controlled by action-manifest) manifest manifest-hal_bouffalolab platform: Bouffalo Lab

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants