printf() to console

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

printf() to console

3,835 Views
Pete66
Contributor I

I am maintaining a S32K144 Makefile project in Design Studio.

I want to send UART output to the Debugger console. The only instruction I can find is https://community.nxp.com/t5/Kinetis-Design-Studio-Knowledge/How-to-use-printf-to-print-string-to-Co... which uses Processor Expert (which we do not).

Its been a few years (& on STM) but as I recall I just have to add an ITM putc() somewhere?

Please point me at the magic charm(s) needed.

I am using USB Multilink, any special debug configuration needed would be welcome.

Labels (1)
0 Kudos
4 Replies

3,806 Views
Pete66
Contributor I

I am not being clear.

I want printf() to appear in the debugger console. This used to be called ITM?

I have a Multilink connected to the target. I do not have access to UART pins (don't ask!).

I have seen a PE example but we do not use PE (again don't ask!).

Thanks

0 Kudos

3,794 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

 

Ok, I see. I understand it that you need to use printf to serial console, sorry.

So - you can use STD C library with debugger I/O support - for example newlib: 

jiri_kral_0-1616671028683.png

 

and enable Semihosting console in debug configurations: 

jiri_kral_1-1616671111622.png

 

You should be able see printf output in Debug session semihosting console. 

 

Hope it helps. 

 

Jiri 

 

 

 

0 Kudos

3,816 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

there is an old example - https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/EXAMPLE-S32k144-UART-printf-scanf-unde...  

Basically - you need to implement these functions: 

int_t __read_console(__file_handle handle, uchar_t * buffer, size_t * count);
int_t __write_console(__file_handle handle, uchar_t * buffer, size_t * count);
int_t __close_console(__file_handle handle);

You can reuse console.h and console.c from example in your project. 

 

Jiri

 

 

0 Kudos

3,092 Views
tzeng015
Contributor II

Hi jiri_kral

According these steps , I make the same thing and SOP but it can't work ok.

please see the attach file and kindly help me.

thank you

0 Kudos