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

DFU cannot upload merged hex file after changing the starting address

I am using nrf51822, I have two firmwares with different offset address, one is having offset address of 0x16000 another at 0x28000.Both are 60kb of size each. I want to start the second application sits at 0x25000 from the bootloader. For uploading these firmwares I merged two files using the mergehex tool. For starting the second application I changed the bootloader CODE_REGION_1_START= 0x28000. Then I tried to upload the merged hex file, but the dfu does not start. The nrftoolbox was stuck at 'starting dfu' message. But it will work fine if I upload the second firmware alone. What I noticed is, this problem starts after changing the m_storage_handle_app.block_id = CODE_REGION_1_START; to m_storage_handle_app.block_id = 0x28000;. What could be the reason for this issue? Please help me to solve this problem ( I am using SD v7.3 and single bank dfu).

Parents
  • Hi Muckesh, you need to replace DFU_BANK_0_REGION_START with 0x249f0 in the two if statements before NVIC_SystemReset() in main, i.e.

      if (dfu_start || (!bootloader_app_is_valid(0x249f0)))
        {
            nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);
    
            // Initiate an update of the firmware.
            err_code = bootloader_dfu_start();
            APP_ERROR_CHECK(err_code);
    
            nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
        }
    
        if (bootloader_app_is_valid(0x249f0) && !bootloader_dfu_sd_in_progress())
        {
            // Select a bank region to use as application region.
            // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
            bootloader_app_start(0x249f0);//DFU_BANK_0_REGION_START
        }
    

    You also have to edit the bootloader_app_startfunction, as the argument app_addr is not used, i.e.

    void bootloader_app_start(uint32_t app_addr)
    {
        // If the applications CRC has been checked and passed, the magic number will be written and we
        // can start the application safely.
        uint32_t err_code = sd_softdevice_disable();
        APP_ERROR_CHECK(err_code);
    
        interrupts_disable();
    
        err_code = sd_softdevice_vector_table_base_set(0x249f0);//CODE_REGION_1_START
        APP_ERROR_CHECK(err_code);
    
        bootloader_util_app_start(0x249f0);//CODE_REGION_1_START
    }
    

    -Best regards

    Bjørn

Reply
  • Hi Muckesh, you need to replace DFU_BANK_0_REGION_START with 0x249f0 in the two if statements before NVIC_SystemReset() in main, i.e.

      if (dfu_start || (!bootloader_app_is_valid(0x249f0)))
        {
            nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);
    
            // Initiate an update of the firmware.
            err_code = bootloader_dfu_start();
            APP_ERROR_CHECK(err_code);
    
            nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);
        }
    
        if (bootloader_app_is_valid(0x249f0) && !bootloader_dfu_sd_in_progress())
        {
            // Select a bank region to use as application region.
            // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
            bootloader_app_start(0x249f0);//DFU_BANK_0_REGION_START
        }
    

    You also have to edit the bootloader_app_startfunction, as the argument app_addr is not used, i.e.

    void bootloader_app_start(uint32_t app_addr)
    {
        // If the applications CRC has been checked and passed, the magic number will be written and we
        // can start the application safely.
        uint32_t err_code = sd_softdevice_disable();
        APP_ERROR_CHECK(err_code);
    
        interrupts_disable();
    
        err_code = sd_softdevice_vector_table_base_set(0x249f0);//CODE_REGION_1_START
        APP_ERROR_CHECK(err_code);
    
        bootloader_util_app_start(0x249f0);//CODE_REGION_1_START
    }
    

    -Best regards

    Bjørn

Children
No Data
Related