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

mrsolomo
Posts: 6
Joined: Wed Mar 07, 2018 9:44 am

Re: beginner Atollic question on printf/puts embedded STM32

Postby mrsolomo » Wed Mar 07, 2018 9:50 am

Hello,

I just switched from IAR/Keil IDE to Atollic Truestudio for code development on STM32F0.

I'm trying to use the printf function to output info on the console window but no success. Is the redirection to SWV console required for this?
In IAR/Keil, the printf function is more direct and doesn't need any redirection, it just works right away.

Isn't it the same with Atollic TrueStudio?

Also, I can't enable the SWV in the ST Link Debugger option. I've read somewhere that SWV is not supported by Cortex M0. So, how can I use the printf function if redirection to SWV is not allowed by the Hardware?

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby treecatt » Fri Mar 09, 2018 9:04 am

SWV requires a cpu core with the Trace Port Interface Unit. It is implemented in the Cortex-M3 and Cortex-M4 cores but not in the Cortex-M0 core. I did a little research. One way is to use RTT (Real-Time Transfer) but this does require a Segger J-Link debug probe. Your code also has to be set up as well. If your interested they have a decent explanation of the RTT technology at https://www.segger.com/products/debug-probes/j-link/technology/real-time-transfer/about-real-time-transfer/.

The educational version of the Segger J-Link is fairly inexpensive ($60 USD) but it is another piece of hardware you have to spend money on. If you are developing a commercial product then the J-Link gets a bit more expensive ($378 and up). Didn't find any "simple" way to redirect printf to a debugger console window with TrueStudio.

BTW, I do not work for Segger nor am I affiliated with them in any way. Just thought you should know.

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby tompe » Sat May 05, 2018 1:02 pm

Hello,

I recently bought a Blue Pill (STM32F103C8T6) with an ST-Link V2 to dive into the 32-bit world. Everything works fine, except the printf(). The SWV Console just won't display any data. I can trace that ITM_SendChar() gets called and writes to port 0.

Also tried to upgrade the programmers firmware and install everything under Windows 7, then made a project without FreeRTOS, and also one without using CubeMX for setup. Then I tried setting the SWV Core Clock to 8MHz and SWO Clock to 1MHz as mennamorato wrote, still no luck.

In a first test using AC6 IDE, I could already receive printf messages so it should be some wrong settings.

I attached screenshots of my settings.
At this point I'm out of ideas and hope anybody has a hint for me.

Thanks in advance.
You do not have the required permissions to view the files attached to this post.

mennamorato
Posts: 15
Joined: Mon Dec 04, 2017 2:04 pm

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Sat May 05, 2018 3:40 pm

@tompe you are using true studio 9.0 right ? otherwise it will not work

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby tompe » Sat May 05, 2018 4:23 pm

Yes, I downloaded the newest TrueSTUDIO Lite V9.0.1 :(

Once for Ubuntu 16.04 and once for Windows 7.

It works for you with ST-Link V2, right?

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby tompe » Sat May 05, 2018 4:42 pm

oO I just found that "printf() re-direction to IDE" might only be available for TrueSTUDIO Pro. Is that the case? Because I can enable all that stuff and change settings in SWV.

mennamorato
Posts: 15
Joined: Mon Dec 04, 2017 2:04 pm

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Sat May 05, 2018 5:06 pm

yes that is the case but 9.0.x has all the Pro features turned on.
yes it works for me.
the only thing i see different is your Core Clock and SWO clock and also do not "Wait for Sync packet"

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby georgeb » Sat May 05, 2018 5:38 pm

On the second screenshot I see core clock 8MHz (the default). It should be what you placed on the first screen, 72MHz. Wrong configuration mayby?(run/debug)

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby tompe » Sat May 05, 2018 6:00 pm

@georgeb:
That is because I tried once with 72MHz and once with 8MHz and made the screenshots at different times. I checked again and TrueSTUDIO automatically uses the right frequency as set in the debug settings

@mennamorato
Now I tried with 8MHz Core and 1MHz SWO and "Wait for sync packet" off, still nothing.
Also the SWV ITM Timeline does not show anything, I guess it should at least display some data traffic.

The debugger log file seems good to me, it turns tracing on and later off again when terminating debugging.

...
[3.513] handleFlashPacket(): Flash write completed in 0.067000 seconds, 1.632465kB/s
[3.516] STM32_AppReset(): Enter STM32_AppReset() function
[3.622] STM32_AppReset(): NVIC_DFSR_REG = 0x00000009
[3.623] STM32_AppReset(): NVIC_CFGFSR_REG = 0x00000000
[3.624] STM32_AppReset(): XPSR = 0x41000000
[3.625] handlePacket(): Reading 0x2 bytes of memory from addr 0x8001806
[3.626] handlePacket(): Reading 0x4 bytes of memory from addr 0x8001a30
[3.626] handlePacket(): Reading 0x4 bytes of memory from addr 0xe0042004
[3.632] handlePacket(): Reading 0x4 bytes of memory from addr 0x8001a30
[3.633] handlePacket(): Reading 0x2 bytes of memory from addr 0x8001806
[3.635] performContinue(): TraceCaptureStart and SWV event set to APP_TRUE
[3.651] handleGDBConnection(): TraceCaptureStart and SWV event set to APP_FALSE
[3.656] Device_GetHaltReason(): NVIC_DFSR_REG = 0x00000002
[3.657] handleStopReply(): ST_LINK Halt Reason break point hit

[3.661] handlePacket(): Reading 0x4 bytes of memory from addr 0x8001806
[4.971] handlePacket(): Reading 0x4 bytes of memory from addr 0xe000ed04
[4.971] handlePacket(): Reading 0x4 bytes of memory from addr 0xe000ed2c
[4.972] handlePacket(): Reading 0x4 bytes of memory from addr 0xe000ed28
[4.973] handlePacket(): Reading 0x4 bytes of memory from addr 0xe000ed38
[4.974] handlePacket(): Reading 0x4 bytes of memory from addr 0xe000ed34
[4.977] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000cac
[4.979] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000cb8
[4.980] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000ccc
[4.981] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000ce0
[4.981] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000cf4
[4.982] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000d08
[4.983] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000d1c
[4.984] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000d30
[4.985] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000d5c
[4.986] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000d70
[4.987] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000d90
[4.987] handlePacket(): Reading 0x4 bytes of memory from addr 0x20000da8
[16.565] handlePacket(): Reading 0x4 bytes of memory from addr 0xe0042004
[19.248] performContinue(): TraceCaptureStart and SWV event set to APP_TRUE
[19.264] Device_GetStatus(): ST_LINK device status: RUN_MODE
[29.399] parseForPacket(): Received Ctrl-C from the client
[29.399] handleGDBConnection(): TraceCaptureStart and SWV event set to APP_FALSE
[29.405] handleSignalPacket(): Device not halted(0), performing Ctrl-C
[29.405] handleSignalPacket(): Device halted
...

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby treecatt » Sat May 05, 2018 6:04 pm

After starting debug session but before starting the program running do you click on the red dot to start trace recording?


Return to “Embedded target code development discussions”

Who is online

Users browsing this forum: No registered users and 1 guest