Not able to use printf/scanf functionality in S32DS

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

Not able to use printf/scanf functionality in S32DS

2,196 Views
emb02
Contributor IV

Hi,

I'm using S32K144 and want to use printf/scanf functions for testing purpose. I want to print some data on UART terminal (Teraterm).

To use printf function EWL library is used but while creating new S32DS project there is no option to select library. Also there is no option to select EWL library in project properties->settings->Target Processor.

S32 create proj.PNG

Screenshot (63).png

 

Can I use printf/scanf without EWL library? Is there any other way to print data on UART terminal.

I'm using,

S32DS v3.5

Toolchain - NXP GCC 10.2 for Arm 32-bit bare metal

0 Kudos
Reply
12 Replies

2,155 Views
emb02
Contributor IV

Hi @jiri_kral

I don't want to use semihosting console, I want to print data on debugger console. But there is no option for ewl_c Debugger console library in project settings (properties->settings->Target Processor->Libraries Support).

Please guide me with this.

 

0 Kudos
Reply

2,153 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

EWL C Library is not supported by S32DS v3.5. But both STD C libraries are using the same Debug output to Semihosting Console (which is different name for Debugger Console). 

Or what you mean by Debugger Console? 

The right NewLib version is this one: 

jiri_kral_0-1716808943545.png

 

0 Kudos
Reply

1,194 Views
emb02
Contributor IV

Hello,

Thank you for your response; however, if the EWL library is not supported for S32DS V3.5, could you suggest any other solution to the same query?

and When I try to create a new project, the SDK is not available for that toolchain.

 

I am using

S32DS v3.5

Toolchain: NXP GCC 10.2 for Arm 32-bit bare metal

0 Kudos
Reply

1,872 Views
emb02
Contributor IV

Hi @jiri_kral

I'm using S32K144 and want to use printf/scanf functions for testing purposes. I want to print some data on UART terminal (Teraterm).

As per your response, I am trying to make a setting in S32DS, but these options 

(newlib semihosting v2 (-specs=rdimon-v2.mspecs)) is not available in Project→properties→Setting→Target Processor.

 

Screenshot (97).png

I'm using,

S32DS v3.5

Toolchain - NXP GCC 6.3 for Arm 32-bit bare metal

Please guide me with this

 

0 Kudos
Reply

1,856 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

I already answered you question a month ago:


https://community.nxp.com/t5/S32K/Not-able-to-use-printf-scanf-functionality-in-S32DS/m-p/1875490/hi...

 

Best way is start with an UART example and use newlib no I/O. 

 

In details - if you call printf/scanf from STD C library (newlib no I/O) the output of both functions is calling _write or _read function which is by default empty. You need to implement both functions - inside _write function you need to send buffer passed through _write function into UART, for scanf you copy buffer read from UART to pointer passed by _read function. 

 

There is nothing special about it - check the example linked in some previous post. 

0 Kudos
Reply

2,134 Views
emb02
Contributor IV
HI,
I want to use real serial port of the MCU not serial console.
I've used mentioned newlib Semihosting library but not able to print data on UART terminal.
0 Kudos
Reply

2,117 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

okay, I see. For this you need to use NewLib with no I/O support and implement _read and _write functions as described in post bellow - https://community.nxp.com/t5/S32K/Not-able-to-use-printf-scanf-functionality-in-S32DS/m-p/1875490/hi...

0 Kudos
Reply

2,089 Views
emb02
Contributor IV

Hi @jiri_kral

It will be helpful if you can share example project in which NewLib with no I/O support library is used for printf (to print on UART).

0 Kudos
Reply

2,086 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

I don't have such example project. You can simply use some existing UART example and implement _write and _read functions by the same way as it is in Example shared with the previous link. 

0 Kudos
Reply

2,157 Views
jiri_kral
NXP Employee
NXP Employee

Hi,

for printf/scanf  via UART you need to implement 

 

int _write(int handle, char * buffer, int * count)

int _read(int handle, char * buffer, int * count)

 

Functions and use NewLib no I/O std C library. Here is example for EWL library - the difference is only in read/write function name - https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/EXAMPLE-S32k144-UART-printf-scanf-unde... 

If you are okay with Semihosting Console, you can link to your project NewLib_Semihosting:

jiri_kral_0-1716805001596.png

 

0 Kudos
Reply

795 Views
emb02
Contributor IV

Hello @jiri_kral 

I referred your code for UART testing, when I try to print data using the printf function, the program does not jump to the write_console function in the console.c.

I have attached my code. Please guide me further.

 

S32DS version 3.5

NXP GCC 10.2 toolchain for Arm 32-bit bare metal

0 Kudos
Reply

704 Views
emb02
Contributor IV

Hello, @jiri_kral.

I'm using my old project (S32DS version 3.5 with NXP GCC 6.3 for Arm 32-bit bare metal, which supports the EWL library) to print data on URAT.
In which the program jumps into the write_console function (console.c) after calling printf and able to print data on UART.

Screenshot (190).png

 

When I'm using your code (S32DS version 3.5 with NXP GCC 10.2 for Arm 32-bit bare metal) to print data on UART, program does jumps into the write_console function (console.c) after calling printf.

 

I've attached my codes. Please guide me further.

0 Kudos
Reply