printf() through OpenSDA

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

printf() through OpenSDA

7,105 Views
christofferjärl
Contributor II

Hi!

Is it possible to use printf() through the OpenSDA debugger back to console?

Like the MCU outputs printf() data through SWD to OpenSDA debugger, and from there back to the console of S32 Design Studio.

I'm using S32K144EVB, and would like it to function in real time with running application, not using LPUART, and no SDK.

Thank you.

13 Replies

5,613 Views
robertfichtner
Contributor I

Hi,

for me the prontf() is working as you describe her using debugger. I can see the outputs with the debug session. When I disconnect from target it will stop (caused by printf). Also it does not run standalone afterwards. Is there a solution for that: having printf() in the running code without console? Why it is not running when printf() used?

br

0 Kudos

5,613 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

you are correct. This is printf functionality for debug purposes and technically the output is done by debug probe. 

You can use UART for printf to some terminal (minicom, putty, RealTerm...). 

Here are examples for printf via UART: 

EXAMPLE: S32k144 UART printf/scanf under FreeRTOS - S32DS 

https://community.nxp.com/docs/DOC-333788 

Jiri

0 Kudos

5,613 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

printf() via OpenSDA is working - but the OpenSDA USB is acting as Virtual COM port and you need to use LPUART1 for that. 

Other possibility is print to Debug Console (in S32DS). For that you need to link new_lib or ewl lib with I/O support. 

Jiri

0 Kudos

5,613 Views
christofferjärl
Contributor II

Thanks for your response Jiri!

So when the lib's are untouched (not linked), a printf() will put the data out on the MCU's LPUART1?

Don´t really understand which "way" the data takes when you use your second alternative and link the lib, is it the PC generating the data from the program just within S32DS, or is it the MCU which send it back in some way?

Do you have an example how to link the lib in S32DS?

Great thanks!

/Chris

0 Kudos

5,613 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

if you are okay with debug console only - just switch in project properties your actual c library from no I/O version to version which supports debug console:

pastedImage_1.png

Otherwise you need to implement read_console/write_console functions. For reference you can look at this example: 

https://community.nxp.com/docs/DOC-335240 

Jiri

3,733 Views
tzeng015
Contributor II

Hi 

Can you see the attach file to help me? I don't have EWL release ?

thank you

 

0 Kudos

3,712 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

you can use NewLib (or NewLib_nano) with debugger console support. 

0 Kudos

3,706 Views
tzeng015
Contributor II

Hi 

Please see the attach file of my code and setting. I still can't make it work and please kindly help me

thank you

0 Kudos

5,612 Views
robertfichtner
Contributor I

Hello Jiri,

this topic describe exactly what I want to do using S32 design studio and a sample project out of it. When I configure the library support as you described, I need to include stdio.h in the main. Then it compiles and I can flash. But the debugger shows me, the program is running in a SW trap deep inside the printf. So it brakes. Any ideas?

0 Kudos

5,612 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

I forgot also mention that together with C lib supporting debug console you also need to enable semihosting console in debug session settings: 

pastedImage_1.png

The printf output you can see in console:

pastedImage_2.png

Hope it helps. 

Jiri 

0 Kudos

5,612 Views
jiri_kral
NXP Employee
NXP Employee

Hi Robert, 

well - SW trap may be caused by many things. Can you share your project? 

Jiri 

0 Kudos

5,612 Views
christofferjärl
Contributor II

Ok.

Maybe I miss some basics here, but which "way" does the data from printf() take when you choose a lib with "Debugger Console I/O"?

Is it the PC that runs the S32DS which generating the data from the program just "within" S32DS, or is it coming from the MCU which send it back in some way?

/Chris

0 Kudos

5,612 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

C lib with I/O supports has implemented printf functionality - you can see output in S32DS debug console. The data are from MCU and send via JTAG/SWD -> PE Micro(OpenSDA) to PC. Yon need to have active S32DS debug session.

Jiri