Get started on mps2-an385 in QEMU (bare-metal)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-mps2-an385; Board Support Levels explains the words.
This starter puts a talker on an Arm Cortex-M3 board with no operating system at all, emulated by QEMU, and shows its messages arriving in ROS 2. The board is Arm’s MPS2-AN385, which QEMU models closely. No one buys one: it is the board this book teaches nano-ros on, because it costs nothing and behaves like a real microcontroller. The talker runs as one loop with no scheduler under it, which is what “bare-metal” means. 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.
Nothing else: no board, no cable, no root access. The board talks to your machine over its emulated serial port, the way a real board’s first program does. Its network comes later, under Next. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
nros setup mps2-an385-baremetal --rmw zenoh
That fetches the Arm cross-compiler, the QEMU that emulates the board, and,
for a Rust talker, the thumbv7m-none-eabi target 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 bm_ws --board mps2-an385-baremetal --template talker --lang rust --rmw zenoh
cd bm_ws
nros new bm_ws --board mps2-an385-baremetal --template talker --lang c --rmw zenoh
cd bm_ws
nros new bm_ws --board mps2-an385-baremetal --template talker --lang cpp --rmw zenoh
cd bm_ws
That wrote a workspace with two packages:
bm_ws/
└── src/
├── bm_node/ # the talker: manifest, build file, source
└── bm_node_bringup/ # what it runs on: board, RMW
bm_node is the talker, a library with no main() that names no board. It
publishes std_msgs/String on /chatter once a second. bm_node_bringup
says what the talker runs on. You do not need to open it for this starter.
Run it in QEMU
Source ROS 2, then build and run. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell (the router still comes from ROS 2):
source /opt/ros/humble/setup.bash
nros run bm_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the firmware (the first build compiles nano-ros for the
Cortex-M3 and takes about five minutes; later builds take seconds), boots it
in QEMU with the board’s serial port connected to a terminal device on your
host, and starts the router on that device. 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. 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.
The router nros run started also listens where a ROS 2 node on this machine
looks for one, so nothing else needs to be configured.
If it doesn’t work
nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it. Source it and run again.nros runstops at once and names the router: it could not findrmw_zenohd. Source ROS 2 in that shell, and installros-<distro>-rmw-zenoh-cppif it is missing.- No
Publishing:line within a minute of boot: the router started but the board did not reach it.nros runnames the router’s log underbuild/nros/run/when it stops. A router you started yourself on the same port is the usual cause. - The talker stalls after you change it: bare-metal has no preemption, so a callback that runs long stops every other callback until it returns.
- Everything else: Troubleshooting - First 10 Minutes.
Next
- The same board over its network, and its configuration: Bare-metal Cortex-M3.
- The same board with an RTOS: mps2-an385 in QEMU (FreeRTOS).
- The project, grown: the Tutorial starts from this same talker, on this board with FreeRTOS under it.