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

NRF52840 BLE bootloader size and layout

I'm working with the NRF52 Development kit for the NRF52840 modifying the secure BLE bootloader to add my custom transport together with BLE so I can update my device with BLE and with my custom transport. I'm going through the memory layout for the NRF52840. From reading the docs and going through the source code I'm trying to understand how the bootloader is fitting in memory and what should I change because my bootloader will be larger than the current one because I will be using 2 transports.

When I compile the DEBUG DFU example for secure BLE with S140 for the PCA10056 dev kit, using SEGGER Embedded Studio, the "text" section is reported with addresses going from 0x000F13D4 to 0x000F978B so the size is 33719 bytes, is this the bootloader size or the bootloader + MBR parameters + bootloader settings size? If I compile the non-debug version the size goes down to 21853 bytes, so the bootloader start address is dynamically defined according to the compilation size, because in both cases, the BLE DFU works perfectly.

What would happen if I update the bootloader with another bootloader which is bigger in size? The MBR parameters and bootloader settings will become corrupt? Is there any way I can reserve some space to account for future bootloader updates?

Thank you very much for your time and help!

Parents
  • Hi Andres, 

    Could you tell which SDK and softdevice you are using ? We have some change in the bootloader start address location in SDK v15.3 (and softdevice v6.1.1). Instead of storing in UICR we store the start address inside the MBR. 

    The bootloader code start from BOOTLOADER_START_ADDR and go up in the flash and limited by NRF_MBR_PARAMS_PAGE_ADDRESS (2 pages on top of flash).

    BOOTLOADER_START_ADDR  value is stored in UICR (in older SDK ) or in MBR (in SDK v15.3) 

    Right now we don't support changing the bootloader start address dynamically via DFU. This mean you can update the one bootloader to another bootloader with different sizes, but it has to be inside the limit between NRF_MBR_PARAMS_PAGE_ADDRESS  and BOOTLOADER_START_ADDR. 

Reply
  • Hi Andres, 

    Could you tell which SDK and softdevice you are using ? We have some change in the bootloader start address location in SDK v15.3 (and softdevice v6.1.1). Instead of storing in UICR we store the start address inside the MBR. 

    The bootloader code start from BOOTLOADER_START_ADDR and go up in the flash and limited by NRF_MBR_PARAMS_PAGE_ADDRESS (2 pages on top of flash).

    BOOTLOADER_START_ADDR  value is stored in UICR (in older SDK ) or in MBR (in SDK v15.3) 

    Right now we don't support changing the bootloader start address dynamically via DFU. This mean you can update the one bootloader to another bootloader with different sizes, but it has to be inside the limit between NRF_MBR_PARAMS_PAGE_ADDRESS  and BOOTLOADER_START_ADDR. 

Children
  • Hi Hung, thank your for your reply. I'm using SDK 15.3.0, I'm not sure what is the softdevice version, I couldn't find it in the source files, where should I look for it?

    So, to reserve some space I should move the BOOTLOADER_START_ADDR. I can see that BOOTLOADER_START_ADDR is defined in "nrf_bootloader_info.h" as:

    #define BOOTLOADER_START_ADDR (CODE_START)

    And CODE_START is defined in "app_util.h" as:

    #define CODE_START ((uint32_t)&_vectors)

    Which I assume is the address of the interrupt vector table? So between the bootloader and the application data, we have the vectors table? In this case just changing the BOOTLOADER_START_ADDR is not enough I have to also move the address of the vector?

  • Which IDE are you using to compile the code ? 

    The code in the bootloader was made so that it take the parameter directly from the IDE (KEIL, Segger Embedded Studio for example). It's the Flash start configuration in the project setting, by default 0x78000 in the secure bootloader for NRF52832 debug version. CODE_START automatically take this number from project setting. 

    If you want to expand the size of the bootloader you just need to move this start address down. 

  • I'm using Segger Embedded Studio. Yes, I found the FLASH_START in the "Section Placement Macros". For the NRF52840 it's 0xf1000. Thank you very much for your help Hung!

Related