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>

  • Thanks, I will implement same.

    Also one thing, Does DFU depends on hardware. We have made few customize nrf52832 board. I found in one old board DFU is working fine but other one code is getting stuck at booloader and only advertising dfutag. Please suggest. 

  • No, if you have the same bootloader on all the boards, then DFU should work fine on all nRF52832 revision 1 and 2, see SDKs and SoftDevices

    However, if the older boards have bootloaders from older SDKs, then you might have to generate the firmware images with the compatible nrfutil version, please see https://github.com/NordicSemiconductor/pc-nrfutil#versions

  • No I am erasing entire flash and flashing new code with bootloader and softdevice. For one type of board its working fine but other code stuck at bootloader.

    Both have same nordic.

  • By stuck at bootloader, do you mean that its not advertising or is it advertising DfuTarget and not jumping to the application. 

     If its the latter, then you need to generate a bootloader settings page and merge this with the bootloader hex, see https://github.com/NordicSemiconductor/pc-nrfutil#settings

  • It advertising DfuTarget , not going to application only for 1 board, other one same settings is working fine.

    I generated and merged boot loader settings.

Reply Children
Related