This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 68f238b22b2dbcaaa76a4c513c3fdf7a9c43484d Author: Daniel P. Carvalho <[email protected]> AuthorDate: Fri Oct 9 08:52:42 2026 -0300 boards/mips/pic32mz/ev49n51a: add Wi-Fi support. Register the PIC32MZ-W1 wlan0 device at bring-up and add the wlan configuration: NSH with Wi-Fi, wapi, a DHCP client, ping and Telnet. Document the Wi-Fi driver, the library download and its license, and station and Soft-AP use. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Daniel P. Carvalho <[email protected]> --- .../mips/pic32mz/boards/ev49n51a/index.rst | 74 ++++++++++++++++++++-- .../mips/pic32mz/ev49n51a/configs/wlan/defconfig | 66 +++++++++++++++++++ boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c | 12 ++++ 3 files changed, 147 insertions(+), 5 deletions(-) diff --git a/Documentation/platforms/mips/pic32mz/boards/ev49n51a/index.rst b/Documentation/platforms/mips/pic32mz/boards/ev49n51a/index.rst index fea00bea53c..5288fd7b82a 100644 --- a/Documentation/platforms/mips/pic32mz/boards/ev49n51a/index.rst +++ b/Documentation/platforms/mips/pic32mz/boards/ev49n51a/index.rst @@ -24,7 +24,7 @@ Features * MIPS32 M-Class core at 200 MHz * 1 MB program flash, 256 KB data RAM * 40 MHz crystal inside the module - * 2.4 GHz IEEE 802.11 b/g/n Wi-Fi (not supported by NuttX) + * 2.4 GHz IEEE 802.11 b/g/n Wi-Fi * SST26VF032B 32 Mbit (4 MB) SPI serial flash (U202) * LAN8720A 10/100 Ethernet PHY (U301, RMII) with RJ45 connector J301 @@ -46,7 +46,8 @@ GPIO Yes SPI1 Yes SST26VF032B; reads tested only I2C1/I2C2 Build Not tested; no I2C device on board Ethernet Yes LAN8720A, RMII, 10/100 Mbps -Wi-Fi No +Wi-Fi Yes Station or Soft-AP, WPA2-Personal; + XC32 only, see `Wi-Fi`_ ========================= ======= ==================================== Pin mapping @@ -168,7 +169,8 @@ The port builds with two toolchains: $ export PATH=$PWD/p32/bin:$PATH * ``CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL_XC32``: Microchip MPLAB XC32 for - Linux (tested with v6.00), selected by the ``nsh`` defconfig. + Linux (tested with v6.00), selected by all defconfigs. The ``wlan`` + configuration builds with XC32 only. XC32 v6 and later no longer include device support and need the `PIC32MZ-W Device Family Pack @@ -285,6 +287,24 @@ The example below was taken with ``CONFIG_NETINIT_IPADDR`` set to 3 packets transmitted, 3 received, 0% packet loss, time 3030 ms rtt min/avg/max/mdev = 0.000/0.000/0.000/0.000 ms +wlan +---- + +The ``nsh`` configuration with Wi-Fi instead of Ethernet: the ``wlan0`` +network device, IPv4, TCP, UDP and ICMP, the ``wapi`` and ``ping`` +commands, a DHCP client (``renew``) and a Telnet server. It downloads +Microchip's WLAN library at build time (see `Wi-Fi`_) and builds with XC32 +only. Join a WPA2-Personal network and get an address by DHCP: + +.. code:: console + + nsh> wapi psk wlan0 <passphrase> 3 2 + nsh> wapi essid wlan0 <ssid> 1 + nsh> renew wlan0 + +``3`` selects CCMP and ``2`` WPA2. ``wapi scan wlan0`` lists the access +points in range. + Ethernet ======== @@ -309,10 +329,49 @@ The PIC32MZ-W1 has no factory-programmed Ethernet MAC address. Assign one with ``CONFIG_NETINIT_NOMAC`` or with the ``SIOCSIFHWADDR`` ioctl before the interface is brought up. +Wi-Fi +===== + +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. The NuttX +driver (``CONFIG_PIC32MZ_W1_WLAN``) provides the services the library +needs (memory, interrupts, a kernel thread, hash and HMAC) and registers +the ``wlan0`` network device, configured with ``wapi``. + +The library is not part of NuttX. The build downloads it from the MPLAB +Harmony `wireless_wifi <https://github.com/Microchip-MPLAB-Harmony/wireless_wifi>`_ +repository (v3.13.0, ``driver/pic32mzw1/pic32mzw1.a``) into +``arch/mips/src/pic32mz``, unless a copy is already there, and links a +copy with three symbols renamed that clash with NuttX. The library is +distributed under Microchip's license (``Microchip_SLA001.md`` in that +repository), which only allows its use with Microchip devices. + +The library is built with XC32 (microMIPS, soft-float) and uses the DSP +ASE, so the driver requires XC32 and enables the DSP ASE at boot. It keeps +its reserved packet buffers in the 64 KB Data Buffer Memory at +0x00040000. The MAC address and the RF calibration come from the module's +OTP memory. + +Station mode is the default. To start a Soft-AP instead, select master +mode before the SSID: + +.. code:: console + + nsh> wapi mode wlan0 3 + nsh> wapi psk wlan0 <passphrase> 3 2 + nsh> wapi freq wlan0 6 1 + nsh> wapi essid wlan0 <ssid> 1 + nsh> ifconfig wlan0 10.0.0.1 + +``wapi freq`` sets the channel (1 if not set). Skip ``wapi psk`` for an +open network. ``wapi essid wlan0 "" 0`` stops the AP. A DHCP server for +the stations can be started on ``wlan0`` with the ``dhcpd`` application +(``CONFIG_NETUTILS_DHCPD``). + L1 cache ======== -Both configurations enable the 16 KB instruction and 16 KB data caches +All configurations enable the 16 KB instruction and 16 KB data caches (``CONFIG_MIPS32_ICACHE``, which also selects ``CONFIG_MIPS32_DCACHE``). The linker script places the data memory in KSEG0, so that it goes through the D-Cache; KSEG0 is uncached when the caches are disabled. The Ethernet @@ -336,7 +395,12 @@ Silicon tested: WFI32E01PE, revision B0 (DEVID 0x0A400000). Limitations =========== -* No Wi-Fi driver. +* Wi-Fi: open and WPA2-Personal networks only (WPA/WPA2 mixed mode can be + selected but is not tested), no WPA3 or enterprise security. Station or + Soft-AP, not both at the same time; no scanning while the AP runs. With + management frame protection (PMF) negotiated, unprotected Public Action + frames from the AP (such as Fast Initial Link Setup discovery frames) are + dropped by the library with a "decap action fail" message. * I2C1/I2C2 build but are not tested. * SPI flash: only reads were tested (JEDEC ID and data), not writes or erases. diff --git a/boards/mips/pic32mz/ev49n51a/configs/wlan/defconfig b/boards/mips/pic32mz/ev49n51a/configs/wlan/defconfig new file mode 100644 index 00000000000..c3db116aa17 --- /dev/null +++ b/boards/mips/pic32mz/ev49n51a/configs/wlan/defconfig @@ -0,0 +1,66 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_RAMFUNCS is not set +CONFIG_ARCH="mips" +CONFIG_ARCH_BOARD="ev49n51a" +CONFIG_ARCH_BOARD_EV49N51A=y +CONFIG_ARCH_CHIP="pic32mz" +CONFIG_ARCH_CHIP_PIC32MZ=y +CONFIG_ARCH_CHIP_PIC32MZW1=y +CONFIG_ARCH_CHIP_WFI32E01=y +CONFIG_ARCH_MIPS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=22224 +CONFIG_BUILTIN=y +CONFIG_DRIVERS_IEEE80211=y +CONFIG_DRIVERS_WIRELESS=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LINE_MAX=64 +CONFIG_MIPS32_DCACHE_SIZE=16384 +CONFIG_MIPS32_ICACHE=y +CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL_XC32=y +CONFIG_MTD=y +CONFIG_MTD_SST26=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDEV_WIRELESS_IOCTL=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1514 +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_CHECKSUMS=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PIC32MZ_ICESEL_CH2=y +CONFIG_PIC32MZ_SPI1=y +CONFIG_PIC32MZ_UART1=y +CONFIG_PIC32MZ_W1_WLAN=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x80000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=2 +CONFIG_START_MONTH=10 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_UART1_SERIAL_CONSOLE=y +CONFIG_WIRELESS_WAPI=y +CONFIG_WIRELESS_WAPI_CMDTOOL=y diff --git a/boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c b/boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c index 0d15ab279b6..07ebc5ebb4c 100644 --- a/boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c +++ b/boards/mips/pic32mz/ev49n51a/src/pic32mz_bringup.c @@ -36,6 +36,10 @@ # include "pic32mz_spi.h" #endif +#ifdef CONFIG_PIC32MZ_W1_WLAN +# include "pic32mz_w1_wlan.h" +#endif + #include "ev49n51a.h" /**************************************************************************** @@ -95,5 +99,13 @@ int pic32mz_bringup(void) #endif UNUSED(ret); +#ifdef CONFIG_PIC32MZ_W1_WLAN + ret = pic32mz_wlan_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: pic32mz_wlan_initialize() failed: %d\n", ret); + } +#endif + return OK; }
