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

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

beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Mon Dec 04, 2017 2:08 pm

Newbie to Atollic question, using STM32F1 value line discovery kit, puts() and printf() call tiny_printf() but I do not see anything on terminal or console.
I know its something basic i am doing wrong, thanks for any help.

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Mon Dec 04, 2017 5:48 pm

and tiny_printf.c calls
/* External function prototypes (defined in syscalls.c) */
extern int _write(int fd, char *str, int len);

which i cannot find but must be sending bytes somewhere...
more looking

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby treecatt » Thu Dec 07, 2017 7:59 am


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

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Thu Dec 07, 2017 2:29 pm

Great thanks this is perfect .. except my Lite free version does not support SWD and i will have to upgrade I guess

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Thu Dec 07, 2017 8:27 pm

Hi Ok got the eval key for the Pro version so I can get at least the SWV console up but when I start running i get a pop up:

"Failed to enable SWV. SWV will be disabled for this debug session."

even though i have enabled SWV in the Debugger config. ANy idea why?

thanks

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby treecatt » Fri Dec 08, 2017 7:48 am

Watch the video and verify you completed all setup steps correctly.

http://info.atollic.com/printf-redirect

and this one on youtube

https://www.youtube.com/watch?v=BwgPV3uKuzY

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Fri Dec 08, 2017 1:50 pm

Yes thanks I did all that I now think my STMF1 Value Line Discovery board is not compatible with the ST-Link V2 firmware because it will not enable the SWV to even get started. I ordered a new Nucleo board that is compatible and will let you know..thanks for your help.

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Mon Dec 11, 2017 7:58 pm

Hi,

Ok this is very frustrating as I have a new STM32F103 Nucleo-64 board and the SWV link does come up when starting debug *but* still nothing coming out on the SWV Console Port0, even though I totally followed the instructions in the video, set up the Port0, etc. I traced the tiny_printf.c --> syscalls.c _write function (modified per instructions) --> core_cm3.h static __INLINE ITM_SendChar macro and it does do the ITM->Port[0].u8 = (uint8_t) ch; AND the ch = the char from the printf string BUT nothing on the Port0 SWV Console [and I did Start Trace].

So where are the ch's going?

thanks

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Mon Dec 11, 2017 8:33 pm

CORRECTION FIXED: OK turns out my OLD project works for the Nucleo board but the NEW project does not on the Nucleo board.

NOTE: the OLD project was created for a Discovery board with F100 cpu originally, the NEW project was created for a Nucelo board with F103 cpu. The code is running on the Nucleo board just fine, *except* no SWV output with the NEW project. The OLD project running on Nucleo board sends output to SWV Console just fine.

The OLD project does NOT use 'tiny_printf.c', it just uses "puts" and "printf" with the correct _write() in syscalls.c --> so how does that even work??

The NEW project does use 'tiny_printf.c' and when i trace it all the way thru _write() --> IMT_SendChar in core_cm3.h macro it gets to "ITM->PORT[0].u8 = (uint8_t) ch;" and NOTHING shows up on SWV Console with port0 enabled... so where is it going?

The OLD project does not have a 'tiny_printf.c' file, but the NEW project does.

The OLD project is in a different workspace than the NEW project.

The ST-Link shows up in Windows Dev Manager as "STLink Virtual COM Port (COM3) if that helps

Any idea why the OLD project works but the NEW does not? I know this is a long winding road here but maybe it will help others.
thanks

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

Re: beginner Atollic question on printf/puts embedded STM32

Postby mennamorato » Wed Dec 13, 2017 3:21 pm

REALLY FIXED this time: MORE clues
in the working project (OLD) I cannot "Step Into" the 'puts()' function to see the ITM macro being called, but the 'puts()' works on SWV.
in the non-working project (NEW) I CAN "Step Into" the 'puts()' function as noted above, all the way thru the ITM macro.

In both projects, the little "Configure Trace" icon in the SWV Console window 'blinks' whenever a 'puts()' or 'printf()' is called.

In the non-working project - NEW, created for Nucleo board - the only difference in the Serial Wire Viewer settings is Core Clock = 72 MHz, Clock Prescaler = 72, SWO clock = 1000.0 kHz, whereas for the OLD project Core Clock is 8 MHz, Prescaler is 8, but SWO clock is also = 1000.0 kHz.

Not sure why the core clock is so low for the Discovery board project and so high for the Nucleo project.

Maybe that helps

OK when i changed the Core Clock to 8 MHz, Prescaler 8, leaving SWO clock = 1000.0 kHz puts() and prinf() are now working in NEW project.. geez.. very strange but it works.


Return to “Embedded target code development discussions”

Who is online

Users browsing this forum: No registered users and 1 guest