This is for future-me, and for future internet searchers.
Using probe-rs to attach to an STM32G0 family MCU to read log messages via defmt over RTT, I encountered the following error:
WARN probe_rs::util::rtt::client: RTT read pointer changed, re-attaching
WARN probe_rs::rtt::channel: RTT channel name points to unrecognized memory. Bad target description?
WARN probe_rs::rtt::channel: RTT channel name points to unrecognized memory. Bad target description?
This occurred the same using defmt_rtt or rtt_target.
Reading through the probe-rs logs, it seemed that at some point after correctly reading the RTT
memory block, it would start reading junk where it expected to read a SEGGER RTT
identifier.
I am using lilos, and in its executor it uses the WFI instruction to sleep. By trying different configurations, I found that the error only occurs when the lilos executor is run.
On many cortex processors, some options have to be enabled to keep the clocks running on the debug core during sleep, e.g., on the STM32G0, the following bits have to be set:
pac::DBGMCU.cr().modify(|w| {
w.set_dbg_standby(true);
w.set_dbg_stop(true);
});
What I learned today is that while this may keep the dbg core running, either the SRAM or something in the bus matrix still gets disabled unless there is at least one active master, and I guess the debug core does not count. So to keep access to SRAM via the debugger during sleep, you can enable a DMA:
pac::RCC.ahbenr().modify(|w| w.set_dma1en(true));
With all three of these bits set, I can reliably read from SRAM over SWD and thus RTT is happy.
This probe-rs issue discusses the problem.