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 (contributor / in-tree workflow)

Looking for the user-facing path? This page covers building nano-ros’s own NuttX examples on QEMU from this repository. If you’re integrating nano-ros into YOUR NuttX app at apps/external/nano-ros/, see Integration: NuttX external app instead.

nano-ros runs on NuttX, targeting QEMU ARM virt (Cortex-A7 + virtio-net). NuttX provides POSIX-compatible BSD sockets, which makes it the most straightforward RTOS port – zenoh-pico uses the same socket API as on Linux.

Overview

The NuttX platform uses:

  • NuttX RTOS – POSIX-compliant real-time OS with BSD socket support
  • BSD sockets – standard socket API provided by NuttX’s network stack
  • zenoh-pico – Zenoh transport over NuttX sockets (same code path as POSIX)
  • virtio-net – NuttX built-in Ethernet driver (no custom driver needed)

Board crate: nros-board-nuttx-qemu-arm (in packages/boards/).

Why NuttX Is Simpler Than FreeRTOS

NuttX is the simplest RTOS platform to port because of its strong POSIX compliance (POSIX.1-2008: pthreads, BSD sockets, select(), clock_gettime()):

AspectNuttXFreeRTOS
zenoh-pico layerReuses unix/ platformDedicated freertos/ platform
NetworkingBuilt-in BSD socketsExternal lwIP
Ethernet driverNuttX virtio-net (built-in)Custom LAN9118 lwIP netif
Rust targetarmv7a-nuttx-eabi with stdthumbv7m-none-eabi (no_std)
Build integrationNuttX build system + cargocc crate compiles FreeRTOS + lwIP
QEMU machinevirt (Cortex-A7)mps2-an385 (Cortex-M3)

Because NuttX supports Rust std, examples use standard fn main() entry points and println! – no semihosting or custom panic handlers needed.

Setup

nros setup qemu-arm-nuttx provisions everything this board needs — the NuttX cross-compiler, qemu-system-arm, the NuttX source tree, and the RMW host daemon — into the shared store at ~/.nros/sdk. No hand-installed cross-toolchain and no ROS 2 install required.

Build the in-tree nros CLI (Phase 218), then provision the board (--rmw defaults to zenoh):

source ./activate.sh        # OR: direnv allow / source ./activate.fish
just setup-cli              # builds packages/cli/target/release/nros
nros setup qemu-arm-nuttx --rmw zenoh

As a contributor, just nuttx setup remains available and now delegates to nros setup qemu-arm-nuttx for the toolchain/SDK provisioning while also staging the external apps.

The NuttX sources land in third-party/nuttx/nuttx/ and third-party/nuttx/nuttx-apps/. Override the paths with environment variables if your sources are elsewhere:

VariableDefaultDescription
NUTTX_DIRthird-party/nuttx/nuttxNuttX RTOS source
NUTTX_APPS_DIRthird-party/nuttx/nuttx-appsNuttX apps source

Prerequisites

The nros setup qemu-arm-nuttx step above provisions the qemu-system-arm emulator and the arm-none-eabi-gcc cross-compiler used for NuttX kernel compilation. The one host-side tool you still supply yourself:

  • Rust nightly toolchain (NuttX targets are Tier 3, require -Z build-std)

Building

just nuttx build

This cross-compiles all NuttX examples for armv7a-nuttx-eabi using cargo +nightly build --release. The examples link against NuttX’s POSIX layer, which provides sockets, pthreads, and standard I/O.

Available Examples

All examples are in examples/qemu-arm-nuttx/rust/:

ExampleDescription
talkerPublishes std_msgs/String on /chatter
listenerSubscribes to std_msgs/String on /chatter
service-serverServes AddTwoInts on /add_two_ints
service-clientCalls AddTwoInts on /add_two_ints
action-serverServes Fibonacci action on /fibonacci
action-clientSends Fibonacci goal on /fibonacci

Testing

just test-nuttx

Tests run under qemu-system-arm -M virt with TAP networking. Each QEMU instance connects to the host bridge (br-qemu) via TAP devices for zenohd communication. The test infrastructure builds a NuttX kernel image with the example app embedded, boots it in QEMU, and verifies message exchange.

Network Configuration

NuttX QEMU instances use the same IP scheme as other QEMU board crates:

RoleIP AddressTAP Device
Talker/Publisher192.0.3.10tap-qemu0
Listener/Sub192.0.3.11tap-qemu1
Service Server192.0.3.12tap-qemu0
Service Client192.0.3.13tap-qemu1
zenohd (host)192.0.3.1br-qemu

Architecture

Board Crate

The nros-board-nuttx-qemu-arm board crate follows the standard Config / run() pattern documented in the Custom Board Package guide. It provides network and node configuration presets (talker(), listener(), server(), client()).

Unlike bare-metal and FreeRTOS board crates, there is no custom hardware initialization, no network stack setup, and no task creation. NuttX’s kernel boots the hardware, initializes virtio-net, and starts the application before main() runs. Because NuttX supports Rust std, examples use standard fn main() entry points.

NuttX Defconfig

The QEMU board configuration lives in packages/boards/nros-board-nuttx-qemu-arm/nuttx-config/ and enables:

  • CONFIG_NET – networking subsystem
  • CONFIG_NET_TCP / CONFIG_NET_UDP – TCP/UDP protocols
  • CONFIG_DRIVERS_VIRTIO + CONFIG_DRIVERS_VIRTIO_NET – virtio Ethernet
  • CONFIG_PTHREAD_MUTEX_TYPES – POSIX mutex types (for zenoh-pico)
  • CONFIG_DEV_URANDOM/dev/urandom for session ID generation
  • CONFIG_DEFAULT_TASK_STACKSIZE=8192 – adequate stack for nros apps
  • CONFIG_BUILD_FLAT – flat memory model (no MMU protection)

Status

NuttX platform support is complete: feature flags, build integration, six Rust examples, E2E network tests, and documentation.