LPCXpresso55S69

Building TF-M

To build a S and NS application along with a BL2 (bootloader) image for the LPCXpresso55S69 run the following commands:

$ mkdir build && cd build
$ cmake -DTFM_PLATFORM=nxp/lpcxpresso55s69 \
        -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake \
        -DCMAKE_BUILD_TYPE=Relwithdebinfo ../
$ make install

Note

Currently Debug cannot be selected as build type and regression tests cannot be run on the board without modifying the flash layout due to the amount of available on-chip flash memory. To run the S and NS regression tests (TEST_S=ON and TEST_NS=ON) the secondary image areas must be set to 0 (firmware updates are not possible) and in parallel the size of the primary regions must be increased in the platform\ext\target\nxp\lpcxpresso55s69\partition\flash_layout.h file in order for the S and NS images to fit in the flash.

Building TF-M without BL2

To build a S and NS application image for the LPCXpresso55S69 run the following commands:

$ mkdir build && cd build
$ cmake -DTFM_PLATFORM=nxp/lpcxpresso55s69 \
        -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake \
        -DBL2=OFF \
        ../
$ make install

Debugging with Segger Ozone

If you have a commercially licensed Segger J-Link, or if you meet the license terms for it’s use, Segger’s cross-platform Ozone tool can be used to debug TF-M firmware images.

To debug, flash the BL2, S and NS firmware images using the flash.sh script or command-line options described earlier in this guide, and configure a new project on Ozone as follows:

  • Device: LPC55S69

  • Target Interface: SWD

  • Target Interface Speed: 2 MHz

  • Host Interface: USB

  • Program File: build/secure_fw/tfm_s.axf (etc.)

Once the project has been setup, and the firmware has previously been flashed to the board, connect to the target via:

  • Debug > Start Debug Session > Attach to a Running Program

At this point, you can set a breakpoint somewhere in the code, such as in startup_LPC55S69_cm33_core0.s at the start of the Reset_Handler, or near a line like bl    SystemInit, or at another appropriate location, and reset the device to debug.

Debugging with GDB

NOTE: If you are debugging, make sure to set the -DCMAKE_BUILD_TYPE value to -DCMAKE_BUILD_TYPE=Debug when building TF-M so that debug information is available to GDB.

NOTE: When debugging with the mbed-crypto library, you also require an additional -DMBEDCRYPTO_BUILD_TYPE=DEBUG compile-time switch.

Start the GDB server, pointing to the secure application image:

JLinkGDBServer -device lpc55s69 -if swd -speed 2000

Connecting to the GDB server in tui mode

In a separate terminal, start the GDB client in tui (text UI) mode:

$ arm-none-eabi-gdb --tui secure_fw/tfm_s.axf

Then from the client connect to the remote GDB server we started earlier:

With JLinkGDBServer (default port 2331):

(gdb) target remote:2331
Remote debugging using :2331

Reset and stop at main

Set a breakpoint at main() (found in tfm_core.c), reset the device (monitor reset), and continue (c) execution.

(gdb) break main
Breakpoint 1 at 0x10024220: file [path]/secure_fw/core/tfm_core.c, line 189.
(gdb) monitor reset
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main ()
    at [path]/secure_fw/core/tfm_core.c:189
189     tfm_arch_init_secure_msp((uint32_t)&REGION_NAME(Image$$, ARM_LIB_STACK_MSP,

Commonly used GDB commands

You can start, step through, and analyse the code using some of the following GDB commands:

GDB Command

Description

next

Execute the next statement in the program

step

Step until new source line, entering called functions

until <n>

Run until source line n in the current file

info locals

Display the local variables and their current values

bt

Display a stack backtrace up to the current function

print <x>

Print the expression (ex. print my_var)

x

Examine memory (ex. x/s *my_string)

From here, you should consult a tutorial or book on GDB to know how to debug common problems.


Copyright (c) 2020, Linaro. All rights reserved. Copyright (c) 2020, Arm Limited. All rights reserved. SPDX-License-Identifier: BSD-3-Clause