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

Application does not start after custom DFU (hardfault_handler)

Hi,

We are using a bootloader/DFU based on the secure_bootloader example with USB transport from SDK15 and It works fine.

Now, we are trying to add the possibility to do an OTA update of our device by GSM. (first ticket here)

For this we do the “DFU” part in the app. The app is therefore responsible for:

  • download by GSM the .bin and .dat files,
  • write them in flash (bank1)
  • configure s_dfu_settings
  • write s_dfu_settings at BOOTLOADER_SETTINGS_ADDRESS
  • reset the device.

When the device restarts, the bootloader check if a new app is available and copies contents of bank1 to bank0 with app_activate()

nrf_bootloader_init() -> nrf_bootloader_fw_activate() -> app_activate()

after the copy, the bootloader performs a reset and start the application with nrf_bootloader_app_start()

 

but the application does not start and if we go in debug in bootloader we can see that the device goes into the hardfault_handler after calling jump_to_addr(new_msp, new_lr, reset_handler) in function app_start().

nrf_bootloader_app_start() -> nrf_bootloader_app_start_final() -> app_start() -> jump_to_addr()

 

Are we missing a step during the update ?

Do you have any idea what we can check/debug to find the problem ?

 

.bin file generated by nrfutil is signed for the DFU by USB.

But it is not signed for our custom DFU by GSM. So what we have to do with the .dat file ?

Configuration of s_dfu_settings in app

#define BIN_FILE_START_ADDRESS 0x000A0000UL

s_dfu_settings.bank_1.image_size = device->ota_data.fileBin.size; // size of .bin file
s_dfu_settings.bank_1.image_crc  = crc32_compute((uint8_t*)(BIN_FILE_START_ADDRESS), device->ota_data.fileBin.size, NULL);

s_dfu_settings.bank_1.bank_code = NRF_DFU_BANK_VALID_APP;
s_dfu_settings.bank_0.bank_code = NRF_DFU_BANK_INVALID;
s_dfu_settings.bank_current     = NRF_DFU_CURRENT_BANK_1;

s_dfu_settings.write_offset = 0;
s_dfu_settings.progress.update_start_address = (BIN_FILE_START_ADDRESS);

s_dfu_settings.crc = crc32_compute((uint8_t*)&s_dfu_settings + 4, DFU_SETTINGS_INIT_COMMAND_OFFSET  - 4, NULL);

Before update :

After update :


same address in bank0


Thanks for your help.

Parents
  • Hi, 

    Not sure related to this issue, but you can check it.  

    Do you have any idea what we can check/debug to find the problem ?

    You need to import HardFault handling library and enable HARDFAULT_HANDLER_ENABLED in the sdk_config.h. 

    // <q> HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release

    #ifndef HARDFAULT_HANDLER_ENABLED
    #define HARDFAULT_HANDLER_ENABLED 1
    #endif

    Please see Vidar's comments in this post on how to do that.

     

    .bin file generated by nrfutil is signed for the DFU by USB.

    But it is not signed for our custom DFU by GSM. So what we have to do with the .dat file ?

    The update file should be singed with the same pair key used in your custom DFU by GSM. If the key is not the same pair, you need to regenerate the package. 

    -Amanda H.

Reply
  • Hi, 

    Not sure related to this issue, but you can check it.  

    Do you have any idea what we can check/debug to find the problem ?

    You need to import HardFault handling library and enable HARDFAULT_HANDLER_ENABLED in the sdk_config.h. 

    // <q> HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release

    #ifndef HARDFAULT_HANDLER_ENABLED
    #define HARDFAULT_HANDLER_ENABLED 1
    #endif

    Please see Vidar's comments in this post on how to do that.

     

    .bin file generated by nrfutil is signed for the DFU by USB.

    But it is not signed for our custom DFU by GSM. So what we have to do with the .dat file ?

    The update file should be singed with the same pair key used in your custom DFU by GSM. If the key is not the same pair, you need to regenerate the package. 

    -Amanda H.

Children
Related