beginner Atollic question on printf/puts embedded STM32

Share code examples or discuss embedded software, including device drivers, interrupt handlers, middleware and application code.

Moderators: Markus Girdland, Mattias Norlander

treecatt
Posts: 39
Joined: Mon Jul 24, 2017 6:56 am

Re: beginner Atollic question on printf/puts embedded STM32

Postby treecatt » Tue May 08, 2018 9:54 pm

You are redirecting print() to ITM channel 0. ITM uses the SWO pin for trace output. SWDIO is used for debugging (i.e. stop, reset, run to cursor, breakpoints, etc.) The pins have two very different functions. I don't know of a way to redirect printf() to the SWDIO pin. Debugger probably would go nuts trying to figure out what it is receiving if you did. :)

georgeb
Posts: 3
Joined: Sat May 05, 2018 5:18 pm

Re: beginner Atollic question on printf/puts embedded STM32

Postby georgeb » Thu May 10, 2018 5:15 pm

treecatt
This is also my understanding, that usage of SWO pin is not optional.

tompe
It would be very interesting if we could get printf debug messages only with SWIO, SWCLK, GNR, PWR, even using other IDE as AC6.

I have a product that uses SWO pin, so I cannot use it for trace.

RockDeng
Posts: 7
Joined: Fri Jul 20, 2018 8:33 am

Re: beginner Atollic question on printf/puts embedded STM32

Postby RockDeng » Wed Aug 01, 2018 8:56 am

So on-board st-link didn't work, you have to use a standalone st-link v2? I have tested printf with Nucleo-64 F103RB board and set the debug port to Trace asynchronous Sw, still nothing show up in SWV Console.

tompe
Posts: 10
Joined: Sat May 05, 2018 12:06 pm

Re: beginner Atollic question on printf/puts embedded STM32

Postby tompe » Wed Aug 01, 2018 2:03 pm

No, I just used one of these cheap china clones (look like a USB stick) that do not provide an SWO pin. To be precise, the used chip does as it is the same, they just didn't route it so you need to solder a wire directly onto the chips pin.

As far as I know, these on-board programmers should be identical to the original stand-alone ones.
Unfortunately, I do not own a Nucleo but a quick look into the manual (ST UM1724) mentions you have to adjust solder bridges (SB15) in order to connect SWO of your programmer with pin PB3 of your STM32. (see page 26 in manual)
I don't know the default state, but I assume it is open so you can use PB3 for other things.

Hope this helps.

RockDeng
Posts: 7
Joined: Fri Jul 20, 2018 8:33 am

Re: beginner Atollic question on printf/puts embedded STM32

Postby RockDeng » Fri Aug 03, 2018 3:18 am

Thank you very much for you reply.

I confirmed that on-board st-link works.
The reason why the printf didn't works on my situation is that there is no definition of printf in my project. I use the cubeMX to generate the project, but the project only contain the declaration of printf and no definition of the function, so after adding tiny_prinft.c which contain definition of printf to the project, everything goes well.

I note that the SWO pin is a essential hardware configuration for implementing this kinda printf and some developer has neglected it. Nucleo-F103rb board is great for this testing because the SWO pin of the on-board programmer is connected to the PB3 directly.


Return to “Embedded target code development discussions”

Who is online

Users browsing this forum: No registered users and 2 guests