ThreadX Linux simulator
Needs first: Run a talker on an emulated board, What you just built, Get started on the ThreadX Linux simulator
Status:
nros-board-threadx-linux: Verified on host (daily). From the board support registry; Board Support Levels explains the words.
The starter scaffolded a talker for
board = "threadx-linux", Eclipse ThreadX’s Linux port, and ran it as an
ordinary host process. This page covers what comes after it: the image’s
configuration, what is particular to the simulator, ThreadX’s sched
tasks, and the native build. The same node package runs on QEMU’s RISC-V
machine with one changed line; the ThreadX RISC-V 64 page
covers that board.
Configure the platform
The bringup’s src/tx_node_bringup/system.toml holds one image. With a
locator added, it reads:
[system]
name = "tx_node"
rmw = "zenoh"
domain_id = 0
[[component]]
pkg = "tx_node"
class = "tx_node::Talker"
name = "tx_node"
[image.threadx]
board = "threadx-linux"
locator = "tcp/127.0.0.1:9000"
locator is where the router is. With no locator, as scaffolded, the
image dials the board’s default, tcp/127.0.0.1:7447, and nros run
starts ROS’s rmw_zenohd on whichever port the image dials. To use a router
you already run, pass --router <its locator>.
The file is the same whatever the node’s language. A C node’s
CMakeLists.txt declares targets and nothing about the deployment, and its
package.xml carries no board. What the image does not state comes from the
board crate’s defaults; Configure an image
lists the keys and knobs.
Both ThreadX boards can be images of one bringup, so one workspace builds for the simulator and for QEMU:
[image.threadx_rv]
board = "rv-virt-threadx"
locator = "tcp/10.0.2.2:9400"
os_config = ["board-net.toml"] # [eth0] network = "qemu", host = 15
With two images, nros run tx_node no longer picks one, so name the image:
nros run threadx or nros run threadx_rv.
Board notes
- The kernel runs inside one Linux process. ThreadX’s threads are
scheduled by its Linux port inside that process, so the build is for your
host and has no cross-compiler or emulator. A Rust node’s entry is still
#![no_std]. - The network is the host’s. NetX Duo’s BSD socket layer
(
nx_bsd_*) sits on the host’s TCP stack, so the image reaches a router on loopback. - A veth pair is optional.
nros setup threadx-linuxcreates no network interface. Without one, the image uses the loopback path, which is all the starter needs. Bring up atap-tx0veth pair by hand (ip link add … type veth …) only when you need a separate host link. - The console is standard output.
- The upstream Linux port types
ULONGas 4 bytes, as NetX Duo expects, so this board needs none of the RISC-V 64 board’s architecture port.
Run sched tasks
ThreadX runs a workspace’s sched tasks: one executor per task, all sharing
one session, each with its own priority and a stack carved from ThreadX’s byte
pool. Declare a task’s ThreadX priority in a [tasks.<name>.threadx] table of
the bringup’s system.toml:
[tasks.control]
class = "real_time"
spin_period = "1000us"
[tasks.control.threadx]
priority = 8
[tasks.telemetry]
spin_period = "10000us"
[tasks.telemetry.threadx]
priority = 16
preempt_threshold = 10 # ThreadX only
time_slice = "5000us"
ThreadX priorities follow the kernel’s own convention: a lower number is a
higher priority. The generated entry boots the lowest-priority task first,
which then takes its declared priority. preempt_threshold and time_slice
are ThreadX’s own mechanisms and lower to nothing on other platforms.
Pick a scheduling model assigns
nodes to tasks and explains the classes.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run tx_node --dry-run --why
The target is a host process, its console is standard output, and its link
is the image’s locator on loopback. --why names where each fact came
from.
Drive the native build yourself
nros build writes the generated ThreadX entry under build/ and runs
cargo or CMake on it. Print the exact commands without building:
nros build --dry-run
To write the generated entry without building, for an IDE or a CI cache
step, run nros configure. Never edit what either command writes under
build/: the next build regenerates it.
If it doesn’t work
nros runstops at once and names the router:rmw_zenohdis not on the path, or another router holds the port. Source ROS 2, or stop the other router.- No
Publishing:line on a first run: a cold first build takes about 80 seconds before the first publish. - Everything else: Troubleshoot.
Reference
- The
threadx-linuxboard’s support evidence. - Copy-out talkers:
examples/threadx-linux/rust/talker/andexamples/threadx-linux/c/talker/. The listener, service and action are thethreadx_*image rows of the language workspaces,examples/workspaces/{rust,c,cpp}. - The board crate:
packages/boards/nros-board-threadx-linux/. - Scheduling wiring matrix: ThreadX’s priority levels beside the other platforms’.