FRDM-KE06Z printf with ConsoleIO not linking

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

FRDM-KE06Z printf with ConsoleIO not linking

跳至解决方案
1,321 次查看
samkreuze
Contributor II

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?

1 解答
1,114 次查看
BlackNight
NXP Employee
NXP Employee

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

在原帖中查看解决方案

3 回复数
1,115 次查看
BlackNight
NXP Employee
NXP Employee

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

1,114 次查看
samkreuze
Contributor II

Wow, the custom sbrk() did it. Thank you!

0 项奖励
回复
1,114 次查看
BlackNight
NXP Employee
NXP Employee

Yeah, I get used to that kind of things.

Glad to hear that it is now working on your end.

Erich

0 项奖励
回复