Rust std on ThreadX - distribution 2
2026-08-22
The second distribution adds a minimal amount of networking support. Like, really minimal. You can bind UDP sockets, then use send_to and receive_from with those sockets. Despite this limitation, there's interesting work available outside the standard library!
All of this builds on the std support of distribution 1 and the NetX Duo bindings. The distribution's build instructions change, since you now build NetX Duo and FileX when building the standard library.
fusible gains a netx-duo feature with high-level bindings for NetX Duo. It's is on the rustc-dep-of-std branch. The bindings are incomplete and missing documentation, having just enough to test driver development and UDP sockets.
The fusible bindings let folks implement their network drivers in separate packages. My ENET implementation for i.MX RT MCUs is available in the demos package. The demo for the iMXRT1170EVK implements a little UDP loopback thread, and you can ping the board. It's still fairly straightforward to use the standard library, with the only new aspect being the magic hardware-specific import.
use rust_threadx_imxrt1170evk as _;
use std::{net::UdpSocket, thread};
fn main() {
thread::scope(|scope| {
thread::Builder::new()
.stack_size(512)
.spawn_scoped(scope, count)
.unwrap();
udp_loopback();
})
}
fn count() -> ! {
let mut count = 0_usize;
loop {
println!("Hello world! The count is {count}");
count = count.wrapping_add(1);
std::thread::sleep(std::time::Duration::from_millis(500))
}
}
fn udp_loopback() -> ! {
let mut buffer = [0_u8; 1024];
let socket = UdpSocket::bind("192.168.5.1:5678").unwrap();
loop {
let (amt, src) = socket.recv_from(&mut buffer).unwrap();
let msg = &buffer[..amt];
println!(
"Received {amt} bytes from {src}: \"{}\"",
str::from_utf8(msg).unwrap()
);
socket.send_to(msg, &src).unwrap();
}
}Out of tree testing with iperf (2) suggests this ENET driver achieves around
- 90Mbps in TCP transmit & receive.
- 95Mbps in UDP transmit & receive with a 1470 byte MTU.
I still need to share the iperf embedded app so you can run your own tests.
That's about all I'm going to get done before RustConf, now less than two weeks away! Hope to see you there.