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 :

  • yes I confirm my feeling.

    hardfault arrive in nrf_dfu_settings_write_and_backup()  because it try to erase at adress 0x7e000.

    question : why?

  • The hardfault happens because the app is not intented to have access the backup page (i.e, MBR param page), see my first post to see which fields the it's permitted to change by default. But, if you want to give you give your app full write access, you can do so by disabling the flash protection in your bootloader as you already suggested.

  • yes understood the reason of hardfault.

    What I don't understand is :

    why the function invalidate is not sufficient ?

    after loading zip file, bootloader call my app

    then we do this :

      ret_code_t ret_val = nrf_dfu_settings_init(false);
      if (ret_val != NRF_SUCCESS)
      {
        //return NRF_ERROR_INTERNAL;
        NRF_LOG_ERROR("Impossible d'init nrf_dfu_settings_init");
      }
      else
      {
        NRF_LOG_DEBUG("s_dfu_settings bank 1 : 0x%02x", s_dfu_settings.bank_1.bank_code);
        if (s_dfu_settings.bank_1.bank_code == NRF_DFU_BANK_VALID_EXT_APP)
        {

    else the s_dfu_settings.bank_1.bank_code is never valid.

    but if I do this the s_dfu_settings.bank_1.bank_code is ALWAYS valide except if we wrote in MBR param.
    just want to understand why i need to erase MBR param.

    seems data are written by bootloader to inform data available but then restore at each reboot except if I wrote it back in MBR param

  • I'm not sure I understand the setup, is the received image meant for an external device? In that case, is the image transferred to the other chip by your application or by your bootloader? And is the problem that you can't clear the .bank_1 code after the update is complete?

Related