Hello all,
We are trying to use Background DFU.
We are able to trigger using "background_dfu_validate_trigger" and "background_dfu_process_trigger". Process the init packet block. Receive all the firmware blocks.
After calling "background_dfu_process_block" on all the firmware blocks, we call "app_sched_execute" and
"err_code = background_dfu_handle_event(&dfu.bg_dfu_ctx, BACKGROUND_DFU_EVENT_TRANSFER_COMPLETE);"
But when we reset into the bootloader we get the message "<info> app: No firmware to activate.". "nrf_dfu_validation_post_data_execute" is never called.
How do we trigger the postvalidation process after the last block is processed?
The Background DFU ctx:
bg_dfu_ctx | |
dfu_state | 0x04 |
dfu_mode | 0x00 |
reset_suppress | 0x00 |
dfu_diag | |
init_cmd_size | 140 |
init_cmd_crc | 0xc0bfbc63 |
firmware_size | 0x00002024 |
firmware_crc | 0xc0bfbc63 |
max_obj_size | 4096 |
remaining_size | 0 |
block_num | 2 |
p_resource_size | |
block_manager | |
image_size | 8228 |
image_type | 2 |
last_block_stored | 1 |
current_block | 2 |
data | |
bitmap | |
[0] | 128 |
result_handler | 0x00039fb9 |
p_context | 0x2000a538 |
currently_stored_block | 2 |
retry_count |
3 |
RTT log file:
<info> app: EVENT_ENCRYPT_NEGOTIATION_SUCCESS ch: 1, state from 02 <info> app: new state: 3 <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()... <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend. <debug> nrf_dfu_settings: Using settings page. <debug> nrf_dfu_settings: Copying forbidden parts from backup page. <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping. <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend. <info> background_dfu: Current DFU Diag version: Sep 16 2019 17:50:47, 0x7C8D85A5 <info> background_dfu: state=DFU_IDLE event=DFU_EVENT_TRANSFER_COMPLETE <info> app: state_update BACKGROUND_DFU_DOWNLOAD_TRIG <info> app: send_request BACKGROUND_DFU_DOWNLOAD_TRIG <info> background_dfu: DFU trigger: init (sz=140, crc=C0BFBC63) image (sz=8228, crc=C0BFBC63) <info> background_dfu: state=DFU_DOWNLOAD_TRIG event=DFU_EVENT_TRANSFER_COMPLETE <warning> background_dfu: Installed image CRC is different <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (command) <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (command) <error> nrf_dfu_validation: Handler: Invalid init command. <error> nrf_dfu_validation: Failed to decode init packet <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x5 <error> background_dfu: Init commad has changed <info> app: state_update BACKGROUND_DFU_DOWNLOAD_INIT_CMD <info> background_dfu: Init complete. Unicast Mode. <info> background_dfu: state=DFU_DOWNLOAD_INIT_CMD event=DFU_EVENT_TRANSFER_CONTINUE <info> app: Process block 0 <info> app: send_acknowledge_crc_to_beast block 0 CRC32 0xC0BFBC63 <info> background_dfu: Storing block (b:0 c:0). <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command) <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command) <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (command) <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (command) <debug> nrf_dfu_validation: PB: Init packet data len: 63 <info> nrf_dfu_validation: Signature required. Checking signature. <info> nrf_dfu_validation: Calculating hash (len: 63) <info> nrf_dfu_validation: Verify signature <info> nrf_dfu_validation: Image verified <debug> app: Enter nrf_dfu_cache_prepare() <debug> app: required_size: 0x2024. <debug> app: single_bank: false. <debug> app: keep_app: true. <debug> app: keep_softdevice: true. <debug> app: SD_PRESENT: true. <debug> app: Bank contents: <debug> app: Bank 0 code: 0x01: Size: 0x20804 <debug> app: Bank 1 code: 0x00: Size: 0x0 <debug> app: pass: 0. <debug> app: cache_address: 0x52000. <debug> app: cache_too_small: false. <debug> app: keep_firmware: true. <debug> app: delete_more: false. <debug> nrf_dfu_validation: Write address set to 0x00052000 <debug> nrf_dfu_settings: Writing settings... <debug> nrf_dfu_settings: Erasing old settings at: 0x000FF000 <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x000FF000, len=1 pages), queue usage: 0 <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x000FF000, src=0x2000E004, len=896 bytes), queue usage: 1 <debug> nrf_dfu_req_handler: Writing valid init command to flash. <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> background_dfu: Is image complete (o:0 n:1). <info> background_dfu: state=DFU_DOWNLOAD_INIT_CMD event=DFU_EVENT_TRANSFER_COMPLETE <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (data) <debug> nrf_dfu_req_handler: crc = 0x0, offset = 0x0, max_size = 0x1000 <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <info> app: state_update BACKGROUND_DFU_DOWNLOAD_FIRMWARE <info> background_dfu: state=DFU_DOWNLOAD_FIRMWARE event=DFU_EVENT_TRANSFER_CONTINUE <debug> nrf_dfu_flash: Flash erase success: addr=0x000FF000, pending 1 <debug> nrf_dfu_flash: Flash write success: addr=0x000FF000, pending 0 <info> app: EVENT_TRANSFER_TX_COMPLETED ch: 1 <warning> app: EVENT_TRANSFER_RX_FAILED ch: 1 <warning> app: EVENT_TRANSFER_RX_FAILED ch: 1 <warning> app: EVENT_RX_FAIL ch: 1 <warning> app: EVENT_RX_FAIL ch: 1 <warning> app: EVENT_TRANSFER_RX_FAILED ch: 1 <info> app: Block Remainder packet(7) coppied to buffer at 1000 <info> app: send_acknowledge_crc_to_beast block 0 CRC32 0x207223D <info> app: Process block 0 <info> app: app_sched_execute 001000 <info> background_dfu: Storing block (b:0 c:0). <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (data) <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x00052000, len=1 pages), queue usage: 0 <debug> nrf_dfu_req_handler: Creating object with size: 4096. Offset: 0x00000000, CRC: 0x00000000 <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data) <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x00052000, src=0x2000A57C, len=4096 bytes), queue usage: 1 <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_flash: Flash erase success: addr=0x00052000, pending 1 <debug> nrf_dfu_flash: Flash write success: addr=0x00052000, pending 0 <info> app: EVENT_TRANSFER_TX_COMPLETED ch: 1 <warning> app: EVENT_TRANSFER_RX_FAILED ch: 1 <warning> app: EVENT_TRANSFER_RX_FAILED ch: 1 <warning> app: EVENT_TRANSFER_RX_FAILED ch: 1 <warning> app: EVENT_RX_FAIL ch: 1 <info> app: Block Remainder packet(7) coppied to buffer at 1000 <info> app: send_acknowledge_crc_to_beast block 1 CRC32 0x6B820540 <info> app: Process block 1 <info> app: app_sched_execute 002000 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (data) <debug> nrf_dfu_req_handler: Offset:4096, CRC:0x0207223D <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (data) <debug> background_dfu: Is image complete (o:0 n:3). <info> background_dfu: state=DFU_DOWNLOAD_FIRMWARE event=DFU_EVENT_TRANSFER_CONTINUE <info> background_dfu: Storing block (b:1 c:1). <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (data) <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x00053000, len=1 pages), queue usage: 0 <debug> nrf_dfu_req_handler: Creating object with size: 4096. Offset: 0x00001000, CRC: 0x0207223D <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data) <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x00053000, src=0x2000B57C, len=4096 bytes), queue usage: 1 <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_flash: Flash erase success: addr=0x00053000, pending 1 <debug> nrf_dfu_flash: Flash write success: addr=0x00053000, pending 0 <info> app: EVENT_TRANSFER_TX_COMPLETED ch: 1 <info> app: Last packet(7) coppied to buffer at 0024 <info> app: send_acknowledge_crc_to_beast block 2 CRC32 0x7531A6F4 <info> app: Process block 2 <info> app: app_sched_execute 002024 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (data) <debug> nrf_dfu_req_handler: Offset:8192, CRC:0x6B820540 <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (data) <debug> background_dfu: Is image complete (o:1 n:3). <info> background_dfu: state=DFU_DOWNLOAD_FIRMWARE event=DFU_EVENT_TRANSFER_CONTINUE <info> background_dfu: Storing block (b:2 c:2). <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (data) <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x00054000, len=1 pages), queue usage: 0 <debug> nrf_dfu_req_handler: Creating object with size: 36. Offset: 0x00002000, CRC: 0x6B820540 <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data) <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x00054000, src=0x2000A57C, len=36 bytes), queue usage: 1 <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <info> app: app_sched_execute dfu.index == dfu.firmware_size <info> background_dfu: state=DFU_DOWNLOAD_FIRMWARE event=DFU_EVENT_TRANSFER_COMPLETE <info> app: state_update BACKGROUND_DFU_WAIT_FOR_RESET or IDLE <info> app: last app_sched_execute before reboot <info> app: Inside main, BOOTLOADER_START_ADDR:000ED000 <debug> app: In nrf_bootloader_init <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()... <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend. <debug> nrf_dfu_settings: Using settings page. <debug> nrf_dfu_settings: Copying forbidden parts from backup page. <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping. <info> nrf_dfu_settings: Backing up settings page to address 0xFE000. <debug> nrf_dfu_settings: Writing settings... <debug> nrf_dfu_settings: Erasing old settings at: 0x000FE000 <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x000FE000, len=1 pages), queue usage: 0 <debug> nrf_dfu_flash: Flash erase success: addr=0x000FE000, pending 0 <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x000FE000, src=0x20007E50, len=896 bytes), queue usage: 1 <debug> nrf_dfu_flash: Flash write success: addr=0x000FE000, pending 0 <debug> app: Enter nrf_bootloader_fw_activate <info> app: No firmware to activate. <info> nrf_dfu_validation: Signature required. Checking signature. <info> nrf_dfu_validation: Calculating hash (len: 133124) <info> nrf_dfu_validation: Verify signature <info> nrf_dfu_validation: Image verified <debug> app: App is valid <debug> app: DFU mode requested via GPREGRET. <info> nrf_bootloader_wdt: WDT is not enabled <debug> app: in weak nrf_dfu_init_user <debug> app: timer_stop (0x20004000) <debug> app: timer_activate (0x20004000) <debug> app: in weak nrf_dfu_init <debug> app: Enter main loop