6 Replies Latest reply on Oct 27, 2015 2:58 AM by user_518446

    printf() with newlib-nano vs. newlib / retargeting to UART

    user_518446

      Hi all,

         

      how do I get printf() working with newlib-nano and a UART / USBUART

         

      I am useing Creator 3.3 with the ARM GCC 4.9-2015-q1-update

         

      first I've read various posts in this forum regarding formatted output via UART / USBUART and the use of sprintf() vs. printf(), for instance this one here: http://www.cypress.com/forum/psoc-5-device-programming/how-do-i-do-printf-function-psoc5?source=search&keywords=newlib-nano&cat=community 

         

      When linking with newlib (Use newlib-nano = False) it works fine and the _write() stub functions I provide obviously overrides the weak implementation in newlib. In other words: printf() writes output to my USBUART / Putty

         

      However, when linking with newlib-nano (Use newlib-nano = True) the _write() function in my stubs.c file is never called. When doing assembly stepping,  I can dig deeper in the call hierarchy but never end in a function _write() as in the newlib case.

         

      Now my questions:

         

      1) how is "stubbing" supposed to work on newlib-nano?

         

      2) anybody got this working?

         

      Note that I know the workarounds / alternatives with sprintf() and then streaming the char arr to an output, that's not the point here.

         

      Just thought it would be nice to have something tiny working the "usual C way"

         

      Regards,

         

      Christof