This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

S332 + Bootloader_secure memory map and linker config


Hi, I have some questions about the memory map, ram usuage and linker config for the secure bootloader when used with the S332 (4.05 sd_req 0x94) softdevice.

I have tried to get DFU to work with the default linker settings from SDK 13.1, these are

  FLASH (rx) : ORIGIN = 0x78000, LENGTH = 0x6000
  RAM (rwx) :  ORIGIN = 0x20002060, LENGTH = 0xDA70

However although my application would start when merged with the appropriate bootloader settings and flashed to the SoC, it would not perform a dfu update successfully.

If I change the bootloader linker settings to those from the Thingy FW secure bootloader implementation then it does work. These are as follows.

  FLASH (rx) : ORIGIN = 0x75000, LENGTH = 0x9000
  RAM (rwx) :  ORIGIN = 0x20002C00, LENGTH = 0x5380

I would like to understand why the Thingy FW bootloader linker settings work and why? Why was it necessary for the Thingy FW bootloader mem map to be changed and why do I need the same settings for my S332 based project. Are there any documents apart from Hung Bui's excellent guide?

Other background info about the rest of my application

S332 based application - using ANT_s332_nrf52_4.0.5.hex

My application size:

Preparing: app_nrf52832_xxaa_s332.bin
Preparing: app_nrf52832_xxaa_s332.hex

   text    data     bss     dec     hex filename
  57836     692    4244   62772    f534 _build/app_nrf52832_xxaa_s332.out

Linker config for my app

  FLASH (rx) : ORIGIN = 0x29000, LENGTH = 0x57000
  RAM (rwx) :  ORIGIN = 0x20004AD8, LENGTH = 0xB528

As I said, although I have DFU working successfully using the ThingFW secure bootloader linker settings I want to understand why the change was necessary in case I am missing some key point which could have other repercussions for the rest of the system.


Thanks for your help

-Allen

  • Could you try using the original settings from the sdk 13.1 bootloader & debugging the bootloader when doing the dfu? It might be that this function inside bootloader_start() leads to the error you mention: 

    sd_softdevice_vector_table_base_set(NRF_UICR->NRFFW[0]);

    It might be that the RAM origin address is wrong in the sdk 13.1 bootloader linker settings.

    You can set a breakpoint at this function to see if an error is asserted. If there is no assert, you can let the bootloader restart the device & once you get into the application, it might be that the sd_ble_enable() function inside your application will ask you to adjust the linker settings. If it does, adjust the linker settings like told & hopefully everything should work like it should.

    There should not be any other repercussions for the rest of your design because of the linker config error.

  • I am using gcc to compile and a gdb server based debug arrangement. I tried to build the secure bootloader with compiler option -ggdb but I get the following error at linker time.

    ../../../../sdk_components/libraries/bootloader/nrf_bootloader_app_start_asm.c: In function 'nrf_bootloader_app_start_impl':
    ../../../../sdk_components/libraries/bootloader/nrf_bootloader_app_start_asm.c:129:1: error: r7 cannot be used in asm here
     }
     ^
    lto-wrapper: /home/fostera/Tools/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc returned 1 exit status
    /home/fostera/Tools/gcc-arm-none-eabi-4_9-2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: lto-wrapper failed
    collect2: error: ld returned 1 exit status
    make: *** [_build/ace_bootloader_nrf52832_s332.out] Error 1

    Is there a known solution for this before I spend some time trying to find one myself?

    Thanks again,

    Allen

  • Have you made any changes to the nrf_bootloader_app_start_asm.c file? Does the secure bootloader compile properly in Keil or Segger Embedded Studio? Have you tried this solution here?

Related