Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

NuttX Arm and RISC-V

How-to · Level 2: Building real applications

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 Arm virt, with a virtio-net device on QEMU’s user-mode network. nros run boots the kernel with the store’s qemu-system-arm and -icount shift=auto.
  • rv-virt-nuttx: QEMU’s RISC-V virt, a 32-bit rv32imac core. The store’s QEMU is built for Arm and RISC-V 64 only, so this board needs a qemu-system-riscv32 from your distribution (Debian and Ubuntu: qemu-system-misc), named with QEMU_SYSTEM_RISCV32. A Rust node builds for the board’s riscv32imac-unknown-nuttx-elf target with build-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 build first 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 own tools/configure.sh, which needs the kconfig-frontends tools; nros setup <board> --sudo installs them.
  • The console is the NSH console. A nros build image runs your node at boot. The readiness signal is the first Publishing: '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_CONFIG and 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:

  1. 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 writes external/Make.defs, Kconfig and Makefile, and links the shell in as external/nano-ros. Remove $NUTTX_APPS_DIR/Kconfig so NuttX rediscovers apps/external/Kconfig. Run the same command again after you update nano-ros. The Makefile is what lets make clean and make distclean clean the external apps; in a tree staged without it, the build after a make distclean fails to link, and every build prints a line naming this command.

  2. Bring the symbols nano-ros needs into your configuration. Stock qemu-armv7a/nsh has no CONFIG_NET, no virtio-net and no TLS_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’s qemu-armv7a:nsh and lists only what differs, so NuttX’s own tools/configure.sh must expand it; copying it to .config does not work. Put it in a directory beside a link to boards/arm/qemu/qemu-armv7a/scripts/Make.defs, and pass that directory to tools/configure.sh -a <apps dir, relative to the kernel>. configure.sh runs kconfig-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=y and CONFIG_ALLSYMS=n. Then run make olddefconfig.

  3. Enable nano-ros in make menuconfig, or with kconfig-tweak from the kconfig-frontends package: NROS, the API you use (NROS_C_API, NROS_CPP_API), and the RMW. These options decide what the shell compiles into libnros_c.a. The board’s config starts nros_nuttx_entry, the entry a nros build image defines. A make-built kernel that boots NSH sets CONFIG_INIT_ENTRYPOINT="nsh_main" back (kconfig-tweak --set-str CONFIG_INIT_ENTRYPOINT nsh_main).

  4. Name your project, if the app has one. In your app’s own Make.defs, beside its CONFIGURED_APPS += line:

    NROS_PROJECTS += $(APPDIR)/external/<app>
    NROS_IMAGE := <bringup>:<image>    # only if several images could match
    

    make then runs nros configure on 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.

  5. Build the kernel with make in $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:

  1. Confirm the app ran: ps at the NSH prompt shows its task.
  2. Confirm the network: ifconfig shows eth0 at 10.0.2.15.
  3. Confirm the router listens on the host’s 0.0.0.0 at the port the image’s locator names.
  4. On RISC-V, confirm QEMU_SYSTEM_RISCV32 names a qemu-system-riscv32.

For DDS on NuttX, raise the network buffer options in the kernel configuration. Everything else: Troubleshoot.

Reference

Design background

  • RFC-0122: behaviour bringups, single-node witnesses, and cadence-backed CI.