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

DFU bootloader resets

I use SDK15 and S132. I have examples\dfu\secure_bootloader\pca10040_ble loaded in my board. I can see it advertising when there is not valid app loaded.

Also, my app with ble butonless dfu service, when it it loaded together with settings file using nrfjprog -f NRF52 --program settings.hex --sectorerase previously generated by nrfutil, works.

The bootloader settings of my app looks like:

Bootloader DFU Settings:
* File: settings.hex
* Family: nRF52
* Start Address: 0x0007F000
* CRC: 0x83842E94
* Settings Version: 0x00000001 (1)
* App Version: 0x00000001 (1)
* Bootloader Version: 0x00000001 (1)
* Bank Layout: 0x00000000
* Current Bank: 0x00000000
* Application Size: 0x00029930 (170288 bytes)
* Application CRC: 0xFE9E2E33
* Bank0 Bank Code: 0x00000001
* Softdevice Size: 0x00000000 (0 bytes)
* Boot Validation CRC: 0x00000000
* SD Boot Validation Type: 0x00000000 (0)
* App Boot Validation Type: 0x00000000 (0)

I then create update package using nrfutil pkg generate --hw-version 52 --sd-req 0xA8,0xAF,0xB7 --application-version 2 --application nrf5.hex --key-file priv.pem app_dfu_package.zip:

DFU Package: <app_dfu_package.zip>:
|
|- Image count: 1
|
|- Image #0:
|- Type: application
|- Image file: nrf5.bin
|- Init packet file: nrf5.dat
|
|- op_code: INIT
|- signature_type: ECDSA_P256_SHA256
|- signature (little-endian): e2e2bbfc7cfb8e2e7039e8482424e6a1359c40f8f869b36b60ce72735cee14353ac691f0782172248f7da3732159570b4d3363cd3d385fb4e49c2140210613aa
|
|- fw_version: 0x00000002 (2)
|- hw_version 0x00000034 (52)
|- sd_req: 0xA8, 0xB7, 0xAF
|- type: APPLICATION
|- sd_size: 0
|- bl_size: 0
|- app_size: 170208
|
|- hash_type: SHA256
|- hash (little-endian): 67e65daaafc9c59a38e2044c52459ab5f71bdb9298268d43c96df5311d6b55dc
|
|- boot_validation_type: ['VALIDATE_GENERATED_CRC']
|- boot_validation_signature (little-endian): ['']
|
|- is_debug: False

I use nrf Connect v2.6.1 on Windows 10 to run DFU update. It connects to my device with buttonless dfu service and I can initiate dfu update. After a while the update ends with error: ERROR DFU failed with error: When writing 'EXECUTE' command to Control Point Characteristic of DFU Target: Timed out while waiting for response to operation code 4 (EXECUTE).

I can see my device restarts with old app running several seconds before the error is displayed.

This is log from nrf connect: http://mysharegadget.com/744176722 

  • Hi, 

    Have you tested the bootloader to do DFU without using the buttonless application ?

     Could you test the bootloader debug variant so we can have some more logging information from the bootloader  ? 

    Have you made any modification to the bootloader ? 

    From your log, it doesn't seem the image has been transferred fully. Looks more like there was an issue when the init packet being transferred. 

  • OK. I tried to perform DFU without the buttonless application. I modified the bootloader a little to support logging (the bootloader starts at 0x70000). I get this log output:

    <info> app: Inside main
    0> <info> app: No firmware to activate.
    0> <info> nrf_bootloader_wdt: WDT is not enabled
    0> <info> app: Entering DFU mode.
    0> <info> nrf_dfu_validation: Signature required. Checking signature.
    0> <info> nrf_dfu_validation: Calculating init packet hash (init packet len: 68)
    0> <info> nrf_dfu_validation: Verify signature
    0> <info> nrf_dfu_validation: Image verified
    0> <error> app: Received a fault! id: 0x00001001, pc: 0x00071EEE, info: 0x40000000

    Not sure whether the fault isn't caused by my bootloader upgrade to support logging. But the symptoms are same as previously - bootloader resets itself during update.

  • Hi, 

    Please test again without any modification of the bootloader.

    The pc location of 0x71EEE suggest that it's the issue inside the bootloader. Could you add DEBUG to the preprocessor symbol in project setting and set the optimization level to 0 ? This would make it stay in a loop when assert (fault) happens, and you should be able to see the line of code that's causing the issue. There is  a debug guide here.  

  • Hi, I deleted all modifications to bootloader. The same happens now - app_error_fault_handler is called with id = 0x1001, pc = 0x78f30, info = 0x40000000 . The call stack is 0x00024008, then app_error_fault_handler. I can't set optimization to 0 as bootloader then doesn't fit into FLASH (without modifying linker script).

  • Please move the bootloader down in the flash to give more space. Or you can use the debug variant of the bootloader to test. 
    Make sure you erased the flash completely before testing.

    Which image did you use ? I have a step by step guide here that could be useful. 

Related