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

Get started on mps2-an385 in QEMU (FreeRTOS)

How-to · Level 1: First contact

Needs first: Install

Status: Verified in emulator (daily). From the board support registry: nros-board-mps2-an385-freertos; Board Support Levels explains the words.

This starter puts a talker on FreeRTOS, on an emulated Arm Cortex-M3 board, and shows its messages arriving in ROS 2. The board is Arm’s MPS2-AN385 in QEMU, the board this book teaches nano-ros on: it costs nothing and behaves like a real microcontroller. FreeRTOS runs the talker as a task, with lwIP as its network stack on the board’s emulated LAN9118 ethernet. 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 nros is on your PATH.
  • 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.

No board, no cable and no root access: QEMU’s user-mode network carries the board’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 mps2-an385-freertos --rmw zenoh

That fetches the Arm cross-compiler, the QEMU that emulates the board, and the FreeRTOS kernel and lwIP sources into a shared store under ~/.nros. Nothing is installed system-wide. 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 fr_ws --board mps2-an385-freertos --template talker --lang rust
cd fr_ws
nros new fr_ws --board mps2-an385-freertos --template talker --lang c
cd fr_ws
nros new fr_ws --board mps2-an385-freertos --template talker --lang cpp
cd fr_ws

That wrote a workspace with two packages:

fr_ws/
└── src/
    ├── fr_node/          # the talker: manifest, build file, source
    └── fr_node_bringup/  # what it runs on: board, RMW

fr_node is the talker, a library with no main() that names no board. It publishes std_msgs/String on /chatter once a second. fr_node_bringup says what the talker runs on. The FreeRTOS startup task that runs your node is generated from it 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 fr_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'

nros run builds the firmware (the first build cross-compiles nano-ros, the FreeRTOS kernel and lwIP, about three minutes for C and five for Rust; later builds take seconds), then boots it in QEMU with the board’s LAN9118 on the user-mode network. What it prints is the board’s 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

It prints a data: line per message:

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

  • No Publishing: line within 30 seconds of boot: the board did not reach the router. A cold boot through FreeRTOS, lwIP and the zenoh session takes 10 to 15 seconds. If you run your own router with --router auto, check that it listens on 0.0.0.0:7447: one on 127.0.0.1 is out of the guest’s reach.
  • Failed to open session on the console: the talker tried once, found no router, and stopped. With --router auto, start your router before nros run.
  • nros run stops at once and names AMENT_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 board’s configuration, its own locator and address, and real hardware: FreeRTOS on mps2-an385.
  • The same FreeRTOS on this machine, with no QEMU: FreeRTOS POSIX.
  • The project, grown: the Tutorial starts from this same talker on this same board.