Skip to content

arch/arm: add Realtek RTL8721Dx and RTL8720F (Ameba IOT) support#19236

Merged
acassis merged 3 commits into
apache:masterfrom
Ameba-AIoT:ameba-pr
Jul 1, 2026
Merged

arch/arm: add Realtek RTL8721Dx and RTL8720F (Ameba IOT) support#19236
acassis merged 3 commits into
apache:masterfrom
Ameba-AIoT:ameba-pr

Conversation

@raulcxw

@raulcxw raulcxw commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Add NuttX support for two Realtek Ameba dual-core WHC (WiFi Host
Controller)
SoCs and their evaluation boards:

SoC Board AP core (NuttX) NP core (WiFi)
RTL8721Dx pke8721daf km4 (Cortex-M33) km0
RTL8720F rtl8720f_evb km4tz (Cortex-M33) km4ns

On 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/ and arch/arm/src/rtl8720f/ chip support, plus a
    shared arch/arm/src/common/ameba/ layer (IPC, WHC WiFi host glue, flash
    MTD, LOGUART console, SDK fetch/build tooling).
  • boards/arm/rtl8721dx/pke8721daf/ and boards/arm/rtl8720f/rtl8720f_evb/
    with an nsh defconfig each.
  • Platform/board documentation under 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

  • Out-of-tree, pinned SDK — no vendored blobs. The build auto-fetches a
    pinned commit of the public ameba-rtos SDK (shallow clone) into
    arch/arm/src/common/ameba/, provisions its toolchain/venv, and compiles the
    needed 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.
  • NuttX owns the image2 entry. arch/arm/src/<chip>/ameba_app_start.c is a
    NuttX-licensed adaptation of the SDK app_start() that performs the
    OS-independent silicon init and then calls NuttX main(). No SDK source file
    is modified.
  • NP/boot built from the same pinned SDK every build, fed NuttX's own
    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.
  • All vendor build artifacts live in a git-ignored prebuilt/ staging dir;
    the SDK kconfig snapshots the packaging step needs are regenerated from the
    pinned SDK on every build (never committed).

Impact

  • New architecture/boards only — adds new files under arch/arm/src/...
    and boards/arm/...; the only edits to existing files are the additive
    registration entries in arch/arm/Kconfig and boards/Kconfig. No existing
    board or architecture is affected.
  • Build system: make only. The board CMakeLists.txt intentionally emits
    a clear "CMake build not yet supported" FATAL_ERROR for these boards.
  • Network: standard NuttX netdev / wireless ioctls; no core net changes.
  • Documentation: new pages only.
  • Security: none (no changes to common code paths).

Testing

Built and run on real hardware for both boards.

Build (host: Ubuntu, arm-none-eabi from the SDK-provisioned toolchain):

./tools/configure.sh pke8721daf:nsh   && make    # -> app.bin, boot.bin, km0_image2_all.bin
./tools/configure.sh rtl8720f_evb:nsh && make    # -> app.bin, boot.bin, km4ns_image2_all.bin

The same configs are built in CI on a clean container using the official
apache-nuttx-ci-linux image (fresh SDK fetch from the pinned commit), and the
resulting firmware was flashed and verified on hardware:

  • NSH prompt over LOGUART, basic shell commands.
  • wapi/iwconfig WiFi scan and connect to a WPA2 AP; DHCP lease and
    ping over the air.
  • SoftAP brought up; a client associates and obtains a DHCP address.
  • littlefs mounted on the flash data partition (read/write/persist across
    reboot).

Notes for reviewers

  • The vendor SDK is auto-fetched (pinned), not vendored — there are no
    binary blobs in the tree, and prebuilt/ is git-ignored.
  • nxstyle emits "Mixed case identifier" on vendor SDK symbol names
    (e.g. Img2EntryFun0, SYSTIMER_Init) referenced from the adaptation files.
    These are the SDK's public API spellings and cannot be renamed.
  • RTL8720F links the SDK lib_rom.a with --whole-archive (its ROM symbols
    must all be present); this is required by the silicon's ROM layout.
  • A fork-only GitHub Actions workflow used to produce/verify the CI firmware is
    not part of this PR.

@github-actions github-actions Bot added Area: Build system Arch: arm Issues related to ARM (32-bit) architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: arm labels Jun 29, 2026
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis

acassis commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@raulcxw nice contribution! Kudos!!

Please fix this CI issue:

./env.sh: line 223: /github/workspace/sources/nuttx/arch/arm/src/common/ameba/ameba-rtos/.venv/bin/activate: No such file or directory
/github/workspace/sources/nuttx/arch/arm/src/common/ameba/ameba-rtos/.venv/bin/python: No module named pip
ameba_setup_env.sh: SDK venv (/github/workspace/sources/nuttx/arch/arm/src/common/ameba/ameba-rtos/.venv) is missing json5/click.
  Most likely the venv was not created properly -- install the python
  venv module (e.g. 'apt install python3-venv') so the SDK env.sh can
  build .venv with pip, then retry.  (A flaky PyPI can also cause it.)
make: *** [tools/Unix.mk:529: prebuild] Error 1
make: Target 'all' not remade because of errors.

Please remove reference to this .venv python

acassis
acassis previously approved these changes Jun 29, 2026
Comment thread Documentation/platforms/arm/rtl8720f/boards/rtl8720f_evb/index.rst
Comment thread Documentation/platforms/arm/rtl8721dx/boards/pke8721daf/index.rst
acassis
acassis previously approved these changes Jun 30, 2026
@acassis

acassis commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@raulcxw please fix this issue:

chip/ameba_wifi_init.c: In function 'rtl8721dx_wifi_initialize':
Error: chip/ameba_wifi_init.c:161:3: error: implicit declaration of function 'up_enable_irq'; did you mean 'up_enable_icache'? [-Werror=implicit-function-declaration]
  161 |   up_enable_irq(RTL8721DX_IRQ_IPC_KM4);
      |   ^~~~~~~~~~~~~
      |   up_enable_icache
``

Comment thread Documentation/platforms/arm/rtl8720f/boards/rtl8720f_evb/index.rst Outdated
Comment thread Documentation/platforms/arm/rtl8721dx/boards/pke8721daf/index.rst Outdated
Donny9
Donny9 previously approved these changes Jul 1, 2026
@raulcxw raulcxw dismissed stale reviews from Donny9 and acassis via 9d18d78 July 1, 2026 04:01
Comment thread Documentation/platforms/arm/rtl8720f/boards/rtl8720f_evb/index.rst
Comment thread Documentation/platforms/arm/rtl8720f/boards/rtl8720f_evb/index.rst
Comment thread boards/arm/rtl8720f/rtl8720f_evb/scripts/Make.defs
Comment thread arch/arm/src/common/ameba/ameba_wlan.c
Comment thread boards/arm/rtl8720f/rtl8720f_evb/configs/nsh/defconfig
Comment thread arch/arm/src/common/ameba/tools/ameba_build_np.sh
raulcxw added 3 commits July 1, 2026 16:04
Add the ARM architecture-level support and build system for the Realtek
Ameba WHC (Wi-Fi Host Controller) dual-core SoCs:

  - RTL8721Dx (KM4 Cortex-M33 host + KM0 NP)
  - RTL8720F  (KM4TZ Cortex-M33 secure host + KM4NS NP)

New directories under arch/arm/src/:
  - common/ameba/   -- IC-agnostic glue (os_wrapper, netdev, KV store,
                       flash MTD, WHC Wi-Fi, SDK bootstrap)
  - rtl8721dx/      -- RTL8721Dx register-level drivers
  - rtl8720f/       -- RTL8720F register-level drivers

New directories under arch/arm/include/:
  - rtl8721dx/      -- RTL8721Dx IRQ and chip headers
  - rtl8720f/       -- RTL8720F IRQ and chip headers

Also includes tools/nxstyle.c white-list entries for the Realtek SDK
CamelCase symbols and tools/ameba/Config.mk for the make flash target.

Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
Add board-level support for two Realtek Ameba WHC evaluation boards:

  - pke8721daf (RTL8721Dx)
  - rtl8720f_evb (RTL8720F)

Each board provides:
  - defconfig for NSH with WiFi networking support
  - CMakeLists.txt (make-only build helper that fails fast on cmake)
  - Board-specific bring-up and initialization (leds, SDIO, flash)
  - Scripts/Make.defs including the IC-level build fragment and the
    make flash target (tools/ameba/Config.mk)

Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
Add the chip-level and board-level documentation for both Ameba WHC
SoCs and their evaluation boards.  Each board document follows the
board.rst template with tags, features, configurations, building and
flashing instructions, and license exceptions.

Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
@acassis

acassis commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

OK, I will merge since the reported error:

Configuration/Tool: stm32l0538-disco/nsh,CONFIG_ARM_TOOLCHAIN_GNU_EABI
2026-07-01 10:33:30
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Building NuttX...
arm-none-eabi-ld: /github/workspace/sources/nuttx/nuttx section `.data' will not fit in region `flash'
arm-none-eabi-ld: region `flash' overflowed by 20 bytes
make[1]: *** [Makefile:230: nuttx] Error 1
make: *** [tools/Unix.mk:569: nuttx] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 397: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize stm32l0538-disco/nsh

is not related to this PR.

@acassis acassis merged commit 76838fa into apache:master Jul 1, 2026
52 of 54 checks passed
@raulcxw raulcxw deleted the ameba-pr branch July 2, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Build system Board: arm Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants