sdk 12 bootloader erased after programming

Hi,

I'm trying to load the secure_debug bootloader for the nrf52 with the SD 132 3.0 and an aplication. But when I load the aplication the bootloader gets erased or overwritten... I'm using Keil, and my process is: 1-Program the softdevice 3. 2-program the bootloader_debug with keil (using the external program nrfprog). (At this point the bootloader appears on the nrfgo aplication...) 3-Program the aplication with Keil.

And the bootloader dissapears after the 3rd step.

I don't know what I'm doing wrong...

Thank you!

  • Could you post the IROM and IROM settings (Keil) or the linker script (GCC) for the application?

  • The IROM and IRAM settings for an application using the S132 v3.0.0 with no bootloader are:

    IROM1 Start: 0x1F000 Size: 0x61000
    IRAM1 Start: 0x20002128 Size: 0xDED8
    

    The Secure Bootloader start address is 0x78000 and 0x1F000 + 0x61000 = 0x80000. Thus, you have to alter the application IROM settings so that the application does not overwrite the bootloader, i.e.

    IROM1 Start: 0x1F000 Size: 0x59000
    IRAM1 Start: 0x20002128 Size: 0xDED8
    

    If you're using GCC you have to alter the application linker script in the armgcc folder, i.e.

    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x59000
      RAM (rwx) :  ORIGIN = 0x20002128, LENGTH = 0xded8
    }
    

    EDIT 28.10.16:

    Its another bug in the buttonless DFU example. It reserves a codepage at 0x7E000 for MBR parameters, which is not necessary and should not been added. The nRF52 flash algorithm in Keil will see this and perform a sector erase from 0x7F000 to 0x1F000 before flashing the application.

    Thus, the entire section in nrf_dfu_settings.c may should be commented out. However, be sure that you do not compile the secure bootloader with this section commented out, as it also uses this file!

    #if defined ( NRF52 )
    
    /**@brief   This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't
     *          locate any code or variables at his location.
     */
        
        
    #if defined ( __CC_ARM )
    
        uint8_t m_mbr_params_page[CODE_PAGE_SIZE]       __attribute__((at(NRF_MBR_PARAMS_PAGE_ADDRESS))) __attribute__((used));
    
    #elif defined ( __GNUC__ )
    
        uint8_t m_mbr_params_page[CODE_PAGE_SIZE]       __attribute__ ((section(".mbrParamsPage")));
    
    #elif defined ( __ICCARM__ )
    
        __no_init uint8_t m_mbr_params_page[CODE_PAGE_SIZE]     @ NRF_MBR_PARAMS_PAGE_ADDRESS;
    
    #else
    
        #error Not a valid compiler/linker for m_mbr_params_page placement.
    
    #endif
    
    
    /**@brief   This variable makes the linker script write the mbr parameters page address to the
     *          UICR register. This value will be written in the HEX file and thus written to the
     *          UICR when the bootloader is flashed into the chip.
     */
     
    #if defined ( __CC_ARM )
        uint32_t m_uicr_mbr_params_page_address __attribute__((at(NRF_UICR_MBR_PARAMS_PAGE_ADDRESS)))
                                                        = NRF_MBR_PARAMS_PAGE_ADDRESS;
    
    #elif defined ( __GNUC__ )
        volatile uint32_t m_uicr_mbr_params_page_address    __attribute__ ((section(".uicrMbrParamsPageAddress")))
                                                        = NRF_MBR_PARAMS_PAGE_ADDRESS;
    #elif defined ( __ICCARM__ )
    
        __root    const uint32_t m_uicr_mbr_params_page_address @ NRF_UICR_MBR_PARAMS_PAGE_ADDRESS
                                                        = NRF_MBR_PARAMS_PAGE_ADDRESS;
    
    #else
    
        #error Not a valid compiler/linker for m_mbr_params_page placement.
    
    #endif
    
    #endif // defined ( NRF52 )
    
  • Are you using the experimental buttonless example application?

  • Yes, I'm trying also with the buttonless example...