cancel
Showing results for 
Search instead for 
Did you mean: 

Semihosting in Eclipse or retargeting printf

a239955_stm1
Associate II
Posted on June 03, 2014 at 09:43

Hi,

I am trying to debug some very simple code for STM32F0Discovery using Eclipse, 

ARM arm-none-eabi-gdb compiler and OpenOCD debuger.

I could build and debug my cods and now I am trying to use printf to see some variables on the screen. CoIDE has this nice semihosting which without using USART, sends printf output on the screen. I tried to use the semihosting library files with eclips to do the same. I could enable  semihosting in Eclipse but nothing showed up on the screen! I guess the problem was SH_DoCommand

http://techwithdave.blogspot.ca/2013/04/hello-world-tutorial-for-stm-discovery.html

Then I tried to use USART_Printf example from STM32F0xx_StdPeriph_Examples.

I got errors regarding _read and _write and so many errors like that. I tried to fix the errors by adding newlib_stubs.c as in 

https://sites.google.com/site/stm32discovery/open-source-development-with-the-stm32-discovery/getting-newlib-to-work-with-stm32-and-code-sourcery-lite-eabi

After small changes in the code I couldn't debug the code!

I have also tried to add 

--specs=rdimon.specs   -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group

flags to the linker but still nothing on the screen!

Any Idea?

Thanks

Ali

#stm32f0 #printf #discovery
11 REPLIES 11
Posted on February 03, 2015 at 14:23

And was this with an STM32F0, or something else? Because as I recall the Cortex-M0 doesn't support the ITM/SWV

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Justyn B
Associate II
Posted on February 10, 2015 at 16:27

The GNU ARM Eclipse plugins (http://gnuarmeclipse.livius.net) include templates which have a custom semihosting implementation, and provide trace_printf.

They work with the STM32F0, but don't use the ITM when on this platform.

Also available separately on github:

https://github.com/justyn/semihosting-cortexm-uos