daniel-p-carvalho opened a new pull request, #20557:
URL: https://github.com/apache/nuttx/pull/20557
## Summary
Wi-Fi support for the PIC32MZ-W1 (WFI32E01) and the EV49N51A board
(added in #20448, Ethernet in #20524): a `wlan0` network device, station
or Soft-AP, open or WPA2-Personal, configured with `wapi`.
The Wi-Fi MAC and baseband of the PIC32MZ-W1 are driven by Microchip's
closed WLAN library `pic32mzw1.a`, which runs on the CPU itself. This PR
adds the NuttX side: the services the library needs and the network
device. The library itself is **not** added to NuttX (see "Library and
license" below).
Commits:
1. **tools/nxstyle: allow the PIC32MZ-W1 WLAN library callback names.**
See "Why tools/nxstyle" below.
2. **arch/mips/pic32mz: add Wi-Fi support for the PIC32MZ-W1.**
`CONFIG_PIC32MZ_W1_WLAN`: a netdev_upperhalf lower half. The driver
provides the library with memory (a reserved packet pool in the 64 KB
Data Buffer Memory, buffers used uncached through KSEG1), the WID
configuration queues, the RFMAC/RFTM0/RFSMC interrupts, a kernel thread,
and random/hash/HMAC from NuttX crypto. Wireless operations: scan,
essid/bssid, psk, auth, mode (managed/master) and freq. The library uses
the DSP ASE indexed loads, so Status.MX is set at boot when the option
is enabled. Depends on XC32 (see "Toolchain and CI").
3. **boards/mips/pic32mz/ev49n51a: add Wi-Fi support.** Registers `wlan0`
at bring-up, new `ev49n51a:wlan` configuration (NSH, wapi, DHCP client,
ping, telnetd), documentation (Wi-Fi section, library download and
license, station and Soft-AP use, limitations).
## Library and license
`pic32mzw1.a` comes from Microchip's MPLAB Harmony
[wireless_wifi](https://github.com/Microchip-MPLAB-Harmony/wireless_wifi)
repository, under Microchip's license (`Microchip_SLA001.md`), which only
allows its use with Microchip devices and does not allow it to be put
under an open source license. So it is not added to the NuttX tree:
`arch/mips/src/pic32mz/Make.defs` downloads it at build time (pinned to
v3.13.0, from the `context` target, the same way `arch/arm/src/nrf91`
downloads Nordic's `sdk-nrfxlib`), unless a copy is already there, and
`distclean` removes it. A copy with some symbols renamed is linked:
* `checksum`, `aes_key_wrap`, `aes_key_unwrap` clash with NuttX symbols;
* `printf`, `puts`, `putchar` and `__printf_npuxX` (XC32's printf variant)
are routed by the driver to the syslog, only with
`CONFIG_DEBUG_WIRELESS_INFO`, so the library's messages (RF calibration,
MAC state) stay off the console.
All the driver code is new and Apache-2.0. The library interface (callback
names, WID identifiers and message formats, 11i settings, the Soft-AP and
connect sequences) is not documented by Microchip; it was taken from the
Harmony driver sources that ship with the library and is tagged `[EX]` in
the code, with a legend in the file header, as in
`pic32mz_wfi32_pwrclk.c` (#20448). Only interface facts were used; no code
was copied. Data sheet facts are tagged `[DS]`.
## Why tools/nxstyle
The library calls back into the host through 33 functions with fixed
names, all prefixed `DRV_PIC32MZW_` (`DRV_PIC32MZW_MemAlloc`,
`DRV_PIC32MZW_PacketMemFree`, `DRV_PIC32MZW_Crypto_HMAC`,
`DRV_PIC32MZW_MACTimer0Enable`, ...). They are the library's ABI: the
driver must define functions with exactly these names, and nxstyle rejects
them as mixed case identifiers. Commit 1 adds `DRV_PIC32MZW_` to
`g_white_prefix`, as done for other external APIs that cannot be renamed
(Plug&Trust `Se05x`, Micro XRCE-DDS, S2OPC, TinyGL, CPython, Infineon
`Ifx` in arch/tricore).
The alternative would be to rename the 33 callbacks with objcopy too, but
then the driver's names would no longer match Microchip's headers and
documentation, which makes the `[EX]` facts harder to trace. Happy to
switch if reviewers prefer that.
## Toolchain and CI
The library is built with XC32 (microMIPS, soft-float), so
`PIC32MZ_W1_WLAN` depends on `MIPS32_TOOLCHAIN_MICROCHIPL_XC32`. CI builds
all MIPS configurations with Pinguino GCC (`tools/ci/testlist/other.dat`),
so in CI `ev49n51a:wlan` builds without the Wi-Fi driver (the option is
dropped by olddefconfig); the driver itself is only built with XC32.
## Impact
* PIC32MZ-W1 / EV49N51A only; new arch option `PIC32MZ_W1_WLAN` (default
n), new `ev49n51a:wlan` configuration. `pic32mz_head.S` sets Status.MX
only with `CONFIG_PIC32MZ_W1_WLAN`.
* `tools/nxstyle.c`: one more whitelisted prefix.
* Documentation: EV49N51A board page.
* Not in this PR (follow-up): WPA3-Personal (SAE) with the BA414E public
key engine. Enterprise security and station + AP at the same time are
not supported.
## Testing
Hardware built from the EV49N51A design (WFI32E01PE, silicon B0), XC32
v6.00, host Ubuntu Linux x86_64 (Qualcomm QCA6174 Wi-Fi as the test station).
* Boot: the library loads the RF calibration and the MAC address from
OTP, `wlan0` is registered, console clean.
* `wapi scan wlan0`: the access points in range are listed.
* Station, WPA2-Personal (home access point): association and 4-way
handshake, DHCP (`renew wlan0`), ping to the gateway (20/20) and to
8.8.8.8 (5/5), 50 pings of 1400 B from the host with 0% loss, telnet NSH
session from the host.
* Soft-AP, WPA2-Personal, channel 6, with the host as station:
association, station join/leave events, 30 pings of 64 B, 530 pings of
1400 B (500 at 20 ms) with 0% loss, telnet NSH session; AP stop, then
station mode again and reconnection to the home access point.
Build checks: `./tools/checkpatch.sh -g` clean; `refresh.sh` leaves
`ev49n51a:wlan`, `ev49n51a:nsh` and `ev49n51a:netnsh` unchanged;
`ev49n51a:nsh`, `netnsh` and `wlan` build with XC32 (no warnings);
`ev49n51a:wlan` with Pinguino GCC as in CI; pic32mz-starterkit,
chipkit-wifire and flipnclick-pic32mz still build.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]