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

DFU SDK15 CRC problem.

Hi!

nRF52832, SDK15, S132.

I try to use DFU. I already implemented same DFU on a SDK13. All works correct. 

When flash SD132 and merged firmware with bootloader_setting.hex, always DFU targ started in a air.

 0> <info> app: Inside main
 0> <debug> app: In nrf_bootloader_init
 0> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
 0> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
 0> <debug> app: Enter nrf_bootloader_fw_activate
 0> <info> app: No firmware to activate.
 0> <debug> app: Enter nrf_dfu_app_is_valid
 0> <debug> app: Return false in CRC
 0> <debug> app: DFU mode because app is not valid.
 0> <info> nrf_bootloader_wdt: WDT is not enabled
 0> <debug> app: in weak nrf_dfu_init_user
 0> <info> app_timer: RTC: initialized.
 0> <info> app: Entering DFU mode.
 0> <debug> app: Initializing transports (found: 1)
 0> <debug> nrf_dfu_ble: Initializing BLE DFU transport
 0> <debug> nrf_dfu_ble: Setting up vector table: 0x00072000
 0> <debug> nrf_dfu_ble: Enabling SoftDevice.
 0> <debug> nrf_dfu_ble: Configuring BLE stack.
 0> <debug> nrf_dfu_ble: Enabling the BLE stack.
 0> <debug> nrf_dfu_ble: No advertising name found
 0> <debug> nrf_dfu_ble: Using default advertising name
 0> <debug> nrf_dfu_ble: Advertising...
 0> <debug> nrf_dfu_ble: BLE DFU transport initialized.
 0> <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
 0> <debug> app: Enter main loop

Therefore, problem in a CRC that DFU can't calculate CRC of the app.

        if (crc != s_dfu_settings.bank_0.image_crc)
        {
            // CRC does not match with what is stored.
            NRF_LOG_DEBUG("Return false in CRC");
            return  false;
        }

If I changed to return true; , all work fine.

One more time, I use same merge code for get bootloader_setting.hex in the SDK13 and it wors fine.

I use example from

https://devzone.nordicsemi.com/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader

Should make any changes for calculate CRC in the SDK15?

Parents Reply Children
  • The data will never be preserved between DFU if they are between the start address and end address of the application .hex file. So if you want to preserve the data after DFU you cannot include it in the application like you do (with __attribute__((section(".ARM.__at_0x71400")))...) as we have discussed. This will mean that everything between the application start address and the page with the data section will be erased when you do DFU, which is expected and correct behavior.

    To keep the data during DFU, make sure to not include the data in the application hex, and put it on the page right beneath FDS. Then adjust DFU_APP_DATA_RESERVED accordingly so that the bootloader does not overwrite the data during a DFU upgrade.

  • I have now in the bootloader project

    #ifndef DFU_APP_DATA_RESERVED
    #define DFU_APP_DATA_RESERVED (CODE_PAGE_SIZE * 3)

    and located my data at the main app at 0x6EC00 right beneath FDS.

    Therefore ,  can I count on normal storage data between DFU or no?

  • No, you cannot. FDS uses three pages, and you would need to reserve an additional page for your data (starting at 0x6E000). Your current DFU_APP_DATA_RESERVED value will only tell the bootloader to leave the three pages used by FDS alone (0x6F000-0x71FFF), so you must set DFU_APP_DATA_RESERVED higher to reserve the additional page:

    #define DFU_APP_DATA_RESERVED (CODE_PAGE_SIZE * 3)

  • Let's speak one more time again.

    FDS used (0x6F000-0x71FFF). Is it right?

    Therefore, I should plase data below 0x6F000. Right?

    Is it incorrect to locate data at 0x6EC00? 

    Why?

    Or should set DFU_APP_DATA_RESERVED  more than 3? Because this means for total reserve FDS and my storage data?

  • Mikhail said:
    FDS used (0x6F000-0x71FFF). Is it right?

    Yes, that is correct. FDS uses flash pages directly beneath the bootloader. In your case your bootloader starts at 0x72000, and as you use 3 pages for FDS, this means that FDS starts at 0x6F000.

    Mikhail said:
    Therefore, I should plase data below 0x6F000. Right?

    Yes.

    Mikhail said:
    Is it incorrect to locate data at 0x6EC00? 

     No, that is OK.

    Mikhail said:
    Or should set DFU_APP_DATA_RESERVED  more than 3? Because this means for total reserve FDS and my storage data?

     YES! You need to set it to 4, as that is the total amount of pages below the bootloader you want to preserve.

Related