Get started on NuttX in QEMU (Arm)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-nuttx-qemu; Board Support Levels explains the words.
This starter puts a talker on Apache NuttX, on QEMU’s Arm virt machine (a
Cortex-A7), and shows its messages arriving in ROS 2. NuttX is a POSIX-style
RTOS, so the talker runs as an ordinary NuttX task, with NuttX’s own network
stack on a virtio-net device. You need no NuttX checkout of your own:
nros setup fetches the kernel and its apps tree, and nros run links your
node into a bootable kernel. You write the talker in Rust, C or C++; pick a tab
and every tab on the page follows.
What you need
- A Linux host with the install done, so
nrosis on yourPATH. - ROS 2 with
ros-<distro>-rmw-zenoh-cpp: Humble on Ubuntu 22.04, Jazzy on 24.04 (which edition). ROS 2 provides the zenoh router the board talks to, and the message definitions the build generates the talker’s code from. - Two host packages the NuttX kernel build uses: the kconfig-frontends
tools, which configure the kernel, and
unzip. The provision step installs them for you when you allow it.
No board, no cable: QEMU’s user-mode network carries the guest’s ethernet to your machine, with no TAP device to create. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
nros setup qemu-armv7a-nuttx --rmw zenoh --sudo
That fetches the NuttX cross-compiler, the QEMU that emulates the machine, and
the NuttX kernel and apps sources into a shared store under ~/.nros. Before
it downloads anything it names the host packages that are missing, and
--sudo lets it run the one install command it composed for your package
manager (sudo apt-get install -y kconfig-frontends-nox unzip on Debian or Ubuntu).
Leave --sudo off and it only prints that command. It installs no router:
the router is ROS’s rmw_zenohd.
Scaffold the project
Source ROS 2 first, in the shell you scaffold from. nros new writes
the ROS 2 edition the project speaks, and it takes it from the sourced
ROS 2; with none sourced, it writes Humble. On Jazzy, source
/opt/ros/jazzy/setup.bash instead:
source /opt/ros/humble/setup.bash
nros new nx_ws --board qemu-armv7a-nuttx --template talker --lang rust
cd nx_ws
nros new nx_ws --board qemu-armv7a-nuttx --template talker --lang c
cd nx_ws
nros new nx_ws --board qemu-armv7a-nuttx --template talker --lang cpp
cd nx_ws
That wrote a workspace with two packages: src/nx_node/, the talker, a
library with no main() that names no board, and src/nx_node_bringup/,
which says what the talker runs on. The NuttX task that runs your node is
generated from the bringup when you build, so you do not need to open it for
this starter.
Run it in QEMU
The image dials a zenoh router on your host through QEMU’s user-mode
network: the guest reaches your host as 10.0.2.2, on port 7447. nros run
starts that router itself, listening on every interface so the guest’s
connection arrives, and stops it when the run ends. If a router already runs
on that port, nros run --router auto uses it instead.
In the workspace, source ROS 2 and build and run the talker. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell:
source /opt/ros/humble/setup.bash
nros run nx_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the kernel with your node linked in (the first build
configures NuttX from the board’s defconfig and takes several minutes; later
builds take seconds), then boots it on QEMU’s virt machine with virtio-net
on the user-mode network. The image starts its application itself, so what you
see is the talker on the NuttX console. It keeps running until you press
Ctrl-C.
See it in ROS 2
Leave nros run going; its router stays up while it runs. In a second
terminal:
source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
ros2 topic echo /chatter std_msgs/msg/String --qos-reliability best_effort
data: 'Hello World: …'
The talker’s publisher is reliable, as ros2 topic info -v /chatter shows.
Asking for best-effort receives from a publisher of either kind, so the
command works whatever QoS a publisher offers.
If it doesn’t work
nros setupstops and nameskconfig-frontends-noxorunzip: you left--sudooff. Run the command it printed, or run the step again with--sudo.- No
Publishing:line within a minute of boot: the talker did not reach the router. Its first line usually appears within about six seconds of boot. If you run your own router with--router auto, check that it listens on0.0.0.0:7447: one on127.0.0.1is out of the guest’s reach. nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it.- Everything else: Troubleshooting - First 10 Minutes.
Next
- The image’s configuration, a NuttX tree of your own, and real hardware: NuttX Arm and RISC-V.
- The same NuttX on a RISC-V machine: NuttX in QEMU (RISC-V).
- The project, grown: the Tutorial.