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

DFU

Hi,

I use a custom board, softdevice and boot loader.

I use DFU to update a slave chip firmware. Everything goes right until we invalidate and write flash :   

        // Invalidate bank, marking completion.
        nrf_dfu_bank_invalidate(&s_dfu_settings.bank_1);

        uint32_t ret_val = nrf_dfu_settings_write_and_backup(NULL);

the nrf_dfu_settings_write_and_backup lead to a HARDFAULT handler because of accessing flash :

Parents Reply Children
  • I will try this

    NRF_BL_DFU_ALLOW_UPDATE_FROM_APP set to 1 in bootloader

    and

    NRF_DFU_IN_APP set to 1 in our app.

    Is that correct?

  • yes it my app that call nrf_dfu_settings_write_and_backup() at the end of our slave chip doanloading

  • Yes, please try again with NRF_DFU_IN_APP  set to 1 in the app. This is probably the reason for the hardfault.

  • in that case this part is not done :

    nrf_dfu_settings_write_and_backup()

    and the log message say this :

    nrf_dfu_settings: Copying forbidden parts from backup page.
    source, write not needed. Skipping.

    and so after a power off/power on the binary is written again, but I don't want this.

    Actually, what I want is the same behavior when my debugger is connected (the area can be written and all is fine)

    actually the only way I found to have a correct behavior was this : comment the flash protect in the bootloader

    //    ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, area_size);

    //    ret_val = nrf_bootloader_flash_protect(0,
    //                    nrf_dfu_bank0_start_addr() + ALIGN_TO_PAGE(s_dfu_settings.bank_0.image_size));

  • Hi Vidar,

    maybe i found out why setting NRF_BL_DFU_ALLOW_UPDATE_FROM_APP is not enough in our case.

    actually I look in details the bootloader and found this :

        area_size = BOOTLOADER_SIZE + NRF_MBR_PARAMS_PAGE_SIZE;

        if (!NRF_BL_DFU_ALLOW_UPDATE_FROM_APP && !NRF_BL_DFU_ENTER_METHOD_BUTTONLESS && !NRF_DFU_TRANSPORT_BLE)
        {
            area_size += BOOTLOADER_SETTINGS_PAGE_SIZE;
        }

        ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, area_size);

    in my case BOOTLOADER_SIZE is

    #define BOOTLOADER_SIZE (NRF_MBR_PARAMS_PAGE_ADDRESS - BOOTLOADER_START_ADDR)

    What I found is the following :

    actually it BOOTLOADER_START_ADDR  is 0x00078000 (in debug mode I look at nrf_bootloader_flash_protect() function)

    area_size is 0x7000.

    and so all the end of flash is then protected and then the bootloader settings as well.

    Maybe we have miss something here.

    Could you tell us more on this?

    Thanks



Related