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

nrfutil dfu random failures

We're using nrfutil v.6.1.0 in order to perform DFU updates to our target board using nrf52840-Dongle, and we're experiencing some issues. Everytime we try a download, even if sometimes we're able to successfully perform it, we often witness a high failure rate, mostly caused by random errors happening while trying to connect to the target board, like the following:

pc_ble_driver_py.exceptions.NordicSemiException: Failed to ble_gattc_exchange_mtu_req. Error code: NRF_ERROR_INVALID_PARAM

pc_ble_driver_py.exceptions.NordicSemiException: MTU exchange request failed. Common causes are: missing att_mtu setting in ble_cfg_set, different config tags used in ble_cfg_set and connect.

We tried with a lower MTU, or disabling the MTU negotiation inside the nrfutil python script, but it did not solve the issue.

We tried to perform the download using nRF Connect v3.5.0 (Bluetooth Low Energy App v.2.4.0) using the same dongle, and we experienced no issues at all, 100% download success rates;
so we assumed that the issue was not inside the nrf connectivity Fw of the dongle, nor in our target board bootloader.

We did some research and found out that at the time of writing, nRF Connect v3.5.0 relies on pc-ble-driver-js v2.7.2 library to perform DFU updates, while nrfutil uses pc-ble-driver-py v0.14.2.
Both libraries relies on pc-ble-driver library but the phyton lib is outdated and currently points to pc-ble-driver v4.1.1, while the Node.JS lib points to pc-ble-driver v4.1.2.

In the release notes of pc-ble-driver v4.1.2, the following it's stated:

Bug fixes

  • Fixed an issue where events after SD_BLE_GAP_CONNECT were occasionally not received
  • Fixed an issue where USB connectivity firmware hangs after receiving many notifications

We're suspecting that those fixes are related to the issues we're experiencing and so we're wondering if you could update pc-ble-driver-py to the latest pc-ble-driver version and release an updated nrfutil tool.
Since we're planning to use nrfutil to perform updates on the company assembly line by december, we cannot rely on the current unstable behavior, so the issue is quite urgent and we'd like to have a stable version asap.

Can you please comment on our considerations? could it be the root cause? are you already planning a new release of nrfutil? if yes, when?

Thank you very much for your support.

Regards.

  • We're having hard time try to focus where the problem actually is, what i can tell you right now is the following:

    • your script runs fine on nRF52840 DK eval board, no failures
    • using nRF52833 DK we experienced some failures with untouched secure_bootloader\pca10100_s140_ble
    • we never experienced failures using nRFConnect Ble 

    After many tests, we're pretty confident that neither the target Hw, nor the target bootloader is responsible for the failures, it's something related to the PC side (libs or dongle fw).

    We would really like to try to use nrfutils with an updated version of  pc-ble-driver-py library which links to the latest pc-ble-driver v4.1.2, rather than the current pc-ble-driver v4.1.1, is this possible?

  • simone.bonetti said:
    We would really like to try to use nrfutils with an updated version of  pc-ble-driver-py library which links to the latest pc-ble-driver v4.1.2, rather than the current pc-ble-driver v4.1.1, is this possible?

     I understand, but this is not something I possess. 

    I tried to run a similar script using the nRF52833 as the target device:

    set TARGET_SNR=685133991
    set CONNECTIVITY_COM_PORT=COM5
    
    del ..\..\..\private.key
    del ..\..\..\dfu_public_key.c
    
    nrfutil keys generate ..\..\..\private.key
    nrfutil keys display --key pk ..\..\..\private.key --format code --out_file ..\..\..\dfu_public_key.c
    
    make -j9
    make -j9 -C ..\..\..\..\ble_peripheral\ble_app_uart\pca10100\s140\armgcc
    
    mkdir files
    
    del files\ble_uart.hex
    copy ..\..\..\..\ble_peripheral\ble_app_uart\pca10100\s140\armgcc\_build\nrf52833_xxaa.hex files\ble_uart.hex
    
    del files\bl_settings.hex
    nrfutil settings generate --family NRF52 --application files\ble_uart.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 --key-file ..\..\..\private.key files\bl_settings.hex
    del files\fake_settings.hex
    nrfutil settings generate --family NRF52 --application _build\nrf52833_xxaa_s140.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 --key-file ..\..\..\private.key files\fake_settings.hex
    
    nrfjprog -e --snr %TARGET_SNR%
    nrfjprog --program ..\..\..\..\..\components\softdevice\s140\hex\s140_nrf52_7.0.1_softdevice.hex --verify --snr %TARGET_SNR%
    nrfjprog --program _build\nrf52833_xxaa_s140.hex --verify --snr %TARGET_SNR%
    ::nrfjprog --program files\ble_uart.hex --verify --snr %TARGET_SNR%				COMMENTED OUT ON PURPOSE
    ::nrfjprog --program files\bl_settings.hex --verify --snr %TARGET_SNR%			COMMENTED OUT ON PURPOSE
    nrfjprog --reset --snr %TARGET_SNR%
    
    del files\dfu_image_2.zip
    del files\dfu_image_3.zip
    del files\dfu_image_4.zip
    del files\dfu_image_5.zip
    del files\dfu_image_6.zip
    del files\dfu_image_7.zip
    del files\dfu_image_8.zip
    del files\dfu_image_9.zip
    del files\dfu_image_10.zip
    del files\dfu_image_11.zip
    
    nrfutil pkg generate --application files\ble_uart.hex --application-version 2 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_2.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 3 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_3.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 4 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_4.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 5 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_5.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 6 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_6.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 7 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_7.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 8 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_8.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 9 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_9.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 10 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_10.zip
    nrfutil pkg generate --application files\ble_uart.hex --application-version 11 --hw-version 52 --sd-req 0xCA --key-file ..\..\..\private.key files\dfu_image_11.zip
    
    :: TODO: flash the dongle with firmware connectivity. Use e.g. nrfutil dfu ble -pkg files\dfu_image_2.zip -ic NRF52 -p COMX -n "Nordic_Buttonless" -f once before runnign this script. Be aware that flashing this may change the COM port for the dongle.
    
    nrfutil dfu ble -pkg files\dfu_image_2.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_3.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_4.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_5.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_6.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_7.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_8.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_9.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_10.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    
    nrfutil dfu ble -pkg files\dfu_image_11.zip -ic NRF52 -p %CONNECTIVITY_COM_PORT% -n "DfuTarg"
    TIMEOUT 5
    nrfjprog --program files\fake_settings.hex --verify --sectorerase --snr %TARGET_SNR%
    nrfjprog --reset --snr %TARGET_SNR%
    

    Can you please try to copy this to the location:

    SDK17\examples\dfu\secure_bootloader\pca10100_s140_ble\armgcc.

    You need to call the script SDK17\external\micro-ecc\build_all.bat before you compile the bootloader using the script (but I guess you already know this if you compiled the bootloader earlier. 

    Can you please try this in an unmodified SDK?

    The reason I ask you to test these is not just to have you spend time on unnecessary tests, but I am trying to narrow down what the issue may be. Did you do any changes to the bootloader? When I ran this script, it didn't fail at any of the DFU updates. 

    If you don't fail on any of the 10 tests in the script, can you try to zip a project + bootloader combination that reproduces the issue, and zip the projects and send them to me here? Please make sure that the projects compile when you unzip them in an unmodified SDK before sending them. 

    BR,

    Edvin

Related