Using NXP i.MX RT685 with pyOCD: Device Support and Debugging Configuration

The NXP i.MX RT685 is an interesting device: an ARM Cortex M33 with a Cadence Xtensa audio DSP. To explore the features of the device, I’m using the NXP EVK board:

pyOCD with NXP i.MX RT685

I have used it so far with the on-board MCU-Link debug probe and LinkServer. This article describes how I have added pyOCD as debug interface for the RT685, as well how to patch and use custom DFP (Device Family Pack) files with pyOCD and Eclipse.

Outline

In this article I describe what I had to install and configure to use the board with pyOCD. Because the RT685 is not installed by default, I describe how to add additional device support.

NXP i.MX RT685-EVK

The board features an on-board debug probe (LPC4322 based circuit), but can be configured to use an external debug probe too.

Prerequisites

I’m using the board with pyOCD and MCUXpresso IDE 11.9.1 (Eclipse). If you are new to pyOCD, then follow first the steps outlined in Debugging Embedded Targets with pyOCD and Eclipse.

I’m pyOCD 0.36.0, using the on-board LinkServer/CMSIS-DAP debug probe:

pyocd list
  #   Probe/Board                                     Unique ID   Target
--------------------------------------------------------------------------
0 NXP Semiconductors LPC-LINK2 CMSIS-DAP V5.224 ATAWBQHR n/a

Builtin Devices

To get a list of installed and supported devices, use the following command:

pyocd list --targets

  Name                      Vendor                   Part Number                  Families     Source
--------------------------------------------------------------------------------------------------------
air001 AirM2M Air001 builtin
air32f103xb AirM2M Air32F103xB builtin
...
mimxrt1010 NXP MIMXRT1011xxxxx builtin
mimxrt1015 NXP MIMXRT1015xxxxx builtin
mimxrt1020 NXP MIMXRT1021xxxxx builtin
mimxrt1024 NXP MIMXRT1024xxxxx builtin
mimxrt1050 NXP MIMXRT1052xxxxB_hyperflash builtin
mimxrt1050_hyperflash NXP MIMXRT1052xxxxB_hyperflash builtin
mimxrt1050_quadspi NXP MIMXRT1052xxxxB_quadspi builtin
mimxrt1060 NXP MIMXRT1062xxxxA builtin
mimxrt1064 NXP MIMXRT1064xxxxA builtin
mimxrt1170_cm4 NXP MIMXRT1176xxxxx_CM4 builtin
mimxrt1170_cm7 NXP MIMXRT1176xxxxx_CM7 builtin

Because at the time of writing this article, the RT685 is not pre-installed, I have to add the device support manually (see https://pyocd.io/docs/target_support.html). One way is to install it with managed packs.

Checking Packs

To check if the device is present as pack:

pyocd pack find rt685

It shows me the RT685:

0000425 I No pack index present, downloading now... [pack_cmd]
Part Vendor Pack Version Installed
-----------------------------------------------------------------------
MIMXRT685SFAWBR NXP NXP.MIMXRT685S_DFP 18.0.0 False
MIMXRT685SFFOB NXP NXP.MIMXRT685S_DFP 18.0.0 False
MIMXRT685SFVKB NXP NXP.MIMXRT685S_DFP 18.0.0 False

Pack Installation

With the following I install it:

pyocd pack install mimxrt685
Downloading packs (press Control-C to cancel):
NXP.MIMXRT685S_DFP.18.0.0
Downloading descriptors (001/001)

After that, the ‘pyocd list --targets‘ shows them installed as pack:

  mimxrt685s                NXP                      MIMXRT685S                   MIMXRT685S   pack
mimxrt685sfawbr NXP MIMXRT685SFAWBR MIMXRT685S pack
mimxrt685sffob NXP MIMXRT685SFFOB MIMXRT685S pack
mimxrt685sfvkb NXP MIMXRT685SFVKB MIMXRT685S pack

Eclipse Launch Configuration

With this, I can use the device in the Eclipse/MCUXpresso IDE launch configuration:

pyOCD Launch Configuration Settings for RT685

Debugging

With this, I can debug the RT685 with pyOCD:

pyOCD with RT685 and NXP MCUXpresso IDE

For reference, here is my pyOCD console output:

0000577 W STLink, CMSIS-DAPv2 and PicoProbe probes are not supported because no libusb library was found. [common]
0000736 W CMSIS-Pack device MIMXRT685SFVKB has no identifiable boot memory [cmsis_pack]
0000753 I Target type is mimxrt685sfvkb [board]
0000954 I DP IDR = 0x6ba02477 (v2 rev6) [dap]
0000955 I debugvar 'BootTime' = 0x2710 (10000) [pack_target]
0000955 I debugvar 'Dbg_CR' = 0x0 (0) [pack_target]
0000955 I debugvar 'SWO_Pin' = 0x0 (0) [pack_target]
0000992 I AHB-AP#0 IDR = 0x84770001 (AHB-AP var0 rev8) [discovery]
0000994 I AP#2 IDR = 0x002a0000 (AP var0 rev0) [discovery]
0001006 I APB-AP#3 IDR = 0x54770002 (APB-AP var0 rev5) [discovery]
0001014 I AHB-AP#0 Class 0x1 ROM table #0 @ 0xe00fe000 (designer=015 part=000) [rom_table]
0001018 I [0]<e00ff000:ROM class=1 designer=43b:Arm part=4c9> [rom_table]
0001018 I AHB-AP#0 Class 0x1 ROM table #1 @ 0xe00ff000 (designer=43b:Arm part=4c9) [rom_table]
0001024 I [0]<e000e000:SCS M33 class=9 designer=43b:Arm part=d21 devtype=00 archid=2a04 devid=0:0:0> [rom_table]
0001027 I [1]<e0001000:DWT M33 class=9 designer=43b:Arm part=d21 devtype=00 archid=1a02 devid=0:0:0> [rom_table]
0001032 I [2]<e0002000:BPU M33 class=9 designer=43b:Arm part=d21 devtype=00 archid=1a03 devid=0:0:0> [rom_table]
0001036 I [3]<e0000000:ITM M33 class=9 designer=43b:Arm part=d21 devtype=43 archid=1a01 devid=0:0:0> [rom_table]
0001040 I [5]<e0041000:ETM M33 class=9 designer=43b:Arm part=d21 devtype=13 archid=4a13 devid=0:0:0> [rom_table]
0001044 I [6]<e0042000:CTI M33 class=9 designer=43b:Arm part=d21 devtype=14 archid=1a14 devid=40800:0:0> [rom_table]
0001048 I [1]<e0040000:TPIU M33 class=9 designer=43b:Arm part=d21 devtype=11 archid=0000 devid=ca1:0:0> [rom_table]
0001057 I CPU core #0: Cortex-M33 r0p3, v8.0-M architecture [cortex_m]
0001057 I Extensions: [DSP, FPU, FPU_V5, MPU, SEC] [cortex_m]
0001057 I FPU present: FPv5-SP-D16-M [cortex_m]
0001058 I Setting core #0 (cm33) default reset sequence to ResetSystem [pack_target]
0001063 I 4 hardware watchpoints [dwt]
0001065 I 8 hardware breakpoints, 1 literal comparators [fpb]
0001089 I Semihost server started on port 4444 (core 0) [server]
0001235 I GDB server started on port 3333 (core 0) [gdbserver]
Started by Eclipse Embedded CDT
0003619 I Client connected to port 3333! [gdbserver]
0006003 I Attempting to load RTOS plugins [gdbserver]

In a normal world, this would be here the end of the article.

Something went wrong?

Experts might have noticed something in above log:

0000736 W CMSIS-Pack device MIMXRT685SFVKB has no identifiable boot memory [cmsis_pack]

This is a warning (W), but actually it is a very bad error. It means that something went wrong with the memory map and flash programming. And actually what happened is that the new binary has not been programmed, and the debugger is happily debugging the previously programmed application :-(.

Command Line

One benefit of pyOCD is its command line interface. Let’s try to use it to program the binary from the command line or console:

pyocd flash --target mimxrt685sfvkb MIMXRT685_Blinky.axf

0000568 W STLink, CMSIS-DAPv2 and PicoProbe probes are not supported because no libusb library was found. [common]
0000783 W CMSIS-Pack device MIMXRT685SFVKB has no identifiable boot memory [cmsis_pack]
0001134 I Loading MIMXRT685_Blinky.axf [load_cmd]
0001136 W Failed to add data chunk: no memory region defined for address 0x08000000 [file_programmer]
0001136 W Failed to add data chunk: no memory region defined for address 0x0800594c [file_programmer]

[==================================================] 100%
0001141 I Erased 0 bytes (0 sectors), programmed 180 bytes (0 pages), skipped 0 bytes (0 pages) at 0.00 kB/s [loader]

Here we see now three warning messages:

Failed programming with OpenOCD for RT685

This gives us the final indication that something must be wrong for the address 0x0800’0000.

Downloading DFP for RT685

The problem seems to be a wrong (or not supported) memory mapping in the Device Family Pack (DFP). The package is available from https://www.keil.arm.com/packs/:

MIMXRT685S_DFP

Download that file, and unpack it (it is a normal .zip file, but does not have .zip extension).

Patching PDSC

Inside the pack, there is a .pdsc file:

NXP.MIMXRT685S_DFP.pdsc

The .pdsc is a text (XML) file. Open it in a text editor. Around line 250 I noticed that there are two entries for flash programming for the same address range:

<algorithm name="devices/MIMXRT685S/arm/MIMXRT6XX_EVK_FLEXSPI.FLM" start="0x08000000" size="0x04000000" RAMstart="0x1001c000" RAMsize="0x00001000" default="1"/>
        <algorithm name="devices/MIMXRT685S/arm/MIMXRT6XX_EVK_FLEXSPI_S.FLM" start="0x18000000" size="0x04000000" RAMstart="0x1001c000" RAMsize="0x00001000" default="1"/>
        <algorithm name="devices/MIMXRT685S/arm/MIMXRT6XX_FLEXSPI_B_SFDP_QSPI.FLM" start="0xF8000000" size="0x04000000" RAMstart="0x1001c000" RAMsize="0x00001000" default="0"/>
        <algorithm name="devices/MIMXRT685S/arm/MIMXRT6XX_FLEXSPI_B_SFDP_QSPI_S.FLM" start="0x18000000" size="0x04000000" RAMstart="0x1001c000" RAMsize="0x00001000" default="0"/>
Double memory algorithm

💡 I’m not clear if this is an issue of the DFP file or pyOCD. pyOCD has not been updated for a while, so I think it could be more of a problem of pyOCD than the DPF file.

The solution is now to delete the two lines marked above in yellow, save the file and zip the folder structure again.

Using local Pack file

Now I can use the local pack file instead the downloaded one. Unfortunately, we have to remove the previously installed pack with

pyocd pack clean

as pyOCD otherwise will be hanging during connection.

To use the local pack:

pyocd load -v --pack NXP.MIMXRT685S_DFP.18.0.0.pack --target mimxrt685sfvkb MIMXRT685_Blinky.axf

which now works as expected:

0000627 W STLink, CMSIS-DAPv2 and PicoProbe probes are not supported because no libusb library was found. [common]
0000728 I Target type is mimxrt685sfvkb [board]
0000931 I DP IDR = 0x6ba02477 (v2 rev6) [dap]
0000931 I debugvar 'BootTime' = 0x2710 (10000) [pack_target]
0000932 I debugvar 'Dbg_CR' = 0x0 (0) [pack_target]
0000932 I debugvar 'SWO_Pin' = 0x0 (0) [pack_target]
0000970 I AHB-AP#0 IDR = 0x84770001 (AHB-AP var0 rev8) [discovery]
0000973 I AP#2 IDR = 0x002a0000 (AP var0 rev0) [discovery]
0000986 I APB-AP#3 IDR = 0x54770002 (APB-AP var0 rev5) [discovery]
0000995 I AHB-AP#0 Class 0x1 ROM table #0 @ 0xe00fe000 (designer=015 part=000) [rom_table]
0001000 I [0]<e00ff000:ROM class=1 designer=43b:Arm part=4c9> [rom_table]
0001000 I AHB-AP#0 Class 0x1 ROM table #1 @ 0xe00ff000 (designer=43b:Arm part=4c9) [rom_table]
0001009 I [0]<e000e000:SCS M33 class=9 designer=43b:Arm part=d21 devtype=00 archid=2a04 devid=0:0:0> [rom_table]
0001013 I [1]<e0001000:DWT M33 class=9 designer=43b:Arm part=d21 devtype=00 archid=1a02 devid=0:0:0> [rom_table]
0001019 I [2]<e0002000:BPU M33 class=9 designer=43b:Arm part=d21 devtype=00 archid=1a03 devid=0:0:0> [rom_table]
0001023 I [3]<e0000000:ITM M33 class=9 designer=43b:Arm part=d21 devtype=43 archid=1a01 devid=0:0:0> [rom_table]
0001027 I [5]<e0041000:ETM M33 class=9 designer=43b:Arm part=d21 devtype=13 archid=4a13 devid=0:0:0> [rom_table]
0001032 I [6]<e0042000:CTI M33 class=9 designer=43b:Arm part=d21 devtype=14 archid=1a14 devid=40800:0:0> [rom_table]
0001036 I [1]<e0040000:TPIU M33 class=9 designer=43b:Arm part=d21 devtype=11 archid=0000 devid=ca1:0:0> [rom_table]
0001046 I CPU core #0: Cortex-M33 r0p3, v8.0-M architecture [cortex_m]
0001046 I Extensions: [DSP, FPU, FPU_V5, MPU, SEC] [cortex_m]
0001047 I FPU present: FPv5-SP-D16-M [cortex_m]
0001049 I Setting core #0 (cm33) default reset sequence to ResetSystem [pack_target]
0001053 I 4 hardware watchpoints [dwt]
0001055 I 8 hardware breakpoints, 1 literal comparators [fpb]
0001064 I Loading C:\Users\Erich Styger.N0007139\Data\GitRepos\McuOnEclipse\Examples\MCUXpresso\i.MX RT685-EVK\MIMXRT685_Blinky\Debug\MIMXRT685_Blinky.axf [load_cmd]
[==================================================] 100%
0004009 I Erased 24576 bytes (6 sectors), programmed 23732 bytes (92 pages), skipped 4096 bytes (16 pages) at 9.24 kB/s [loader]
working programming with local pack

Using local DFP pack in Eclipse

The last question is: how to use a custom DFP pack file with Eclipse? The solution is to place the pack in the project root and then point to it from the launch configuration as shown below:

Using pack in Eclipse launch configuration

Now it works as expected 🙂

Summary

Having pyOCD as debug interface is always a good addition to any project. Because RT685 is not builtin supported target, I have to add it to pyOCD. This is simple using the packs method, but only if that pack works with pyOCD. In the case of RT685 there seems to be a problem between pyOCD and the pack memory flash programming mapping, so I had to patch the file and use a local version. The good thing is that I learned more about DFP packs and how pyOCD works ;-).

The example project used here is available on GitHub, together with the patched DFP file. I have submitted pyOCD github ticket, with the hope it gets fixed in the future.

Happy packing 🙂

Links

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.