Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

nRF Toolbox DFU suddenly fails with Error 4 - Insufficient resources

Hi there,

We've been doing OTA DFU updates for a while now, but a recent increase (by one page = 4kb) of the firmware has created an issue.

Flashing through USB serial works fine, but the same firmware can't be pushed with nRF Toolbox DFU via Bluetooth anymore. When trying to do so, it almost immediately generates an Error 4 - Insufficient resources.

Given the error, I can only imagine that the device runs out of flash memory. This new version of our firmware is slightly bigger than previous versions. Once flashed through USB serial along with the Bootloader and the SoftDevice, there is only one page of flash memory left available. But it is immediately used by the firmware for fstorage when it first runs.

I couldn't find a definitive answer but I'm thinking that the DFU settings backup feature needs one free page of flash memory, and because it fails do so the update is aborted.

I would like to know if my assumptions are correct or if the OTA DFU might fail for another reason.

Thanks a lot!

Parents
  • Hi,

    Insufficient resources (NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES) happens if: 

    - nrf_dfu_cache_prepare() cannot find room for the update (what you are assuming)

    - If trying to push a bootloader update that is too large to fit the bootloader slot (BOOTLOADER_SIZE).

    - If the init command is too big (INIT_COMMAND_MAX_SIZE)

    - If the protocol attempts to create an object that is too big (failure of the DFU protocol)

    We assume it is the first one. OTA DFU is using dual bank, while flashing over USB does not,that may be why you only see it in DFU. There is a difference in when dual bank is used, you can look in nrf_dfu_cache_prepare() to see the details about calculation of the bank size.

  • Hi Mttrinh,
    I am new with nRF microcontrollers.
    I created a custom board that mounts the nRF52840 microcontroller. I made a firmware that uses BLE to exchange data and everything works fine.
    Now I want to use the OTA DFU.
    I used the example provided in the SDK: (examples \ dfu \ secure_bootloader \ pca10056_s140_ble_debug).

    I created a Distribution packet (ZIP) with the command: python nordicsemi/__main__.py pkg generate --application hand.hex hand.zip --hw-version 1 --sd-req 0x100 --application-version 1 --key-file priv.pem
    When I connect to the DfuTarg device and select the zip file to send, the device disconnects. The error "<warning> nrf_dfu_ble: DFU request 4 failed with error: 0xB" appears on the Debug Terminal.
    Can anyone help me understand why the operation is not successful?
    I use SoftDevice s140 (7.2.0).
    Below is the contents of the Debug Terminal:

    <info> app: Inside main
    <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: Destination settings are identical to source, write not needed. Skipping.
    <debug> app: Enter nrf_bootloader_fw_activate
    <info> app: No firmware to activate.
    <info> app: Boot validation failed. No valid app to boot.
    <debug> app: DFU mode because app is not valid.
    <info> nrf_bootloader_wdt: WDT is not enabled
    <debug> app: in weak nrf_dfu_init_user
    <debug> app: timer_stop (0x20005994)
    <debug> app: timer_activate (0x20005994)
    <info> app: Entering DFU mode.
    <debug> app: Initializing transports (found: 1)
    <debug> nrf_dfu_ble: Initializing BLE DFU transport
    <debug> nrf_dfu_ble: Setting up vector table: 0x000F1000
    <debug> nrf_dfu_ble: Enabling SoftDevice.
    <debug> nrf_dfu_ble: Configuring BLE stack.
    <debug> nrf_dfu_ble: Enabling the BLE stack.
    <debug> nrf_dfu_ble: No advertising name found
    <debug> nrf_dfu_ble: Using default advertising name
    <debug> nrf_dfu_ble: Advertising...
    <debug> nrf_dfu_ble: BLE DFU transport initialized.
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    <debug> app: Enter main loop
    <debug> nrf_dfu_ble: Connected
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST.
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE (27, max_rx_time 328).
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 6
    <debug> nrf_dfu_ble: min_conn_interval: 6
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 500
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600
    <debug> nrf_dfu_ble: Received BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST (request: 517, reply: 247).
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST.
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE (251, max_rx_time 2120).
    <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_ble: Set receipt notif
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_RECEIPT_NOTIF_SET
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    <debug> app: timer_stop (0x20005994)
    <debug> app: timer_activate (0x20005994)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_ble: Buffer 0x200092C8 acquired, len 141 (244)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    <debug> nrf_dfu_ble: Freeing buffer 0x200092C8
    <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: 64
    <info> nrf_dfu_validation: Signature required. Checking signature.
    <info> nrf_dfu_validation: Calculating hash (len: 64)
    <info> nrf_dfu_validation: Verify signature
    <info> nrf_dfu_validation: Image verified
    <warning> nrf_dfu_ver_validation: Faulty HW version.
    <warning> nrf_dfu_validation: Prevalidation failed.
    <debug> nrf_dfu_validation: Init command:
    <debug> nrf_dfu_validation: 08 01 10 01 1A 02 80 02|........
    <debug> nrf_dfu_validation: 20 00 28 00 30 00 38 BC| .(.0.8.
    <debug> nrf_dfu_validation: BB 0D 42 24 08 03 12 20|..B$...
    <debug> nrf_dfu_validation: A9 CD B1 8F 69 AD 38 79|....i.8y
    <debug> nrf_dfu_validation: 2E 77 F7 2F 2D 07 60 17|.w./-.`.
    <debug> nrf_dfu_validation: 0C 29 18 AB 36 79 AE 7E|.)..6y.~
    <debug> nrf_dfu_validation: 6D E4 70 DF A5 89 04 97|m.p.....
    <debug> nrf_dfu_validation: 48 00 52 04 08 01 12 00|H.R.....
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0xB
    <warning> nrf_dfu_ble: DFU request 4 failed with error: 0xB
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 6
    <debug> nrf_dfu_ble: min_conn_interval: 6
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 500
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600

Reply
  • Hi Mttrinh,
    I am new with nRF microcontrollers.
    I created a custom board that mounts the nRF52840 microcontroller. I made a firmware that uses BLE to exchange data and everything works fine.
    Now I want to use the OTA DFU.
    I used the example provided in the SDK: (examples \ dfu \ secure_bootloader \ pca10056_s140_ble_debug).

    I created a Distribution packet (ZIP) with the command: python nordicsemi/__main__.py pkg generate --application hand.hex hand.zip --hw-version 1 --sd-req 0x100 --application-version 1 --key-file priv.pem
    When I connect to the DfuTarg device and select the zip file to send, the device disconnects. The error "<warning> nrf_dfu_ble: DFU request 4 failed with error: 0xB" appears on the Debug Terminal.
    Can anyone help me understand why the operation is not successful?
    I use SoftDevice s140 (7.2.0).
    Below is the contents of the Debug Terminal:

    <info> app: Inside main
    <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: Destination settings are identical to source, write not needed. Skipping.
    <debug> app: Enter nrf_bootloader_fw_activate
    <info> app: No firmware to activate.
    <info> app: Boot validation failed. No valid app to boot.
    <debug> app: DFU mode because app is not valid.
    <info> nrf_bootloader_wdt: WDT is not enabled
    <debug> app: in weak nrf_dfu_init_user
    <debug> app: timer_stop (0x20005994)
    <debug> app: timer_activate (0x20005994)
    <info> app: Entering DFU mode.
    <debug> app: Initializing transports (found: 1)
    <debug> nrf_dfu_ble: Initializing BLE DFU transport
    <debug> nrf_dfu_ble: Setting up vector table: 0x000F1000
    <debug> nrf_dfu_ble: Enabling SoftDevice.
    <debug> nrf_dfu_ble: Configuring BLE stack.
    <debug> nrf_dfu_ble: Enabling the BLE stack.
    <debug> nrf_dfu_ble: No advertising name found
    <debug> nrf_dfu_ble: Using default advertising name
    <debug> nrf_dfu_ble: Advertising...
    <debug> nrf_dfu_ble: BLE DFU transport initialized.
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    <debug> app: Enter main loop
    <debug> nrf_dfu_ble: Connected
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST.
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE (27, max_rx_time 328).
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 6
    <debug> nrf_dfu_ble: min_conn_interval: 6
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 500
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600
    <debug> nrf_dfu_ble: Received BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST (request: 517, reply: 247).
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST.
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE (251, max_rx_time 2120).
    <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_ble: Set receipt notif
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_RECEIPT_NOTIF_SET
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    <debug> app: timer_stop (0x20005994)
    <debug> app: timer_activate (0x20005994)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_ble: Buffer 0x200092C8 acquired, len 141 (244)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    <debug> nrf_dfu_ble: Freeing buffer 0x200092C8
    <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: 64
    <info> nrf_dfu_validation: Signature required. Checking signature.
    <info> nrf_dfu_validation: Calculating hash (len: 64)
    <info> nrf_dfu_validation: Verify signature
    <info> nrf_dfu_validation: Image verified
    <warning> nrf_dfu_ver_validation: Faulty HW version.
    <warning> nrf_dfu_validation: Prevalidation failed.
    <debug> nrf_dfu_validation: Init command:
    <debug> nrf_dfu_validation: 08 01 10 01 1A 02 80 02|........
    <debug> nrf_dfu_validation: 20 00 28 00 30 00 38 BC| .(.0.8.
    <debug> nrf_dfu_validation: BB 0D 42 24 08 03 12 20|..B$...
    <debug> nrf_dfu_validation: A9 CD B1 8F 69 AD 38 79|....i.8y
    <debug> nrf_dfu_validation: 2E 77 F7 2F 2D 07 60 17|.w./-.`.
    <debug> nrf_dfu_validation: 0C 29 18 AB 36 79 AE 7E|.)..6y.~
    <debug> nrf_dfu_validation: 6D E4 70 DF A5 89 04 97|m.p.....
    <debug> nrf_dfu_validation: 48 00 52 04 08 01 12 00|H.R.....
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0xB
    <warning> nrf_dfu_ble: DFU request 4 failed with error: 0xB
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 6
    <debug> nrf_dfu_ble: min_conn_interval: 6
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 500
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    <debug> nrf_dfu_ble: max_conn_interval: 12
    <debug> nrf_dfu_ble: min_conn_interval: 12
    <debug> nrf_dfu_ble: slave_latency: 0
    <debug> nrf_dfu_ble: conn_sup_timeout: 600

Children
No Data
Related