ThreadX RISC-V 64
Needs first: Run a talker on an emulated board, What you just built, Get started on ThreadX in QEMU (RISC-V 64)
Status:
nros-board-threadx-qemu-riscv64: Verified in emulator (daily). From the board support registry; Board Support Levels explains the words.
The starter scaffolded a talker for
board = "rv-virt-threadx", Eclipse ThreadX with its NetX Duo TCP/IP stack
on QEMU’s RISC-V 64 virt machine, and heard it from ROS 2. This page covers
what comes after it: the image’s network configuration, what is particular to
this board and its architecture port, and the native build. Sched tasks are
declared the same way on both ThreadX boards; the
ThreadX Linux simulator page shows them.
Configure the platform
The guest boots behind QEMU’s user-mode network, so its image states the router’s address as the guest sees it and names a board network file for its own address:
[image.threadx]
board = "rv-virt-threadx"
locator = "tcp/10.0.2.2:9400"
os_config = ["board-net.toml"]
and board-net.toml, beside system.toml in the bringup:
[eth0]
network = "qemu"
host = 15
10.0.2.2 is QEMU’s gateway, which forwards to the host, so a router
listening on the host’s 0.0.0.0 at the locator’s port is reachable. An
image that states no address gets QEMU’s first guest address, 10.0.2.15;
host = N picks 10.0.2.N. With no locator, as scaffolded, the image
dials tcp/10.0.2.2:7447. Start the router as the starter did, with its
listen/endpoints port changed to the one the image dials (9400 here).
The node package does not change between this board and the
Linux simulator: only the image’s board line and its
network keys do, and one bringup can hold an image for each.
Board notes
- QEMU’s
virtmachine, a 64-bit RISC-V core. The UART is on standard input and output, and the network is a virtio-net device on QEMU’s user-mode network.nros setup rv-virt-threadxfetches the RISC-V 64 cross-compiler andqemu-system-riscv64. - Three ThreadX packages in three layers.
nros-board-threadxis the family driver (the kernel and NetX Duo build, and the boot path both boards call).nros-board-threadx-port-riscv64is the architecture port.nros-board-threadx-qemu-riscv64is the board overlay: defaults, console, exit, panic and network bring-up. The generated entry depends on the board crate, so nothing you write names any of them. - Why the architecture port exists. Upstream’s RISC-V 64 port types
ULONGas 8 bytes, and NetX Duo’s packet code assumes 4. nano-ros retypes it tounsigned int, as upstream’s own Linux and AArch64 ports do, and that shifts the offsets the port’s context-switch assembly loads, so the assembly is forked with it. A second RISC-V 64 ThreadX board reuses the port unchanged and writes only an overlay; see Add a board. - Search the port’s
inc/first if you build ThreadX outsidenros build, before$THREADX_DIR/ports/risc-v64/gnu/inc. In the wrong order the build succeeds against the 8-byteULONGand packets corrupt at run time. A_Static_assert(sizeof(ULONG) == 4, …)in the board’s hooks turns the mistake into a build failure. - The app thread’s stack is 512 KiB. Change it with
NROS_MEMORY_APP_STACK_BYTES=<bytes>in the build environment, or with[image.<id>.knobs.memory] app_stack_bytes = <bytes>insystem.toml. Both reach a cargo image. A CMake image keeps 512 KiB. A sched task declared with nostack_bytesgets the same size. - No physical ThreadX board ships. A vendor board (Renesas Synergy, i.MX RT and others) is a board package of your own on the family crate, flashed with that vendor’s tools; see Flash a real board.
Read the run plan
From the starter’s workspace, print the plan nros run follows:
nros run tx_node --dry-run --why
The plan names the QEMU runner and the qemu:rv-virt machine, the console on
the guest’s UART, and the link to the router at the image’s locator.
--why names where each fact came from, the board’s descriptor for most of
them.
Drive the native build yourself
The first build compiles ThreadX and NetX Duo, about three minutes; later builds take seconds. Print the exact cargo or CMake commands, and the QEMU line the run uses, without building:
nros build --dry-run
nros configure writes the generated entry without building. Neither
command’s output under build/ is yours to edit.
Multi-sched-task scheduling
ThreadX supports the multi-sched-task workspace scheduling model: declare per-sched-task ThreadX priorities in the bringup’s
system.toml with [tasks.<name>.threadx] priority tables, and
the generated entry routes the app onto run_sched_tasks — one executor per
sched task, all sharing one session, with per-sched-task stacks carved from the
ThreadX byte pool. ThreadX priorities follow the native convention:
lower number = higher priority. Sched tasks are sorted descending by
raw priority number, so sched_tasks[0] (the numerically-largest, i.e.
lowest-priority sched task) boots first and then adopts its declared
priority. See Scheduling Models
for the mechanics.
If it doesn’t work
- The image boots and never publishes: no router on the host’s
0.0.0.0at thelocator’s port. A router on127.0.0.1is unreachable from the guest. - Corrupted packets in a ThreadX build of your own: the include order above.
- Everything else: Troubleshoot.
Reference
- The
rv-virt-threadxboard’s support evidence. - Copy-out talker:
examples/rv-virt-threadx/rust/talker/. The other roles are theriscv_threadx_*image rows of the language workspaces,examples/workspaces/{rust,c,cpp}. - The board crate:
packages/boards/nros-board-threadx-qemu-riscv64/.