arch/arm/ameba: add CMake build support for RTL8721Dx and RTL8720F#19463
Merged
Conversation
Both Ameba WHC boards (pke8721daf, rtl8720f_evb) previously built only via the
make build; the board CMakeLists fell back to a FATAL_ERROR. Wire up the full
vendor-SDK machinery for CMake so `cmake --build` produces the same flashable
nuttx.bin as make, with no change to any shared/arch-common file:
- tools/ameba/env.sh: source it once before cmake. It resolves/auto-fetches
the ameba-rtos SDK + its pinned asdk toolchain (reusing the same helper
scripts the make build uses) and puts the toolchain on PATH, so cmake's
normal compiler probe finds it -- exactly like every other NuttX board's
toolchain. No per-chip hook is added to the shared arch Toolchain.cmake.
- common/ameba/cmake/ameba_sdk.cmake: resolve AMEBA_SDK + asdk dir from that
environment (fall back to the in-tree checkout) and sanity-check the
compiler; included by each arch chip CMakeLists before its SDK-relative
source lists.
- common/ameba/cmake/ameba_board.cmake: the shared mechanism -- autoconf,
libameba_fwlib.a / libameba_wifi.a compiled with the isolated SDK include
set, the image2 linker script, the image2 link flags + EXTRA_LIBS, nuttx.bin
packaging and the flash target. Per-IC inputs are set by each arch chip
CMakeLists.
- common/ameba/tools/{ameba_gen_ldscript,ameba_package,ameba_flash}.sh:
shared shell steps used by both the make and cmake paths so the two produce
identical output; tools/ameba/Config.mk now flashes via ameba_flash.sh too.
- Fix a latent rtl8720f CMakeLists source list bug (ameba_ipc.c was missing
for the WiFi / flash-fs configs).
The make build is unchanged (it still auto-fetches everything, so sourcing
env.sh is optional there and required only for cmake). Verified on hardware:
both boards build, flash and boot with WiFi over the CMake path.
Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
Without SCHED_WAITPID, NSH cannot waitpid() on a spawned builtin application, so every foreground builtin (e.g. wapi) is run in the background and NSH echoes "<cmd> [pid:priority]" instead of blocking until it finishes. Enable CONFIG_SCHED_WAITPID (the setting used by the large majority of nsh defconfigs) so foreground builtins run synchronously with a correct exit status and no spurious [pid:priority] echo. Assisted-by: Claude Code:claude-opus-4-8 Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
Each ameba IC pins its asdk (arm-none-eabi) version in the SDK
(component/soc/<soc>/project/CMakeLists.txt): RTL8720F needs 12.3.1 while
RTL8721Dx needs 10.3.1. Both share the same arm-none-eabi triple and differ
only by install directory. The make + cmake setup previously read only the
global default, so the NuttX objects for an IC pinning a newer asdk were built
with the wrong compiler (not the one its SDK archives were built with).
Resolve the version per-IC from a single helper (ameba_asdk_version.sh, keyed
by the SoC) used by every caller:
- toolchain.mk / ameba_board.mk: make picks the right asdk automatically
(it already knows the SoC), no user action.
- ameba_fetch_toolchain.sh: fetches the version the SoC pins.
- tools/ameba/env.sh: takes an optional board (`. tools/ameba/env.sh
<board>`) so cmake, which locks the compiler at project() time, gets the
matching asdk on PATH before it probes. No board -> the global default.
- ameba_sdk.cmake: fail configure with a fix-it message if the on-PATH
compiler is not the version this IC needs (e.g. a stale env from another
board), instead of silently mis-compiling.
Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
The make PREBUILD packed the fwlib/wifi static archives with `ar crs <a> <objdir>/*.o`. The glob also picks up stale objects left in the obj dir from a previous configuration (e.g. a renamed/removed SDK source), which can pull a duplicate/old translation unit into the image (seen on RTL8720F as a spurious ROM-overlay symbol from an old log.o). Accumulate the exact object list the loop compiled and `ar` that instead, removing the archive first so it is rebuilt from precisely the current sources. Assisted-by: Claude Code:claude-opus-4-8 Signed-off-by: raul_chen <raul_chen@realsil.com.cn>
xiaoxiang781216
approved these changes
Jul 17, 2026
jerpelea
approved these changes
Jul 17, 2026
acassis
approved these changes
Jul 17, 2026
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
Both Realtek Ameba boards (
pke8721daf/ RTL8721Dx andrtl8720f_evb/RTL8720F) previously built only via the make build; their board
CMakeLists.txtfell back to aFATAL_ERROR. This wires up the fullvendor-SDK machinery for CMake so
cmake --buildproduces the same flashablenuttx.binas make, with no change to any shared/arch-common CMake file(
arch/arm/src/cmake/*untouched).tools/ameba/env.sh— source once before cmake(
. tools/ameba/env.sh <board>). It resolves/auto-fetches theameba-rtosSDK and the SDK-pinned asdk toolchain (reusing the same helper scripts the
make build already uses) and puts the toolchain on
PATH, so CMake's normalcompiler probe finds it — like every other NuttX board. No per-chip hook is
added to the shared arch
Toolchain.cmake.common/ameba/cmake/{ameba_sdk,ameba_board}.cmake— the shared mechanism:SDK resolve + compiler/version guard, autoconf generation,
libameba_fwlib.a/
libameba_wifi.abuilt with the isolated SDK include set, the image2 linkerscript + link flags,
nuttx.binpackaging and theflashtarget. Per-ICinputs are set by each arch chip
CMakeLists.txt.common/ameba/tools/{ameba_gen_ldscript,ameba_package,ameba_flash}.sh—shared shell steps used by both the make and cmake paths so the two produce
identical output;
tools/ameba/Config.mkflashes viaameba_flash.shtoo.ameba_asdk_version.sh) — each IC pinsits asdk version in the SDK (RTL8720F -> 12.3.1, RTL8721Dx -> 10.3.1). make
and cmake now build the NuttX objects with the version the IC pins, matching
the SDK archives they link against. A configure-time guard fails with a
fix-it message if a stale environment puts the wrong compiler on
PATH.(Supersedes and includes arch/arm/ameba: fix per-IC asdk toolchain selection and fwlib archive hygiene #19352.)
object list instead of a
*.oglob, so a stale object from a previousconfiguration can no longer be pulled into the image.
CONFIG_SCHED_WAITPIDenabled in both nsh defconfigs so foregroundbuiltins (e.g.
wapi) run synchronously with a correct exit status.on first build, by
env.shfor cmake) and aBuilding and Flashingsectionwith
With make/With CMakesubsections; build-time config options areshared, only the menuconfig entry point differs.
Impact
sourcing
env.shis optional for make, required for cmake.arch/arm/src/cmake/*untouched).Testing
paths (hardware verified: NSH +
ifup wlan0+ WPA2).(make + cmake x 2 boards), plus single-runner ops jobs that exercise the
kconfig backend (
olddefconfig/savedefconfig), switching boards bothways across the per-IC asdk boundary (10.3.1 <-> 12.3.1),
make distclean,and the abnormal cases (stale / absent
env.shcaught by the guards; a boardswitch without
make distcleanrefused).CMake build — pke8721daf:nsh (RTL8721Dx, asdk 10.3.1)
CMake build — rtl8720f_evb:nsh (RTL8720F, asdk 12.3.1)