I've been trying to print to a console from my freedom board using printf. I've set up a project using mqxlite and processor expert. I set up a ConsoleIO component with a Serial_LDD component within it. I've generated the code and according to the guide I've been following (Tutorial: Printf() with (and without) Processor Expert | MCU on Eclipse)) I should be able to use printf over UART.
However, when I call printf in a task, the program crashes. Looking at the assembly I can see that it crashes when trying to branch to the printf function. I've tried cleaning and rebuilding the project; I get no errors nor warnings when building in regards to printf.
Any ideas? Is there an example project somewhere for this board that has this figured out already?
Solved! Go to Solution.
Hi Sam,
if using printf(), make sure you have plenty of stack allocated. Additionally, you might needs some heap too, depending on the toolchain and compiler. For example if you are using semihosting with the 4.9 ARM tools, you need to provide your own custom _sbrk() function, otherwise malloc() internally will return a NULL pointer and then the code in the library crashes. See
Using Kinetis Design Studio V3.0.0 with the Launchpad 4.9-2015-q2 Release | MCU on Eclipse
Semihosting with GNU ARM Embedded (Launchpad) and Kinetis Design Studio | MCU on Eclipse
I hope this helps,
Erich
Hi Sam,
if using printf(), make sure you have plenty of stack allocated. Additionally, you might needs some heap too, depending on the toolchain and compiler. For example if you are using semihosting with the 4.9 ARM tools, you need to provide your own custom _sbrk() function, otherwise malloc() internally will return a NULL pointer and then the code in the library crashes. See
Using Kinetis Design Studio V3.0.0 with the Launchpad 4.9-2015-q2 Release | MCU on Eclipse
Semihosting with GNU ARM Embedded (Launchpad) and Kinetis Design Studio | MCU on Eclipse
I hope this helps,
Erich
Wow, the custom sbrk() did it. Thank you!
Yeah, I get used to that kind of things.
Glad to hear that it is now working on your end.
Erich