-
-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Hi. I am using defmt on top of rtt_target on esp32s3, launched by probe-rs. I am trying to set up multiple rtt channels, one for defmt and another for other information. However as soon as I declare the existence of another up channel in rtt_target::rtt_init!
macro, defmt output seems corrupted.
My set up looks like this:
#[esp_hal_embassy::main]
async fn main(spawner: Spawner) {
let mut channels = rtt_target::rtt_init! {
up: {
0: { size: 1024, mode: ChannelMode::NoBlockSkip, name: "Terminal" }
1: { size: 1024, name: "Perf" }
}
down: {
0: { size: 16, name: "Terminal" }
}
};
rtt_target::set_defmt_channel(channels.up.0);
defmt::info!("Hello from defmt.");
channels.up.1.write(b"Hello from Channel 2\n");
}
Output looks like this:
[Brminal] ~~ ~
16:03:54.429: ~[Perf ] Hello from Channel 2
But if I comment out the 2nd channel and 2nd print message, it all works as expected:
[INFO ] Hello from defmt.
I run probe-rs with:
$ probe-rs run --chip=esp32s3 --preverify --always-print-stacktrace --no-location --catch-hardfault /path/to/target/debug/program
Edit: it seems like there is some data race going on. Sometimes, the output works, sometimes not. Sometimes, adding seemingly noop code makes it work, and sometimes not. Eg adding if core::hint::black_box(1 == 0) { defmt::println!("{}", String::new()); }
in some random function suddenly made it works, but then adding another line broke it again.