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

FreeRTOS on mps2-an385

How-to · Level 2: Building real applications

Needs first: Run a talker on an emulated board, What you just built, Get started on mps2-an385 in QEMU (FreeRTOS)

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

The starter scaffolded a Rust, C or C++ talker for board = "mps2-an385-freertos", FreeRTOS with the lwIP network stack on QEMU’s Cortex-M3, and heard it from ROS 2. This page covers what comes after it: the image’s network configuration, what is particular to the board, waiting for a late router, the run plan, and the native build. The same kernel runs as a Linux process on the FreeRTOS POSIX board, for Rust, C and C++ nodes.

Configure the platform

Board, RMW, domain and network identity are declared in the bringup’s system.toml and compiled into the image: there is no configuration file on the device. With a locator and an address added, the image reads:

[image.freertos]
board = "mps2-an385-freertos"
locator = "tcp/10.0.2.2:7800"
os_config = ["board-net.toml"]

and board-net.toml, beside system.toml in the bringup:

[eth0]
network = "qemu"
host = 15

locator is where the router is. The guest reaches the host’s router through QEMU’s gateway, 10.0.2.2, and QEMU forwards the guest’s 10.0.2.2:<port> to the host’s port. The image above dials port 7800, so start the router as the starter did with its listen/endpoints port changed to 7800. With no locator, as scaffolded, the image dials tcp/10.0.2.2:7447. The file is the same whatever language the node is written in: nothing about the deployment lives in Cargo.toml, CMakeLists.txt or package.xml.

Switching board is editing the image’s board and building again. nros build picks the cross-toolchain file the board names, and the generated entry brings the board crate, its RMW and the FreeRTOS platform layer. Changing board to "mps2-an385-baremetal" builds the same Rust node with no RTOS.

Task stacks and priorities come from the board crate’s defaults. Configure an image lists the keys, and Pick a scheduling model declares sched tasks with [tasks.<name>.freertos] priorities, where a larger number is more urgent.

Wait for a late router

A FreeRTOS image tries once to open its session and stops with Failed to open session when no router answers, so the starter starts the router first. An image that should wait for a router started later, as on a bench where the board powers up first, sets a knob:

[image.freertos.knobs.zenoh]
connect_forever = true        # or connect_timeout_ms = 30000 for a bounded wait

Board notes

  • QEMU’s MPS2-AN385, a Cortex-M3, with FreeRTOS and lwIP. The board crate, nros-board-mps2-an385-freertos, builds the kernel, lwIP and the LAN9118 driver. The generated entry, the FreeRTOS startup task that runs your node, depends on it, so nothing you write names it.
  • Rust, C and C++. The Rust side’s triple (thumbv7m-none-eabi), link group, QEMU runner and [patch.crates-io] rows are the board’s, written under build/. A C or C++ node package names no board in its CMakeLists.txt.
  • QEMU’s user-mode network, no TAP. The 10.0.2.0/24 subnet and its gateway 10.0.2.2 are QEMU’s own, so the board needs no root access and no host bridge.
  • The console is semihosting, printed on your terminal by QEMU.
  • Nothing is flashed. No in-tree FreeRTOS board is flashed by a documented flow. A FreeRTOS board of your own is a board package on the FreeRTOS family crate, flashed with its vendor’s tools; see Add a board and Flash a real board.

Read the run plan

From the starter’s workspace, print the plan nros run follows:

nros run fr_node --dry-run --why

The plan names the QEMU runner and the qemu:mps2-an385 machine, the semihosting console, and the link to the router at the image’s locator. --why names where each fact came from.

Drive the native build yourself

The first build cross-compiles nano-ros’s dependencies, the FreeRTOS kernel and lwIP: about three minutes for C or C++, five for Rust. Print the exact cargo or CMake commands without building:

nros build --dry-run

nros configure writes the generated entry without building, for an IDE or a CI cache step. Never edit what either command writes under build/. For a CMake tree that is not a nano-ros workspace, see Build inside an existing CMake or vendor tree.

If it doesn’t work

  • Failed to open session: no router answered on the host’s 0.0.0.0 at the locator’s port. Start it first, or set connect_forever.
  • The router runs and the image never connects: the router listens on 127.0.0.1, which the guest cannot reach.
  • Everything else: Troubleshoot.

Reference

Design background

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