cancel
Showing results for 
Search instead for 
Did you mean: 

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

Noname1937
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

>>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?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

6 REPLIES 6
Pavel A.
Evangelist III

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

-- pa

>>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?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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

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.

Bu how do people get the st link v2 to work with printf when the jtag doesn't have an SWO pin? only an SWDIO and SWIM.

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