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

DFU issue

Hello, I am using nrfgo studio to flash softdevice, application and bootloader on nrf52832 I am getting below issue:

"This hex file has data in SoftDevice region. Try programming using "Program SoftDevice", or erase all before programming"

Application Linker settings as below:

Bootloader Linker settings as below:

Thanks

Parents
  • Hi Chandan, 

    First, nRFGo Studio is deprecated for the nRF52 Series, please use the nRF Connect Programmer instead. 

    Which SDK version and SoftDevice version are you using? SDK v15.3.0? 

    If yes, then this is a known issue in SDK v15.3.0, i.e. that the bootloader and SoftDevice( specifically the MBR) have overlapping sections. Programming the generated bootloader hex file with nrfjprog using the --sectorerase command, which is happening under the hood in the nRF Connect Programmer app, will result in the MBR being erased. 

    This can be solved by merging the SoftDevice hex file with the bootloader hex file and then programming the combined hex. However, this is a bit cumbersome so we will likely switch to an approach where we write the bootloader start address to UICR and then the bootloader will at run-time write the bootloader start address to the MBR page. I have implemented this in SDK v15.3.0 and it is done by modifyying the uicr_bootloader_start_address section in the flash_placement.xml to the following

    // in nrf_mbr.h
    #define MBR_BOOTLOADER_ADDR      (0xFF8)
    #define MBR_PARAM_PAGE_ADDR      (0xFFC)
    
    //in app_util.h
    #define CODE_START ((uint32_t)&_vectors)
    
    //in nrf_bootloader_info.h
    #define BOOTLOADER_START_ADDR (CODE_START)
    
    //in nrf_dfu_types.h
    #define NRF_MBR_PARAMS_PAGE_ADDRESS         (0x0007E000UL)
    
    ret_code_t nrf_bootloader_write_bl_addr_to_mbr(void){
    
        if( (*(volatile uint32_t *)MBR_BOOTLOADER_ADDR != BOOTLOADER_START_ADDR) && 
         (*(volatile uint32_t *)MBR_PARAM_PAGE_ADDR = NRF_MBR_PARAMS_PAGE_ADDRESS))
         {
              // Enable Write with the NVMC
              NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
              while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    
              // Write Bootloader start address to MBR 
              *(volatile uint32_t *)MBR_BOOTLOADER_ADDR = BOOTLOADER_START_ADDR;
              // Write MBR parameter page address to MBR
              *(volatile uint32_t *)MBR_PARAM_PAGE_ADDR = NRF_MBR_PARAMS_PAGE_ADDRESS;
              // Revert NVMC to read-only
              NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
              while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
          }
    
        return NRF_SUCCESS;
    }

    You will however need to modify the flash_placement.xml to place the addresses in UICR instead of flash. 

      <MemorySegment name="uicr_bootloader_start_address" start="0x10001014" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_bootloader_start_address" address_symbol="__start_uicr_bootloader_start_address" end_symbol="__stop_uicr_bootloader_start_address" start = "0x10001014" size="0x4" />
      </MemorySegment>
      <MemorySegment name="uicr_mbr_params_page" start="0x10001018" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_mbr_params_page" address_symbol="__start_uicr_mbr_params_page" end_symbol="__stop_uicr_mbr_params_page" start = "0x10001018" size="0x4" />
      </MemorySegment>
    </Root>

Reply
  • Hi Chandan, 

    First, nRFGo Studio is deprecated for the nRF52 Series, please use the nRF Connect Programmer instead. 

    Which SDK version and SoftDevice version are you using? SDK v15.3.0? 

    If yes, then this is a known issue in SDK v15.3.0, i.e. that the bootloader and SoftDevice( specifically the MBR) have overlapping sections. Programming the generated bootloader hex file with nrfjprog using the --sectorerase command, which is happening under the hood in the nRF Connect Programmer app, will result in the MBR being erased. 

    This can be solved by merging the SoftDevice hex file with the bootloader hex file and then programming the combined hex. However, this is a bit cumbersome so we will likely switch to an approach where we write the bootloader start address to UICR and then the bootloader will at run-time write the bootloader start address to the MBR page. I have implemented this in SDK v15.3.0 and it is done by modifyying the uicr_bootloader_start_address section in the flash_placement.xml to the following

    // in nrf_mbr.h
    #define MBR_BOOTLOADER_ADDR      (0xFF8)
    #define MBR_PARAM_PAGE_ADDR      (0xFFC)
    
    //in app_util.h
    #define CODE_START ((uint32_t)&_vectors)
    
    //in nrf_bootloader_info.h
    #define BOOTLOADER_START_ADDR (CODE_START)
    
    //in nrf_dfu_types.h
    #define NRF_MBR_PARAMS_PAGE_ADDRESS         (0x0007E000UL)
    
    ret_code_t nrf_bootloader_write_bl_addr_to_mbr(void){
    
        if( (*(volatile uint32_t *)MBR_BOOTLOADER_ADDR != BOOTLOADER_START_ADDR) && 
         (*(volatile uint32_t *)MBR_PARAM_PAGE_ADDR = NRF_MBR_PARAMS_PAGE_ADDRESS))
         {
              // Enable Write with the NVMC
              NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
              while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    
              // Write Bootloader start address to MBR 
              *(volatile uint32_t *)MBR_BOOTLOADER_ADDR = BOOTLOADER_START_ADDR;
              // Write MBR parameter page address to MBR
              *(volatile uint32_t *)MBR_PARAM_PAGE_ADDR = NRF_MBR_PARAMS_PAGE_ADDRESS;
              // Revert NVMC to read-only
              NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
              while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
          }
    
        return NRF_SUCCESS;
    }

    You will however need to modify the flash_placement.xml to place the addresses in UICR instead of flash. 

      <MemorySegment name="uicr_bootloader_start_address" start="0x10001014" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_bootloader_start_address" address_symbol="__start_uicr_bootloader_start_address" end_symbol="__stop_uicr_bootloader_start_address" start = "0x10001014" size="0x4" />
      </MemorySegment>
      <MemorySegment name="uicr_mbr_params_page" start="0x10001018" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_mbr_params_page" address_symbol="__start_uicr_mbr_params_page" end_symbol="__stop_uicr_mbr_params_page" start = "0x10001018" size="0x4" />
      </MemorySegment>
    </Root>

Children
Related