Skip navigation

MCUXpresso IDE

9 Posts authored by: Erich Styger Employee

With the cost of an single pin, many ARM Cortex-M boards including the NXP i.MX RT1064 can produde SWO data: think about a pin able to stream data out of the chip in realtime. For example interrupt activity which otherwise might be hard to capture:

SWO Interrupt Trace

SWO Interrupt Trace

 

Outline

This article describes how to enable and use the SWO (Single Wire Output) of the ARM Cortex-M7 present in the NXP i.MX RT1064 device.

i.MX RT1064-EVK Board

i.MX RT1064-EVK Board

While this is a very valuable feature, not every development tool supports capturing SWO data. And not every board has the SWO pin routed to the debug header which is a prerequisite to get the data.

JTAG TDO Pin

JTAG TDO Pin (Source: NXP i.MX RT1064 Schematics)

The pin is connected to the AD_B0_10 pin of the i.MX RT1064 device.

Software and tools used:

  • Eclipse: NXP MCUXpresso IDE 10.3.1
  • SDK: NXP MCUXpresso SDK 2.4.1 for i.MX RT1064-EVK

Check SDK Manifest File

To use SWO, it has to be enabled in the SDK manifest file. So let’s check this first.

In the IDE, open the location where the SDK zip files are installed:

Open Location

Open Location

 Best to close the IDE now, as we might need to change the content on disk.

Open the archive:

Open SDK zip file

Open SDK zip file

Locate the manifest XML file:

SDK Manifest File

SDK Manifest File

To check/edit the manifext XML file I can use an external editor or the IDE:

Using the IDE

I can use the IDE to edit the XML (this is useful if I want to change the SDK sources).

To check/edit the file in the IDE workspace preferences, disable the ‘Selected files from SDK View open in read-only mode:

Selected Files Open Option

Selected Files Open Option

Open with the context menu the XML description:

Show XML Description

Show XML Description

In the XML editor, click on the ‘Source’ tab. Search for internal.has_swo:

XML Source tab

XML Source tab

Verify that it has a ‘true’ value. If not, change it to true and save the file.

Using external editor

Below are the steps using an external editor.

Open the file with a text editor and search for ‘internal_has_swo’ and check if it has a ‘true’ value. If not: change the value to true:

internal_has_swo

internal_has_swo

If that change is needed: update the zip file with the new content/file.

 if that setting is set to false, the IDE does not offer the SWO feature and buttons/views will be grayed out/disabled.

Now I can start the IDE again. If I had to modify the XML file, best to recreate the part information in the IDE:

Recreate Part Information

Recreate Part Information

Muxing SWO Pin

Locate the file ‘pin_mux.c’ and add the following lines to BOARD_InitPins():

1
2
3
4
IOMUXC_SetPinMux(
      IOMUXC_GPIO_AD_B0_10_ARM_CM7_TRACE_SWO,     /* GPIO_AD_B0_10 is configured as ARM_TRACE_SWO */
      0U);                                        /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_10_ARM_CM7_TRACE_SWO,0x00F9u);
BOARD_InitPins

BOARD_InitPins

Open ‘clock_config.c’ and search for the following inside the function BOARD_BootClockRUN():

1
2
3
4
/* Set TRACE_PODF. */
CLOCK_SetDiv(kCLOCK_TraceDiv, 2);
/* Set Trace clock source. */
CLOCK_SetMux(kCLOCK_TraceMux, 2);

and change it to

1
2
3
4
/* Set TRACE_PODF. */
CLOCK_SetDiv(kCLOCK_TraceDiv, 0);
/* Set Trace clock source. */
CLOCK_SetMux(kCLOCK_TraceMux, 3);
clock div and mux

clock div and mux

Finally, add the following to the end of the function BOARD_BootClockRUN(), or add it to main() after the clocks have been initialized.

1
2
3
4
#if 1 /* enable SWO */
*((uint32_t *)(0x400E0600)) = (1 << 11);  /* enable TPIU clock */
CLOCK_EnableClock(kCLOCK_Trace);
#endif

Debugging

The onboard DAPLink debug probe does *not* support SWO, so I’m using an external debug probe (LPC-Link2). Alternatively, the EVK board can be loaded with a LPC-Link2 firmware.

Debugging i.MX RT1064 Board with LPCLink2

Debugging i.MX RT1064 Board with LPC-Link2

In the SWO Trace Config view, the ‘change’ button shall now be enabled:

SWO Trace Config

SWO Trace Config

Use the ‘Detect’ button to detect the SWO speed (note that for the application shall have already passed the clock configuration code):

Detect SWO speed

Detect SWO speed

SWO Views

After this, I can open the various SWO views:

Open SWO views

Open SWO views

The views have a green ‘start’ button to start data collection from SWO:

start button

start button

SWO Counters view:

SWO counters

SWO counters

SWO statistical profiling:

SWO Profile View

SWO Profile View

SWO Data Trace:

SWO Data Trace

SWO Data Trace

Text output with SWO:

ITM Text Output

ITM Text Output

SWO Interrupt Trace:

SWO Interrupt Trace

SWO Interrupt Trace

 The IDE reveference manual/online help describes the views in more detail.

Summary

SWO on the i.MX RT1064 board is a fine thing: it requires some setup and a SWO capable debug probe. But with that extra ARM SWO pin I get extended debug views and data which are very valuable.

I have put an example project on GitHub (see Links section).

Happy SWOing 

 

Links

 

- - -

Originally published on June 3, 2019 by Erich Styger

The following article is a step-by-step tutorial how to use the NXP MCUXpresso SDK & IDE to create a SD card bootable image on i.MX RT. It features the i.MX RT1050-EVK(B) but is with minor changes applicable to any other i.MX RT device:

Tutorial: Booting the NXP i.MX RT from Micro SD Card

  • Creating a project running in RAM
  • Generating S19 file
  • Running application in RAM
  • Creating SD card boot image with Flashloader and elftosb
  • Loading image to SD card with MfgTool
  • Booting i.MX from SD card image

 

I hope you find it useful,

Erich

The link below is a step-by-step tuturial how to use the LPC800-DIP board with the MCUXpresso IDE:

MCUXpresso IDE: Blinky the NXP LPC800-DIP Board | MCU on Eclipse 

LPC800-DIP

Enjoy!

Erich

The MCUXpresso IDE has flexible ways how to use 'disconnect' and 'terminate'. Read more about this in

MCUXpresso IDE: Terminate and Disconnect a Debug Session | MCU on Eclipse 

 

 

Enjoy :-)

Erich

I have completed an article (external link) describing how existing Kinetis Design Studio projects can be imported and used in the MCUXpresso IDE:

MCUXpresso IDE: Importing Kinetis Design Studio Projects | MCU on Eclipse 

 

I hope this is useful,

Erich

The following article (external link) shows how to install the Eclipse Market Client into the MCUXpresso IDE:

MCUXpresso IDE: Adding the Eclipse Marketplace Client | MCU on Eclipse 

The plugin provides a convenient way to install extra Eclipse Plugins:

 

Enjoy!

Erich

The following article (external link) shows how to genereate S-Records (.s19), Intel Hex (.hex) and Binary (.bin) files:

MCUXpresso IDE: S-Record, Intel Hex and Binary Files | MCU on Eclipse 

 

Enjoy!

Erich

If you have already Kinetis Design Studio v3.x installed on Linux, then you might run into a P&E driver installation problem while installing MCUXpresso IDE v10.0.0 build 344.

 

David Karibe has described the solution in his blog:

http://karibe.co/2017/03/installing-nxp-mcuxpresso-in-linux/ 

 

thanks David!

The following blog post gives a tour through some of the features in the NXP MCUXpresso IDE:

MCUXpresso IDE: Unified Eclipse IDE for NXPs ARM Cortex-M Microcontrollers | MCU on Eclipse 

 

Happy Unifying :-)

Erich