This is the mail archive of the
mailing list for the newlib project.
Re: first post, perplexed by printf()
- From: Freddie Chopin <freddie_chopin at op dot pl>
- To: newlib at sourceware dot org
- Date: Fri, 03 Oct 2014 09:13:01 +0200
- Subject: Re: first post, perplexed by printf()
- Authentication-results: sourceware.org; auth=none
- References: <542E1B16 dot 8050503 at neurotica dot com>
On 10/03/2014 05:42 AM, Dave McGuire wrote:
If I do printf("%d\n", 1); everything works fine. If I do
printf("%d\n", 10);, my processor hangs. (again with no debugging
support just yet, I don't know where) In other words, as soon as I try
to format an integer with more than one digit, it hangs. I can add
characters to the format string, and it works. I've given it ever more
stack, no change. (I'm aware of printf()'s appetite for memory)
Before digging any further set stack to 4kB (or 2kB at least). Second
thing - make sure your stack is 8-byte aligned (this shouldn't be a
problem for printf()ing ints, but its better to be safe).
You could also try one of my example ARM projects, take the one for
Cortex-M3 (like the one for STM32F4) and just do these two things:
- disable any hardware-specific calls in main() - setting the PLL,
- adjust the sizes and addresses of memories in the linker script to
match your chip (you can also increase the stack size).
Then download the "syscalls" package, drop the source file into the main
folder of the example and at this point printf() MUST work. To make it
actually print anything, you'd also need to add your "retargetting" code...
Did you build the toolchain yourself or are you using some precompiled
one? Have you tried your code with the "official" one -
https://launchpad.net/gcc-arm-embedded or maybe with my own compilation
- bleeding-edge-toolchain - http://sourceforge.net/projects/bleeding-edge/