Not able to use printf/scanf functionality in S32DS

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Not able to use printf/scanf functionality in S32DS

351件の閲覧回数
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

タグ(4)
0 件の賞賛
9 返答(返信)

310件の閲覧回数
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 件の賞賛

308件の閲覧回数
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 件の賞賛

27件の閲覧回数
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 件の賞賛

11件の閲覧回数
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 件の賞賛

289件の閲覧回数
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 件の賞賛

272件の閲覧回数
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 件の賞賛

244件の閲覧回数
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 件の賞賛

241件の閲覧回数
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 件の賞賛

312件の閲覧回数
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 件の賞賛