How to debug samples/tfm_integration/tfm_secure_partition with Zephyr

Hi,

I have a fresh clone of Zephyr version v3.4.0-rc1-66-g462dc9746b42. I want to build and debug the unmodified project samples/tfm_integration/tfm_secure_partition.

I am building with est build -b=nrf9160dk_nrf9160_ns. Which works fine. After flashing I am able to see also the expected output over the serial terminal. However running west debug is not working. See my log:

(.venv) stefan@p14s:~/Programs/sources/zephyrproject/zephyr/samples/tfm_integration/tfm_secure_partition$ west debug
-- west debug: rebuilding
[0/20] Performing build step for 'tfm'
ninja: no work to do.
[2/3] Performing install step for 'tfm'
-- Install configuration: "MinSizeRel"
[3/3] Completed 'tfm'
-- west debug: using runner jlink
-- runners.jlink: JLink version: 7.86f
-- runners.jlink: J-Link GDB server running on port 2331; no thread info available
SEGGER J-Link GDB Server V7.86f Command Line Version

JLinkARM.dll V7.86f (DLL compiled Mar 29 2023 16:34:11)

-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      yes
Generate logfile:              off
Verify download:               off
Init regs on start:            off
Silent mode:                   on
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 nRF9160_xxAA
Target device parameters:      none
Target interface:              SWD
Target interface speed:        4000kHz
Target endian:                 little

GNU gdb (Zephyr SDK 0.16.1) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=arm-zephyr-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://github.com/zephyrproject-rtos/sdk-ng/issues>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/stefan/Programs/sources/zephyrproject/zephyr/samples/tfm_integration/tfm_secure_partition/build/zephyr/zephyr.elf...
Remote debugging using :2331
0xfffffffe in ?? ()
Resetting target
Loading section rom_start, size 0x544 lma 0x50000
Loading section text, size 0x4904 lma 0x50544
Loading section .ARM.exidx, size 0x8 lma 0x54e48
Loading section initlevel, size 0x38 lma 0x54e50
Loading section device_area, size 0x48 lma 0x54e88
Loading section sw_isr_table, size 0x208 lma 0x54ed0
Loading section device_handles, size 0x12 lma 0x550d8
Loading section log_const_area, size 0x50 lma 0x550ec
Loading section rodata, size 0x234 lma 0x55140
Loading section datas, size 0x98 lma 0x55374
Loading section device_states, size 0x6 lma 0x5540c
Loading section k_mutex_area, size 0x14 lma 0x55414
Loading section .last_section, size 0x4 lma 0x55428
Start address 0x00051a98, load size 21540
Transfer rate: 172320 bits in <1 sec, 1538 bytes/write.
(gdb) Failed to open listener port 2331

(gdb) b main
Breakpoint 1 at 0x50814: file /home/stefan/Programs/sources/zephyrproject/zephyr/samples/tfm_integration/tfm_secure_partition/src/main.c, line 16.
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x50814

Command aborted.
(gdb) 
 

How to debug this sample??

  • Hello,

    Thank you for your patience.

    I recommend that you use nRF Connect SDK (NCS) and instead of upstream Zephyr. NCS is currently using a downstream of Zephyr v3.1.99. When testing with my setup* I built the tfm_secure_partition sample for nrf9160dk_nrf9160_ns with "Enable debug options" chosen and started a debug session with the Debug action in the extension UI. This worked as expected for me.

    *My setup is:
    Windows 10,
    NCS installed with Toolchain Manager v1.2.5,
    VS Code 1.78.2,
    nRF Connect for VS Code extension v2023.4.179,
    JLinkArm.dll v7.80c

    If you are not going to use NCS, you should ask your question in the Zephyr Project discord. You can also try to downgrade your Zephyr version to 3.1.0.

    Best regards,

    Maria

Related