ST-Link SWV data stream is not always reliable
I'm using an ST-Link V2 to stream (over ITM) code coverage data from an STM32G4 via GDB Server on a PC.
This works fine most of the time (for many days), but the data stream sometimes drops some of the data. Adding a delay between calls to ITM_SendChar() on the target stops the data loss, so it appears as if the ST-Link and/or its driver are sometimes unable to keep up.
I'm not exactly sure how long the delay needs to be as I am not able to use timers to generate it (as this would invalidate the testing), so I've been using a simple volatile access loop:
for ( volatile unsigned delay=0; delay<500; ++delay );Based on timings and data length, that is introducing delays of about 20uS between the calls.
It seems strange to me that it works without the delay most of the time, especially as the target and PC are both running the same software at the time.
Is this a known limitation of the ST-Link that would be fixed with a "professional" trace probe?
