AnsweredAssumed Answered

Redirect printf()

Question asked by Mathias Edman on Sep 27, 2019
Latest reply on Oct 21, 2019 by Mathias Edman



I am trying to redirect the printf() to Uart. I am using S32 studio (Version: 2017.R1 Build id: 171018)  with gnu toolchain and MPC5777C and I have tried with pretty much every possible combination of newlib and ewl with lower layer functions such as _write(), _read(), write(), read(),_sbrk(), _open(),  _isatty(), _fstat(), __read_console, __write_console etc. etc.


Usually in other projects, I manage to do this simply using read() write() functions with newlib, but this does not seem to work correctly using S32 studio with the MCU I work with currently.


With newlib I can get printf() to work and it will call write() and read(), but for some reason using %d and similar will return null chars like below.


printf("number %d %s", 57, "MCU");



'n', 'u', 'm', 'b', 'e', 'r', ' ', \0, \0, ' ', 'M', 'C', 'U'


Is there some kind of magic involved here that I need to understand in order to get this up and running?