printf() causes crash before being called

Hi,
Using Keil uVision 5.11 with Cortex M4 target.

I wrote a program with printf() calls. I added a fputc() & output to UART.
I have now created another project with the same fputc().
If in the second program I add a printf() then I get an exception before main().
If I remove the printf() then all is OK.

I suspect that something is missing & that the exception is down to late linking (scatter?).

I would like to understand what changes I need to make to the second project such that I know how to create a project from start.
What am I missing?
If this is a late link issue then how do I force a full link?

Parents
  • Under the CMSIS model SystemInit() is typically called prior to your main() function, and BEFORE the statics are initialized, so be very conscious about what's in system_arch.c, what it's calling, and perhaps what stack size you have.

    You could always analyze the Hard Fault, or implement a half useful one (Joseph Yiu) to display the details.

Reply
  • Under the CMSIS model SystemInit() is typically called prior to your main() function, and BEFORE the statics are initialized, so be very conscious about what's in system_arch.c, what it's calling, and perhaps what stack size you have.

    You could always analyze the Hard Fault, or implement a half useful one (Joseph Yiu) to display the details.

Children
More questions in this forum