Using SWO printf debug tutorial

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

Using SWO printf debug tutorial

3,159 Views
biafra
Senior Contributor I

Hi everyone,

I'm having trouble to use the SWO printf debug feature, I've read many posts but I'm not able to view some debug string in the console view.

Does exist some step by step tutorial on how to configure this feature? Which probe can I use? What are the steps to create a simple project that can send some strings to the console?

Many thanks

Biafra

5 Replies

1,932 Views
lpcxpresso_supp
NXP Employee
NXP Employee

We may extend the support for SWO trace built into MCUXpresso IDE to other probes at some stage, though this certainly won't be in the immediate future.

Thus currently, if you don't have an LPC-Link2 (LPC-Link2|NXP and available from most distributors for around $20), then you will need to stick with regular semihosted output or else direct i/o through a UART. See section 13.4 "What is Semihosting", and section 13.4, "Use of printf", in the MCUXpresso IDE v10.1 User Guide for more information.

Regards,

MCUXpresso IDE Support

1,932 Views
lpcxpresso_supp
NXP Employee
NXP Employee

This functionality will only work when using an LPC-Link2 connection - it will not work with other CMSIS-DAP (LinkServer) connections, or with SEGGER / P&E debug connections.

For more details see:

MCUXpresso IDE v10.1 User Guide - section 13.5.7, "How to use ITM Printf"

MCUXpresso IDE v10.1 LinkServer SWO Trace Guide - section 3, "ITM"

It obviously also requires a part with SWO support - which generally means an MCU built around the Cortex-M3/M4 cpu, but not Cortex-M0/M0+. If you don't have this, then you will need to use semihosting or UART as an output channel.

Regards,

MCUXpresso IDE Support

1,932 Views
deniscollis
Contributor V

What MCU are you using Francesco?  SWO Debug Console works perfectly with my Kinetis K81/K82 and Segger J-Link.   If that is what you have, then make sure you have selected Quick Settings >> SDK Debug Console >> Semihost Console.  Also, the SDK defines PRINTF() for this purpose, so be careful when defining your own debug print macros. 

1,932 Views
lpcxpresso_supp
NXP Employee
NXP Employee

deniscollis‌ : that is "standard" semihosting output - which will work through all debug probes. The SWO printf mechanism redirects printf out through the SWO Trace channel instead (of through the main debug channel) - and is only supported when connected via LPC-Link2 to a SWO supporting target MCU.

Regards,

MCUXpresso IDE Support

1,932 Views
biafra
Senior Contributor I

Many thanks for your answer,

Is it planned to support the other probes too?

Many thanks

Biafra