Skip to main content
Visitor II
May 8, 2020
Solved

Cannot get printf to work with SWD. What am I doing wrong?

  • May 8, 2020
  • 2 replies
  • 5112 views

Hello,

I am trying to write a simple hello world in order to make printf work with my setup. I have an own board, which I am programming it using ST-Link V3set (I also couldn't get it to work with ST-Link V2). I can program my board, debug it, I can see variables on live expression and everything is working perfectly.

The problem is when I try to redirect printf to ITM. I overwrite the _write function, I can step through it, I can see it writing to the register, but I get nothing on my console.

I basically followed this video and have also tried following articles, where everyone got it working. I have followed every possible step, but I still don't get anything on the console. What am I doing wrong?

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    >>What am I doing wrong?

    Ok, so 11 minute video, nothing about your board, not attached the project...

    >>I have an own board

    And what processor do you have on this board? Perhaps you have a schematic or wiring diagram?

    PB3/SWO needs to be connected

    The clock settings on the core and the debugger need to match properly, otherwise no output

    Do you have a working U(S)ART? Can you send data to both UART and ITM?

    2 replies

    Super User
    May 8, 2020

    Are you using latest CubeIDE (1.3.1) and same MCU as in the video (STM32F466)?

    -- pa

    Visitor II
    May 8, 2020

    Sorry it took me so long to answer. I have the latest CubeIDE version and I'm using STM32G431

    Super User
    May 10, 2020

    It looks like Cube IDE v 1.3.1 has regression with prints via ITM.

    If it does not work for you, try v. 1.2.

    -- pa

    Graduate II
    May 8, 2020

    >>What am I doing wrong?

    Ok, so 11 minute video, nothing about your board, not attached the project...

    >>I have an own board

    And what processor do you have on this board? Perhaps you have a schematic or wiring diagram?

    PB3/SWO needs to be connected

    The clock settings on the core and the debugger need to match properly, otherwise no output

    Do you have a working U(S)ART? Can you send data to both UART and ITM?

    Visitor II
    May 9, 2020

    Sorry, I am an idiot. It was a rough day, it was late here and I ended up forgeting.

    I am using STM32G431. And I think you might have solved my problem. SWO is not connected, the line was accidentally cut.