Skip to content

arch/arm/rtl8721f: add RTL8721F chip and EVB board support - #19575

Open
dcgong2917 wants to merge 4 commits into
apache:masterfrom
dcgong2917:pr/rtl8721f-port
Open

arch/arm/rtl8721f: add RTL8721F chip and EVB board support#19575
dcgong2917 wants to merge 4 commits into
apache:masterfrom
dcgong2917:pr/rtl8721f-port

Conversation

@dcgong2917

Copy link
Copy Markdown
Contributor

Summary

Add initial NuttX support for the Realtek RTL8721F, a dual-core
Cortex-M55 (KM4 TrustZone) + Cortex-M55 (KM4 NS) SoC targeting
Wi-Fi 6 / Bluetooth 5.3 IoT applications. The RTL8721F belongs to
the amebagreen2 SoC family alongside the already-merged RTL8720F;
chip-specific constants substituted.

  • arch/arm/include/rtl8721f/irq.h: full 109-entry IRQ table compiled
    from the RTL8721F TRM; differs from RTL8720F in peripheral numbering.
  • arch/arm/src/rtl8721f/ameba_app_start.c: NuttX-owned image2 entry
    running OS-independent silicon init (cache, BSS clear, LOGUART,
    data-flash high-speed setup, OSC calibration, SDM32K/RTC system
    timer, pinmap, MPU) before calling NuttX main(). Owning this file
    keeps the vendor SDK pristine.
  • arch/arm/src/rtl8721f/: ameba_loguart.c, ameba_irq.c, ameba_start.c,
    ameba_timerisr.c, ameba_allocateheap.c, ameba_ipc.c — standard NuttX
    ARM bring-up adapted to the RTL8721F memory map and boot flow.
  • arch/arm/src/rtl8721f/ameba_board.mk: SDK fwlib source list and
    linker flags for the RTL8721F image2 build.
  • arch/arm/src/rtl8721f/ameba_wifi_init.c: wires the Ameba Wi-Fi upper
    half into NuttX netdev at bring-up.
  • boards/arm/rtl8721f/rtl8721f_evb: board Kconfig, defconfig (nsh),
    board.h pin table, boot and bringup hooks, LittleFS on internal
    4 MiB flash (/dev/mtd0 -> /mnt/lfs).
  • tools/nxstyle.c: whitelist RTL8721F-specific Realtek SDK ROM/HAL
    symbol prefixes (RTC_, EFUSE_, SDM32K_, Get_OSC131_, Set_OSC131_)
    that cannot be renamed without breaking linkage against the vendor
    blob; extends the existing Ameba SDK comment block.
  • Documentation/platforms/arm/rtl8721f/: platform overview (memory map,
    peripheral list, toolchain, flash procedure) and EVB board page.

Impact

  • New platform: arch/arm/src/rtl8721f/ and boards/arm/rtl8721f/ are
    entirely new directories; no existing platform is modified.
  • tools/nxstyle.c: five new Ameba SDK prefixes added to the whitelist
    inside the existing Ameba comment block; no behavioural change for
    any other platform.
  • arch/arm/Kconfig and boards/Kconfig: new ARCH_CHIP_RTL8721F and
    ARCH_BOARD_RTL8721F_EVB entries appended; no existing entries changed.

Testing

Built for rtl8721f_evb:nsh and verified on hardware (RTL8721F EVB):

  • NSH boots to prompt over LOGUART at 115200 baud.
  • LittleFS mounts on internal 4 MiB flash; file create/read across
    power cycles confirmed.
  • Wi-Fi association, DHCP lease and ping to 8.8.8.8 pass end-to-end.
  • tools/checkpatch.sh clean on all new/changed sources (0 error:
    lines); full build produces nuttx.bin with no new warnings.

dcgong2917 and others added 4 commits July 29, 2026 18:39
Add a P0 skeleton port for the Realtek RTL8721F (SDK codename Green2 /
amebagreen2).  Structurally the RTL8721F is a twin of the RTL8720F -- the
AP/host core is km4tz (ARMv8-M.main, TrustZone secure) and the WiFi MAC/PHY
runs on the km4ns network-processor core -- so this port is modelled on the
RTL8720F one and shares the IC-agnostic ameba glue in
arch/arm/src/common/ameba.

This is the "configures and links" skeleton (rtl8721f_evb:nsh builds an
image end to end).  Four differences from the RTL8720F template were needed
to make the empty shell link against amebagreen2:

  * km4tz has no FPU (cmsis_cpu.h defines __FPU_PRESENT 0), so the chip does
    not select ARCH_HAVE_FPU and the image is built soft-float.
  * ameba_app_start.c matches amebagreen2's ram_km4tz silicon init: the
    nocache MPU map, the non-secure ROM BSS clear, OSC4M (not OSC2M)
    calibration gated on EFUSE cut >= B and CHIP_TYPE_ASIC_POSTSIM.
  * amebagreen2 ships no lib_rom.a, so the ROM archive whole-archive link is
    dropped; the WiFi/OS/non-secure ROM symbols come from the SDK
    ameba_rom_symbol_acut{,_wifi,_os}.ld maps appended to the image2 linker
    script, exactly as green2's own image2 link does.
  * the AP WiFi security lib is lib_wifi_common.a (was lib_wifi_com_sec.a).

The per-chip IRQ vector table (irq.h) and the RAM_START/RAM_SIZE layout
still carry RTL8720F values and are refined in the follow-up bring-up work.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Wire the RTL8721F km4tz core up to a working NuttShell:

- irq.h: renumber the KM4TZ external vector table to the RTL8721F
  APIRQn map (UART_LOG=24, IPC=5, +GPIOB/C, TIMER7/8, ...).
- ameba_loguart.c: fix the LOG-UART base to 0x40810000.  The former
  0x401C6000 belongs to a different Ameba part; the wrong base bus-
  faulted on the RX interrupt-enable write while TX still worked
  (LOGUART_PutChar uses its own ROM-internal base).
- ameba_app_start.c: adjust the MPU read-only / RAM regions for the
  RTL8721F memory map and seed the RTC on first power-on so the
  SDM32K-clocked SYSTIMER comes up (mirrors the SDK app_rtc_init).
- ameba_ipc.c: move the km4tz<->km4ns IPC to APIRQn 5 (IPC_CPU0).
- ameba_board.mk: pull in fwlib ameba_rtc.c for the RTC_* symbols.
- defconfig: RTL8721F RAM map, enable TIMER/TIMER_ARCH/ARMV8M_SYSTICK
  for a live system tick, and drop the WiFi/NET stack for now.
- scripts/Make.defs: use the RTL8721F_NOR flash profile.

Boots cleanly to nsh> on hardware; tick, RX and builtin apps verified.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Bring up the last two RTL8721F feature blocks and wire them into the
nsh board configuration:

- littlefs on the on-chip flash MTD region (P2).
- WHC/INIC WiFi with the on-chip IPC control plane, NuttX net stack,
  DHCP client and the wapi command tool (P3).

Two porting fixes were required for the WiFi control plane:

- ameba_ipc.c: the AP IPC device base (IPCAP_DEV) was carried over
  verbatim from the RTL8720F template (0x40804000).  On this SoC IPC0
  lives at 0x40815000; using the wrong base makes ipc_table_init()
  program the RX-full mask in the wrong register block, so the NP->AP
  interrupt never fires and WiFi bring-up hangs waiting for the device
  to answer.  Point IPCAP_DEV at the correct 0x40815000 base.

- ameba_board.mk: the EVB silicon is B-cut, so link against the
  ameba_rom_symbol_bcut*.ld ROM symbol tables (the A-cut tables resolve
  the WiFi ROM helpers to the wrong addresses and fault at run time).

Validated on hardware: NSH comes up, wapi scan lists real APs, a WPA2
connect succeeds, the DHCP client obtains a lease and ICMP to the
public internet round-trips.

The board defconfig keeps SSID/passphrase as placeholders; real
credentials are supplied at run time via the wapi commands.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Add platform documentation for the Realtek RTL8721F: a chip overview
page and the rtl8721f_evb board page, modelled on the existing RTL8720F
/ RTL8721Dx docs.  The platform index picks them up automatically via
its */index glob.

The pages cover the vendor-SDK/toolchain dependency, the make and CMake
build/flash flow, and the hardware-verified features: NSH over the
LOG-UART console, littlefs at /data on the on-chip NOR flash, Wi-Fi
station and SoftAP via the wapi tool, and the DHCP client/server.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Co-Authored-By: Claude <noreply@anthropic.com>
@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 Jul 29, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis

acassis commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@dcgong2917 please fix the CMake error:

 ../nuttx/tools/checkpatch.sh -c -u -m -g  a9e4af4f0d44bd69e35fce54e490aa6d4641ef7d..HEAD
Used config files:
    1: .codespellrc
ERROR __main__.py:618: Check failed: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/rtl8721f/CMakeLists.txt

cmake-format check failed, run following command to update the style:
  $ cmake-format <src> -o <dst>

ERROR __main__.py:618: Check failed: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/rtl8721f/CMakeLists.txt
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md
Error: Process completed with exit code 1.

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.

3 participants