NuttX Arm and RISC-V
Needs first: Run a talker on an emulated board, What you just built, Get started on NuttX in QEMU (Arm) or (RISC-V)
Status:
nros-board-nuttx-qemu(NuttxArm): Verified in emulator (daily);nros-board-nuttx-qemu(NuttxRiscv): Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
The starters scaffolded a talker for board = "qemu-armv7a-nuttx" (QEMU’s
Arm virt machine) or board = "rv-virt-nuttx" (QEMU’s RISC-V rv-virt),
linked it into a bootable NuttX kernel with nros build, and heard it from
ROS 2. This page covers what comes after them: the image’s configuration,
what is particular to each board, adding nano-ros to a NuttX tree you build
with NuttX’s own make, and the native build.
Configure the platform
Your application’s deployment (board, RMW, domain and an optional
locator) is the bringup’s system.toml, compiled into the image. With a
locator added, the image reads:
[image.nuttx]
board = "qemu-armv7a-nuttx"
locator = "tcp/10.0.2.2:8200"
The file is the same whatever language the node is written in, and nothing
in it names a target triple: armv7a-nuttx-eabihf is a fact about the
board, and the board’s descriptor states it. The guest’s network comes from
the board as well: eth0 at 10.0.2.15, with QEMU’s gateway 10.0.2.2.
With no locator, as scaffolded, the image dials tcp/10.0.2.2:7447. Start
the router as the starter did, listening on the host’s 0.0.0.0 at the port
the image dials (8200 here); the guest cannot reach a router on 127.0.0.1.
An image for the other board sits beside the first in the same bringup:
[image.nuttx_rv]
board = "rv-virt-nuttx"
With two images, name the one you run: nros run nuttx or
nros run nuttx_rv.
Board notes
qemu-armv7a-nuttx: QEMU’s Armvirt, with a virtio-net device on QEMU’s user-mode network.nros runboots the kernel with the store’sqemu-system-armand-icount shift=auto.rv-virt-nuttx: QEMU’s RISC-Vvirt, a 32-bitrv32imaccore. The store’s QEMU is built for Arm and RISC-V 64 only, so this board needs aqemu-system-riscv32from your distribution (Debian and Ubuntu:qemu-system-misc), named withQEMU_SYSTEM_RISCV32. A Rust node builds for the board’sriscv32imac-unknown-nuttx-elftarget withbuild-std.- C is the runtime-checked language; read the board’s support page for what its Rust and C++ rows show.
- A Rust node needs a configured kernel. For one,
nros buildfirst configures and exports the NuttX kernel from the board’s config (a current export is a no-op), then builds the entry with the board’s pinned nightly toolchain. The configure is NuttX’s owntools/configure.sh, which needs the kconfig-frontends tools;nros setup <board> --sudoinstalls them. - The console is the NSH console. A
nros buildimage runs your node at boot. The readiness signal is the firstPublishing: 'Hello World: 1', within about six seconds of boot. - No NuttX hardware board ships. On real hardware the image is an
ordinary NuttX application, built with that board’s
BOARD_CONFIGand flashed as NuttX’s documentation for the board says; see Flash a real board.
Add nano-ros to a NuttX tree you build with make
When your NuttX board ships its own kernel build, nano-ros joins it as an
external application under apps/external/nano-ros/, with its Kconfig
options under Application Configuration › External Modules › nano-ros.
This road needs a NuttX 12 or later checkout of your own, with an apps/
tree beside it ($NUTTX_DIR, $NUTTX_APPS_DIR). In that tree, NuttX owns the
build verb, make, the way Zephyr owns west build:
-
Provision the board, then stage the integration shell into your apps tree once:
"$(nros locate nano-ros)/scripts/nuttx/stage-external-apps.sh" "$NUTTX_APPS_DIR". It writesexternal/Make.defs,KconfigandMakefile, and links the shell in asexternal/nano-ros. Remove$NUTTX_APPS_DIR/Kconfigso NuttX rediscoversapps/external/Kconfig. Run the same command again after you update nano-ros. TheMakefileis what letsmake cleanandmake distcleanclean the external apps; in a tree staged without it, the build after amake distcleanfails to link, and every build prints a line naming this command. -
Bring the symbols nano-ros needs into your configuration. Stock
qemu-armv7a/nshhas noCONFIG_NET, no virtio-net and noTLS_NELEM. With no configuration of your own, configure from the board’s config,packages/boards/nros-board-nuttx-qemu/nuttx-config/arm/defconfig. It#includes upstream’sqemu-armv7a:nshand lists only what differs, so NuttX’s owntools/configure.shmust expand it; copying it to.configdoes not work. Put it in a directory beside a link toboards/arm/qemu/qemu-armv7a/scripts/Make.defs, and pass that directory totools/configure.sh -a <apps dir, relative to the kernel>. configure.sh runskconfig-tweak, so it needs the kconfig-frontends tools (Debian and Ubuntu:kconfig-frontends-nox). With a vendor defconfig, merge the requirements into it instead:CONFIG_NET=y,CONFIG_NET_TCP=y,CONFIG_NET_IPv4=y, the virtio-net options,CONFIG_TLS_NELEM=8,CONFIG_LIBCXXTOOLCHAIN=yandCONFIG_ALLSYMS=n. Then runmake olddefconfig. -
Enable nano-ros in
make menuconfig, or withkconfig-tweakfrom thekconfig-frontendspackage:NROS, the API you use (NROS_C_API,NROS_CPP_API), and the RMW. These options decide what the shell compiles intolibnros_c.a. The board’s config startsnros_nuttx_entry, the entry anros buildimage defines. A make-built kernel that boots NSH setsCONFIG_INIT_ENTRYPOINT="nsh_main"back (kconfig-tweak --set-str CONFIG_INIT_ENTRYPOINT nsh_main). -
Name your project, if the app has one. In your app’s own
Make.defs, beside itsCONFIGURED_APPS +=line:NROS_PROJECTS += $(APPDIR)/external/<app> NROS_IMAGE := <bringup>:<image> # only if several images could matchmakethen runsnros configureon that project, so the generated message bindings exist before anything compiles against them, and builds the image’s own settings into the app. It stops, saying which, when the image’s board, RMW or ROS edition disagrees with the kernel’s configuration from step 3. One NuttX build takes one project. With no project named, the shell builds from your Kconfig choices alone. -
Build the kernel with
makein$NUTTX_DIR. The Rust static libraries build as a sub-step of the app build, and the kernel ELF is$NUTTX_DIR/nuttx.
A kernel built this way boots to the NSH prompt. Run your app by its
program name there, for example nsh> nuttx_c_talker: the build registers
each app as an NSH built-in command. Several apps each declare their own
program name and share the one libnros_c.a.
The staging script stages the shell only. A bringup with several components
is built with nros build and an [image.<id>], as in
examples/workspaces/rust.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run nx_node --dry-run --why
The plan names the QEMU runner and the board’s machine, the console, and the
link to the router at the image’s locator. --why names where each fact
came from.
Drive the native build yourself
Print the exact commands nros build runs, and the QEMU line that boots the
kernel, without building:
nros build --dry-run
The same QEMU line boots a kernel you built with make. nros configure
writes the generated entry without building.
If it doesn’t work
If no Publishing: line appears:
- Confirm the app ran:
psat the NSH prompt shows its task. - Confirm the network:
ifconfigshowseth0at10.0.2.15. - Confirm the router listens on the host’s
0.0.0.0at the port the image’slocatornames. - On RISC-V, confirm
QEMU_SYSTEM_RISCV32names aqemu-system-riscv32.
For DDS on NuttX, raise the network buffer options in the kernel configuration. Everything else: Troubleshoot.
Reference
- The boards’ support pages:
qemu-armv7a-nuttx,rv-virt-nuttx. - The integration shell and its Kconfig:
integrations/nuttx/. - Copy-out talkers, one per language:
examples/qemu-armv7a-nuttx/. The other roles are thenuttx_*andriscv_nuttx_*image rows of the language workspaces,examples/workspaces/{rust,c,cpp}.
Design background
- RFC-0122: behaviour bringups, single-node witnesses, and cadence-backed CI.