Search code examples
c++cstm32jtag

Using debugger swo on stm32


As the title suggest I would like to use swo for debugging on an stm32F1 device without the use of st-link utils.I think I have flashed the code to send messages via swo on my chip but I can not establish a connection with the correct port as some tutorials suggested I use putty with the telnet port 2332 . Specifics about my configuration:cubemx swo configuration Relative code on my main

    int _write(int file, char *ptr, int len)
{
    int DataIdx;
    for (DataIdx = 0; DataIdx < len; DataIdx++)
    {
        __io_putchar(*ptr++);
    }
    return len;
}

...

   int main(){
    while (1)
      {
        printf("Hi\n");
      }
}

I have seen some tutorials using eclipse configurations or st-link utils but I have a very custom toolchain (I use conan, obko cmake configurations https://github.com/ObKo/stm32-cmake , ocb and linux) for the sole purpose of using c++ 2017 and libraries like boost so I can not use st-link utils.


Solution

  • The problem with my configurations was that I didn't have a parser on my computer for the ITM messages so even after having the right configurations on the chip when I was opening the port to communicate with the chip my terminal was empty of messages . Hopefully I found this very helpful parser on github so all I had to do after compiling the program with the above configurations was to run openocd with configuring two options about the frequency of the f1 chip and the fact that ITM port was open (here is my .cfg file ):

    source [find interface/stlink-v2.cfg]
    source [find target/stm32f1x.cfg]
    init
    tpiu config internal - uart off 72000000
    itm ports on
    

    and on another terminal I runed the parser script from github python3 swo_parser.py