Skip to main content
PHolt.1
Senior
August 1, 2024
Question

Any way to receive SWV ITM debug data without Cube being in the post-F11 debug context?

  • August 1, 2024
  • 5 replies
  • 1686 views

Currently the Cube SWV ITM debug console does not receive the data unless you have built the project using the build+debug option F11.

This is a problem sometimes, when running code which contains the debug statements but which wasn't loaded from Cube IDE.

Or maybe there is some other program which can interface to STLINK V3 and receive this data?

    This topic has been closed for replies.

    5 replies

    AScha.3
    Super User
    August 1, 2024

    You can use CubeProgrammer and connect to SWV :

     

    AScha3_1-1722501038670.png

    + just set real cpu frequ.

    If you feel a post has answered your question, please click on " Best Answer ".
    Tesla DeLorean
    Guru
    August 1, 2024

    ST-LINK Utilities used to do it and STM32 Cube Programmer can do so now.

    Code running on MCU can set up ITM, DWT and FPB too depending on how hard core bare metal you want to go.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    PHolt.1
    PHolt.1Author
    Senior
    August 1, 2024

    Yes this is great. I have the ST Link Utility and that picks up the data

    PHolt1_0-1722541284828.png

    Curiously it reboots the target when it starts up but that's OK.

    Thank you all!

     

     

    Tesla DeLorean
    Guru
    August 2, 2024

    Not sure if ST-LINK Utilities offer connectivity options, ie so you can hot-plug

    STM32 Cube Programmer might have more, and less disruptive, connection modes.

    There should be a SWV tab/pane on the newer versions

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Rim LANDOLSI
    ST Employee
    August 2, 2024

    Hello @PHolt.1 ,

     

    Yes, it is possible to receive Serial Wire Viewer debug data. These steps could be helpful:

    1. Enable the SWV feature in the debug configuration.
    2. Ensure that the clock settings are correctly configured to provide a stable clock for the SWV.
    3. Configure ITM by adding some code to "syscalls.c"
      #include "stm32f4xx.h"
      
      
      in the write function:
      
      __attribute__((weak)) int _write(int file, char *ptr, int len)
      {
       (void)file;
       int DataIdx;
      
       for (DataIdx = 0; DataIdx < len; DataIdx++)
       {
       __io_putchar(*ptr++);
       ITM_SendChar(*ptr++);
       }
       return len;
      }
      
      
    4. Click Debug to start a debug session.

    In the debug session, open the SWV IT Data Console window and configure the port for receiving data, then click the button to run the view.

    Thanks,

    Rim