{{ message }}
arch/arm: add Realtek RTL8721Dx and RTL8720F (Ameba IOT) support#19236
Open
raulcxw wants to merge 7 commits into
Open
arch/arm: add Realtek RTL8721Dx and RTL8720F (Ameba IOT) support#19236raulcxw wants to merge 7 commits into
raulcxw wants to merge 7 commits into
Conversation
Contributor
|
@raulcxw nice contribution! Kudos!! Please fix this CI issue: Please remove reference to this .venv python |
acassis
previously approved these changes
Jun 29, 2026
linguini1
reviewed
Jun 29, 2026
b267f29 to
3b22294
Compare
xiaoxiang781216
previously approved these changes
Jun 30, 2026
acassis
previously approved these changes
Jun 30, 2026
Contributor
|
@raulcxw please fix this issue: |
acassis
reviewed
Jun 30, 2026
Add NuttX support for two Realtek Ameba dual-core Wi-Fi Host Controller (WHC) SoCs: RTL8721Dx (board PKE8721DAF, application core KM4) and RTL8720F (board RTL8720F EVB, application core KM4TZ). NuttX runs on the Cortex-M33 application/host core and drives the Wi-Fi MAC/PHY on the network-processor core (KM0 / KM4NS) over the on-chip IPC transport (WHC). The IC-agnostic glue is shared in arch/arm/src/common/ameba (os_wrapper backend, WHC netdev with STA + SoftAP, key-value store, flash MTD / littlefs); only the register-level drivers are per-IC. The image2 entry is a NuttX-owned app_start() (arch/arm/src/<chip>/ameba_app_start.c) that runs the SoC silicon init and calls main(); the vendor ameba-rtos SDK is used pristine -- shallow-cloned at a pinned commit, no patching -- and provides the prebuilt Wi-Fi / ROM libraries linked into the image. Features: NSH console, littlefs at /data on SPI NOR, Wi-Fi STA + SoftAP via wapi, DHCP client/server, NuttX-native TCP/IP (no lwIP). Builds via the make build only; the board CMakeLists guards CMake with a clear "not yet supported" message. Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
Add platform/board documentation for the Realtek RTL8721Dx (PKE8721DAF) and RTL8720F (RTL8720F EVB) Ameba WHC ports: the vendor SDK dependency (auto-fetched at a pinned commit), the build steps, and Wi-Fi STA / SoftAP usage with wapi and the DHCP server. Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
The build ran the SDK env.sh and then mandated $SDK/.venv/bin/python with
json5/click. On an image without python3-venv/ensurepip the venv is created
pip-less, so env.sh installs the tool deps into the system python3 instead and
the build aborted in prebuild ("SDK venv is missing json5/click").
ameba_setup_env.sh now resolves a deps-carrying interpreter -- the SDK .venv
when its python imports the deps, otherwise the system python3 exposed through
a non-venv shim dir (so a bare `python` exists and the system site-packages
stay visible) -- and records its bin directory in .amebapy/bindir. board.mk
and the gen-autoconf / build-np helpers read that file instead of hard-coding
.venv/bin, so the build proceeds whenever a python (venv or system) carries
the deps. The sentinel also checks a compiled wheel (pycryptodome) so a
partial dep install is detected, not just the pure-python json5/click.
Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
The board defconfigs took the DEBUG_NOOPT default (-O0), which made the whole image run several times slower and capped iperf UDP RX at ~4 Mbps. Select DEBUG_FULLOPT (-O2). Decouple the WiFi RX seam: ameba_wlan_rxframe now copies each frame into a pooled IOB, queues it and schedules a worker (ameba_wlan_rxwork), so the WHC host RX path returns immediately -- the NP recycles its RX buffer at once -- instead of running ipv4_input()/the reply TX inline in the RX callback and stalling the NP RX ring. Size the IOB pool for sustained WiFi RX (IOB_BUFSIZE=400, IOB_NBUFFERS=100, IOB_THROTTLE=40). Together these take iperf UDP RX from ~0.9 Mbps to ~20 Mbps. Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
Donny9
previously approved these changes
Jul 1, 2026
Adds a generic FLASH macro in tools/ameba/Config.mk that invokes the SDK's AmebaFlash.py, modeled on the ESP32 approach (tools/espressif/Config.mk). Each board sets AMEBA_FLASH_PROFILE and includes the fragment from its scripts/Make.defs. Usage: make flash AMEBA_PORT=/dev/ttyUSB0 [ AMEBA_BAUD=1500000 ] The python interpreter resolved by ameba_setup_env.sh (.amebapy/bindir) is used so that AmebaFlash.py's dependencies (pyDes, json5, click, etc.) are available. Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
Adds the make flash AMEBA_PORT=/dev/ttyUSB0 command and a pointer to the Realtek Ameba ImageTool guide (Windows GUI) to both board docs, addressing the reviewer's request for programmer model and flashing command details. Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
9d18d78
…t 1500000) Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
| Windows GUI tool and download-mode entry (hold the download button / | ||
| power-cycle with the ``UART_LOG_TX`` line asserted). | ||
|
|
||
| **Serial console** — after flashing, connect to the LOG-UART at 1500000 8N1:: |
Contributor
There was a problem hiding this comment.
merge into documentation patch
|
|
||
| This produces ``nuttx/app.bin`` (the NuttX KM4TZ image2), ``boot.bin`` and the | ||
| NP (KM4NS) image, ready to flash with the Realtek tooling. | ||
| NP (KM4NS) image in the build directory. |
Contributor
There was a problem hiding this comment.
merge to the documentation patch
|
|
||
| include $(TOPDIR)/arch/arm/src/rtl8720f/ameba_board.mk | ||
|
|
||
| # Flashing via the SDK AmebaFlash.py (make flash AMEBA_PORT=/dev/ttyUSB0) |
Contributor
There was a problem hiding this comment.
merge to board patch
| * RX: netif_adapter_wifi_recv_whc() -> ameba_wlan_rxframe() (this file) | ||
| * | ||
| * Modeled on arch/arm/src/rtl8720c/amebaz_netdev.c and the bcmf driver. | ||
| * Follows the standard NuttX Ethernet-style netdev (devif) RX/TX idiom. |
Contributor
There was a problem hiding this comment.
merge to the chip patch
| CONFIG_BUILTIN=y | ||
| CONFIG_DEBUG_ASSERTIONS=y | ||
| CONFIG_DEBUG_FEATURES=y | ||
| CONFIG_DEBUG_FULLOPT=y |
Contributor
There was a problem hiding this comment.
merge to board patch
Contributor
There was a problem hiding this comment.
merge into chip patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Add NuttX support for two Realtek Ameba dual-core WHC (WiFi Host
Controller) SoCs and their evaluation boards:
pke8721dafrtl8720f_evbOn these parts NuttX runs on the application (AP) core; the WiFi
MAC/PHY firmware runs on the network (NP) core, and the two cores talk
over the vendor IPC. The host WiFi stack is driven through a WHC glue layer.
What this PR adds:
arch/arm/src/rtl8721dx/andarch/arm/src/rtl8720f/chip support, plus ashared
arch/arm/src/common/ameba/layer (IPC, WHC WiFi host glue, flashMTD, LOGUART console, SDK fetch/build tooling).
boards/arm/rtl8721dx/pke8721daf/andboards/arm/rtl8720f/rtl8720f_evb/with an
nshdefconfig each.Documentation/platforms/arm/.Working features (both boards): NSH over LOGUART, WiFi STA scan + connect,
WiFi SoftAP, littlefs on the on-chip flash (MTD), and AP↔NP IPC.
How the dual-core / vendor-SDK integration works
pinned commit of the public
ameba-rtosSDK (shallow clone) intoarch/arm/src/common/ameba/, provisions its toolchain/venv, and compiles theneeded register-layer (fwlib) and WHC glue sources from SDK source into
per-board archives. The SDK tree is kept pristine (zero patches) — it
natively supports the single-core / boot build entry points we use.
arch/arm/src/<chip>/ameba_app_start.cis aNuttX-licensed adaptation of the SDK
app_start()that performs theOS-independent silicon init and then calls NuttX
main(). No SDK source fileis modified.
disassembly so the SDK's "noused" WiFi-API generator keeps exactly the host
APIs NuttX references (avoids an NP deadlock). This guarantees the two cores
never drift.
prebuilt/staging dir;the SDK kconfig snapshots the packaging step needs are regenerated from the
pinned SDK on every build (never committed).
Impact
arch/arm/src/...and
boards/arm/...; the only edits to existing files are the additiveregistration entries in
arch/arm/Kconfigandboards/Kconfig. No existingboard or architecture is affected.
makeonly. The boardCMakeLists.txtintentionally emitsa clear "CMake build not yet supported"
FATAL_ERRORfor these boards.Testing
Built and run on real hardware for both boards.
Build (host: Ubuntu,
arm-none-eabifrom the SDK-provisioned toolchain):The same configs are built in CI on a clean container using the official
apache-nuttx-ci-linuximage (fresh SDK fetch from the pinned commit), and theresulting firmware was flashed and verified on hardware:
wapi/iwconfigWiFi scan and connect to a WPA2 AP; DHCP lease andping over the air.
reboot).
Notes for reviewers
binary blobs in the tree, and
prebuilt/is git-ignored.(e.g.
Img2EntryFun0,SYSTIMER_Init) referenced from the adaptation files.These are the SDK's public API spellings and cannot be renamed.
lib_rom.awith--whole-archive(its ROM symbolsmust all be present); this is required by the silicon's ROM layout.
not part of this PR.