Arm Cortex: ITM Trace limitations via Terminal Window

06-Nov-2024

Printing characters via ITM can result in all the characters not being displayed in the Terminal Window.

For example, here's an ITM message ("\nTEST_12345678") and some possible outputs:


Explanation 

Tracing (observing the Terminal Window falls under this category), is a non-intrusive operation. It should not affect the CPU's behavior in any way. You can see what's happening inside the CPU while it's running, without interrupting its work. However, using breakpoints or manually halting the CPU interferes with its operation and violates the principle of non-intrusiveness.

Flushing data from the CPU to the debugger is device-specific. However, observations suggest these mechanisms often stop when the CPU is halted, preventing the debugger from receiving data. This only occurs when the CPU is stopped, which is why tracing focuses on a running CPU.

Solution

The trace buffer needs to be full to automatically flush its contents. To ensure you receive all the data, you can:

  • trigger a flush by printing another message in the Terminal Window or,
  • by adding a dummy character to the end of your current message.

This dummy character should be an ASCII NUL (represented by 0x00 or '\0' in C).


Make sure your application can parse NUL characters correctly. Most printf functions use NUL as the end of a string character.


More resources in winIDEA Help

Was this answer helpful?