This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How do I configure newlib printf?

Im using GCC + Eclipse with the S110 SoftDevice and the HRS example code. Everything is working well except for printf (which I've added a call to via app_trace). I've set the ENABLE_DEBUG_LOG_SUPPORT #define. I've also called app_trace_init().

I get a Hard_Fault when I call app_trace. Stepping through the assembly:

  1. printf is entered.
  2. printf attempts to dereference _impure_ptr (part of the thread support for errno in newlib), but _impure_ptr points to 0x8000222, which I believe is in the region of the SoftDevice and not readable.
  3. At this point, a Hard_Fault occurs.

Does newlib need to be initialized (i.e. do I need to call _init or _fini somewhere)? Has anyone else used printf with GCC + newlib?

I'm using the gcc_nrf51_s110_xxac.ld linker script that comes with the SDK--so my memory and flash regions should be correct.

Related