Using CONFIG_DEBUG_OPTIMIZATIONS with Thingy:91 and Asset Tracker v2

I'm getting started with the nRF Connect SDK v2.6 and the Asset Tracker v2 application on a Thingy:91.
I can build and flash the unmodified app, and it pushes sensor data to nRF Cloud, using both `overlay-debug.conf` and `overlay-low-power.conf`.
When I set CONFIG_DEBUG_OPTIMIZATIONS=y for the debug conf the build fails with memory problems when building TFM:
[20/461] Performing build step for 'tfm'
[170/174] Linking C executable bin/tfm_s.axf
/usr/local/zephyr-sdk-0.16.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: address 0x1a460 of bin/tfm_s.axf section `.TFM_UNPRIV_CODE' is not within region `FLASH'
/usr/local/zephyr-sdk-0.16.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: bin/tfm_s.axf section `.psa_interface_thread_fn_call' will not fit in region `FLASH'
/usr/local/zephyr-sdk-0.16.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: address 0x1fc40 of bin/tfm_s.axf section `.gnu.sgstubs' is not within region `FLASH'
/usr/local/zephyr-sdk-0.16.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: address 0x1a460 of bin/tfm_s.axf section `.TFM_UNPRIV_CODE' is not within region `FLASH'
/usr/local/zephyr-sdk-0.16.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: address 0x1fc40 of bin/tfm_s.axf section `.gnu.sgstubs' is not within region `FLASH'
/usr/local/zephyr-sdk-0.16.4/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld: region `FLASH' overflowed by 32136 bytes
Memory region    Used Size       Region Size   %age Used
            FLASH:      80776 B              48640 B       166.07%
               RAM: 1.     8540 B                 32 KB         56.58%
collect2: error: ld returned 1 exit status
How can I increase the partition size for TFM ? 
Thanks
Parents
  • Hi,

     

    If you add CONFIG_DEBUG_OPTIMIZATIONS=y in your prj.conf, TF-M will also be compiled with debug optimizations, which will cause the partition size to be exceeded.

    thingy91_nrf9160_ns will follow this specific partition layout: https://github.com/nrfconnect/sdk-nrf/blob/v2.5.2/boards/arm/thingy91_nrf9160/thingy91_pm_static.yml

     

    One way around this is to configure your project with CONFIG_SIZE_OPTIMIZATIONS, and afterwards go into menuconfig and change the application's optimization level. This will cause TF-M to be left with the default optimization, and only set DEBUG_OPTIMIZATION for the asset tracker v2.

    You can do this via vscode nRF Kconfig GUI or manually edit and save the .config file:

    The .config file is located in ../asset_tracker_v2/my-build-folder/zephyr/.config - Search for "CONFIG_SIZE_OPTIMIZATION" and comment out this with a "#" and then add CONFIG_DEBUG_OPTIMIZATIONS=y and then press "build" in vscode.

     

    Kind regards,

    Håkon

  • Doing as you suggest does let me build an image with debug optimisations - thanks ! 

     

    However, when I flash that image to the board it doesn't run the Asset Tracker app. When I try a debugging session with this image the console gives me:

     

    JLinkGDBServerCLexe: SEGGER J-Link GDB Server V7.94e Command Line Version
    JLinkGDBServerCLexe:
    JLinkGDBServerCLexe: JLinkARM.dll V7.94e (DLL compiled Jan 15 2024 15:13:39)
    JLinkGDBServerCLexe:
    JLinkGDBServerCLexe: -----GDB Server start settings-----
    JLinkGDBServerCLexe: GDBInit file: none
    JLinkGDBServerCLexe: GDB Server Listening port: 58700
    JLinkGDBServerCLexe: SWO raw output listening port: 2332
    JLinkGDBServerCLexe: Terminal I/O port: 2333
    JLinkGDBServerCLexe: Accept remote connection: yes
    JLinkGDBServerCLexe: Generate logfile: off
    JLinkGDBServerCLexe: Verify download: off
    JLinkGDBServerCLexe: Init regs on start: off
    JLinkGDBServerCLexe: Silent mode: on
    JLinkGDBServerCLexe: Single run mode: on
    JLinkGDBServerCLexe: Target connection timeout: 0 ms
    JLinkGDBServerCLexe: ------J-Link related settings------
    JLinkGDBServerCLexe: J-Link Host interface: USB
    JLinkGDBServerCLexe: J-Link script: none
    JLinkGDBServerCLexe: J-Link settings file: none
    JLinkGDBServerCLexe: ------Target related settings------
    JLinkGDBServerCLexe: Target device: cortex-m33
    JLinkGDBServerCLexe: Target device parameters: none
    JLinkGDBServerCLexe: Target interface: SWD
    JLinkGDBServerCLexe: Target interface speed: 12000kHz
    JLinkGDBServerCLexe: Target endian: little
    JLinkGDBServerCLexe:
    =thread-group-added,id="i1"
    =cmd-param-changed,param="pagination",value="off"
    fih_panic_loop () at /opt/nordic/ncs/v2.6.0/bootloader/mcuboot/boot/bootutil/src/fault_injection_hardening.c:68
    68 __asm volatile ("b fih_panic_loop");
    [New Thread 1879048192]

     

    and I can't stop the code at breakpoints. If i use an image without DEBUG_OPTIMISATION the debugger works as expected. Looks like the boot process is broken....

Reply
  • Doing as you suggest does let me build an image with debug optimisations - thanks ! 

     

    However, when I flash that image to the board it doesn't run the Asset Tracker app. When I try a debugging session with this image the console gives me:

     

    JLinkGDBServerCLexe: SEGGER J-Link GDB Server V7.94e Command Line Version
    JLinkGDBServerCLexe:
    JLinkGDBServerCLexe: JLinkARM.dll V7.94e (DLL compiled Jan 15 2024 15:13:39)
    JLinkGDBServerCLexe:
    JLinkGDBServerCLexe: -----GDB Server start settings-----
    JLinkGDBServerCLexe: GDBInit file: none
    JLinkGDBServerCLexe: GDB Server Listening port: 58700
    JLinkGDBServerCLexe: SWO raw output listening port: 2332
    JLinkGDBServerCLexe: Terminal I/O port: 2333
    JLinkGDBServerCLexe: Accept remote connection: yes
    JLinkGDBServerCLexe: Generate logfile: off
    JLinkGDBServerCLexe: Verify download: off
    JLinkGDBServerCLexe: Init regs on start: off
    JLinkGDBServerCLexe: Silent mode: on
    JLinkGDBServerCLexe: Single run mode: on
    JLinkGDBServerCLexe: Target connection timeout: 0 ms
    JLinkGDBServerCLexe: ------J-Link related settings------
    JLinkGDBServerCLexe: J-Link Host interface: USB
    JLinkGDBServerCLexe: J-Link script: none
    JLinkGDBServerCLexe: J-Link settings file: none
    JLinkGDBServerCLexe: ------Target related settings------
    JLinkGDBServerCLexe: Target device: cortex-m33
    JLinkGDBServerCLexe: Target device parameters: none
    JLinkGDBServerCLexe: Target interface: SWD
    JLinkGDBServerCLexe: Target interface speed: 12000kHz
    JLinkGDBServerCLexe: Target endian: little
    JLinkGDBServerCLexe:
    =thread-group-added,id="i1"
    =cmd-param-changed,param="pagination",value="off"
    fih_panic_loop () at /opt/nordic/ncs/v2.6.0/bootloader/mcuboot/boot/bootutil/src/fault_injection_hardening.c:68
    68 __asm volatile ("b fih_panic_loop");
    [New Thread 1879048192]

     

    and I can't stop the code at breakpoints. If i use an image without DEBUG_OPTIMISATION the debugger works as expected. Looks like the boot process is broken....

Children
No Data
Related