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 POSIX

How-to · Level 2: Building real applications

Needs first: Run a talker on an emulated board, What you just built, Get started on FreeRTOS POSIX

Status: nros-board-freertos-posix: Verified on host (daily). From the board support registry; Board Support Levels explains the words.

The starter scaffolded a C talker for board = "freertos-posix" over Cyclone DDS and ran it: the FreeRTOS kernel, through its POSIX port, as an ordinary Linux process. This page covers what comes after it: the image’s configuration, what is particular to the simulator, moving a workspace between it and the emulated Cortex-M3, and the native build.

Configure the platform

The bringup’s src/fp_node_bringup/system.toml holds one image. Its [system] table and image read:

[system]
name = "fp_node"
rmw = "cyclonedds"
domain_id = 0

[image.freertos]
board = "freertos-posix"

The RMW comes from [system] rmw, and an image can override it with its own rmw key. This board takes cyclonedds or zenoh. Cyclone DDS runs inside the image’s process and finds its peers by multicast discovery on the host’s network, so the image has no locator and nothing runs beside it. With rmw = "zenoh" the image dials a zenoh router on the host, at tcp/127.0.0.1:7447 unless the image sets a locator. domain_id is the DDS domain, which ROS 2 calls ROS_DOMAIN_ID; a ROS 2 node on another domain does not see the talker.

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

Board notes

  • The kernel runs inside one Linux process. FreeRTOS’s POSIX port maps each task to a thread of that process and drives the tick from a host timer. Timing follows the host scheduler, so use this board to develop and test application logic, not to measure real-time behavior.
  • The network is the host’s. The image uses the host’s sockets, so it finds its DDS peers, or its zenoh router, with no network setup and no root access.
  • The console is standard output.

Move a workspace to the emulated board

The node package names no board, so the same C or C++ workspace builds for the mps2-an385 FreeRTOS board in QEMU. Add an image for it beside the first. That board’s starter runs zenoh, so the image names it, with the router it dials:

[image.freertos_qemu]
board = "mps2-an385-freertos"
rmw = "zenoh"
locator = "tcp/10.0.2.2:7447"

10.0.2.2 is QEMU’s gateway to the host. With two images, name the one you run: nros run freertos or nros run freertos_qemu. The second board needs its own provisioning, nros setup mps2-an385-freertos --rmw zenoh, and its router listens on the host’s 0.0.0.0; FreeRTOS on mps2-an385 covers it.

Read the run plan

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

nros run fp_node --dry-run --why

The target is a host process and its console is standard output. --why names where each fact came from.

Drive the native build yourself

nros build writes the generated FreeRTOS entry, the startup task that runs your node, under build/, then runs CMake on it with the board’s toolchain file. Print the exact commands without building:

nros build --dry-run

nros configure writes the generated entry without building, for an IDE or a CI cache step. 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

  • nros run says the router exited: another zenoh router already holds port 7447. Stop it; nros run starts one for a zenoh image on this board.
  • ros2 topic echo prints nothing: set RMW_IMPLEMENTATION=rmw_cyclonedds_cpp, and check that both sides use the same domain. A firewall that drops multicast also stops DDS discovery.
  • Everything else: Troubleshoot.

Reference