Get started on ThreadX in QEMU (RISC-V 64)
Needs first: Install
Status: Verified in emulator (daily). From the board support registry:
nros-board-threadx-qemu-riscv64; Board Support Levels explains the words.
This starter puts a talker on Eclipse ThreadX (formerly Azure RTOS
ThreadX), on QEMU’s 64-bit RISC-V virt machine, and shows its messages
arriving in ROS 2. ThreadX runs the talker as a thread, with NetX Duo as its
TCP/IP stack on a virtio-net device. You install no RISC-V cross-compiler and
no QEMU of your own: nros setup fetches both.
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.
No board, no cable and no root access: QEMU’s user-mode network carries the guest’s ethernet to your machine, with no TAP device to create. WiFi is deferred to the Zephyr 4.4 line, so no starter opens over WiFi yet.
Provision
nros setup rv-virt-threadx --rmw zenoh
That fetches the RISC-V 64 cross-compiler, the qemu-system-riscv64 that
emulates the machine, and the ThreadX and NetX Duo sources into a shared store
under ~/.nros. Most of it is prebuilt for your host; what is not is built
from source the first time, and nros setup --dry-run shows which. 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 tx_ws --board rv-virt-threadx --template talker --lang rust
cd tx_ws
nros new tx_ws --board rv-virt-threadx --template talker --lang c
cd tx_ws
nros new tx_ws --board rv-virt-threadx --template talker --lang cpp
cd tx_ws
That wrote a workspace with two packages:
tx_ws/
└── src/
├── tx_node/ # the talker: manifest, build file, source
└── tx_node_bringup/ # what it runs on: board, RMW
tx_node is the talker, a library with no main() that names no board. It
publishes std_msgs/String on /chatter once a second. tx_node_bringup
says what the talker runs on. The ThreadX startup that runs your node is
generated from it when you build, so you do not need to open it for this
starter.
Run it in QEMU
The image dials a zenoh router on your host through QEMU’s user-mode
network: the guest reaches your host as 10.0.2.2, on port 7447. nros run
starts that router itself, listening on every interface so the guest’s
connection arrives, and stops it when the run ends. If a router already runs
on that port, nros run --router auto uses it instead.
In the workspace, source ROS 2 and build and run the talker. This first run records the ROS 2 prefix in the workspace, so later runs of it need no sourced shell:
source /opt/ros/humble/setup.bash
nros run tx_node
Publishing: 'Hello World: 1'
Publishing: 'Hello World: 2'
nros run builds the firmware (the first build compiles ThreadX, NetX Duo and
nano-ros, a few minutes; later builds take seconds), then boots it with the
store’s qemu-system-riscv64 on the virt machine, the UART on your terminal
and virtio-net on the user-mode network. 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; its router stays up while it runs. 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.
If it doesn’t work
- No
Publishing:line within 30 seconds of boot: the talker did not reach the router. QEMU’s boot and NetX Duo’s start take about 15 seconds. If you run your own router with--router auto, check that it listens on0.0.0.0:7447: one on127.0.0.1is out of the guest’s reach. nros runstops at once and namesAMENT_PREFIX_PATH: this shell has not sourced ROS 2, and no earlier build of the workspace recorded it.nros runnames noqemu-system-riscv64: run thenros setup rv-virt-threadxstep again, which installs it.- Everything else: Troubleshooting - First 10 Minutes.
Next
- The image’s configuration, sched tasks, and real hardware: ThreadX RISC-V 64.
- The same ThreadX as a program on this machine: ThreadX Linux simulator.
- The project, grown: the Tutorial.