Automating FOTA Flashing for 20 boards of nRF52840 DK using BLE

I am working on automating the FOTA flashing process for 50 PCA10056 (nRF52840 DK) boards using a Python script. The goal is to efficiently flash firmware onto multiple boards simultaneously while ensuring reliability.

I have already tried using nrfutil, but I encounter the same error as described in Case ID: 256309. Additionally, mcumgr has never worked for me.

I would like guidance on:

  1. Best practices for automating FOTA updates on multiple nRF52840 DKs.
  2. Recommended tools and libraries (nrfutil,or other alternatives).
  3. The best command to use for this operation.
  4. Handling potential issues such as connection stability and flashing failures.
  5. Any existing scripts or references that could help streamline this process.
Parents
  • Hi,

    I assume you are using the nRF5 SDK as you are using nrfutil for this?

    Are you using nrfutil from here? That is the only currently supported version. And to update it you use "nrfutil self-upgrade" and subsequently "nrfutil pgrade" to install various commands. Note that you must install nrf5sdk-tools in order to perform nRF5 SDK DFU. If this still fails, can you show the the command you use and the log with the error?

    Regarding the specific questions, we do not have any guidance on automated FOTA testing. nrfutil is the only command line tool we provide for nRF5 SDK secure DFU, so it makes sense to call that from your python test scripts.

  • ok I installed nrfutil.  My code snip, 

      cmd = f"nrfutil dfu ble -ic NRF52 -f {firmware_file} -a {mac_address} --timeout 600"
     
                   result = subprocess.run(cmd, shell=True, capture_output=True, text=True)

          if result.returncode == 0:
                print(f"[SUCCESS] FOTA update sent to {mac_address}")
      
    output prints as SUCCESS but the device is not actually flashed. 
    since I am using the nrf52 SDK , I zipped all the bin and hex files from path  src\build\zephyr  and used a firmware_file here.
    Please let me know why the flashing didnt take place. 
  • Hi,

    I am a bit confused here. Y ou write nRF52 SDK, which I would assume point to the nRF5 SDK. But you write src\build\zephyr. If that is the case, you can use mcumgr on a Linux computer do perform DFU over the air. (The nrfutil dfu command is only relevant for the old nRF5 SDK bootloaer)

  • Actually I need to work on windows computer and found that nrfutil was the alternative way to use . Yes its a v2.7.0  nRF5 SDK. Is there a trusted library for mcumgr for windows something  like this page www.nordicsemi.com/.../ 

  • I see. But if you are using the nRF Connect SDK (as it seems), nrfutil is the only solution I am aware of, and that only works with Bluetooth on Linux.

  • I need a command line solution for my python scripts as I work with many nodes. nRF Connect SDK is a GUI/App. which doesn't match my requirement. Can you please help me to flash with nrfutil? I am using the evaluation kit  nRF52840 DK. Is there any prerequisite like going into DFU mode with button press? I  understood that command " nrfutil dfu ble..." is a SW way to put into the DFU mode. Manual  button press didn't work. 

Reply
  • I need a command line solution for my python scripts as I work with many nodes. nRF Connect SDK is a GUI/App. which doesn't match my requirement. Can you please help me to flash with nrfutil? I am using the evaluation kit  nRF52840 DK. Is there any prerequisite like going into DFU mode with button press? I  understood that command " nrfutil dfu ble..." is a SW way to put into the DFU mode. Manual  button press didn't work. 

Children
  • Hi,

    PGenius said:
    Can you please help me to flash with nrfutil?

    You can use nrfutil to flash via a debugger (the DK has an onboard debugger so if it is connected to the computer that will work out of the box with "nrfutil device", see "nrfutil device --help"), but as it seems you are using nRF Connect SDK (please confirm), that cannot be used to perform DFU over Bluetooth.

    PGenius said:
    Is there any prerequisite like going into DFU mode with button press?

    Normally not. Assuming you are using the nRF Connect SDK and do DFU over BLE, the transport happens in the application, and if you use for instance the SMP server sample, this should work out of the box (but not with nrfutil).

    I am a bit confused about this thread, so if you can back-track a bit and describe in more detail both which SDK you are using, and other details about your firmware that would help.

  • Hi Einar,

    This is my understanding. 

    • Non-Zephyr Project (nrf5 SDK maintenance mode ): Uses Nordic Secure Bootloader and works with nrfUtil for firmware updates.

    • Zephyr Project (nrf Connect SDK - NCS): Uses MCUBoot (if configured) and works with MCUmgr for firmware updates

    To be precise, I am using windows platform, NCS  and want to perform FOTA with BLE, Is MCUmgr only the possibility? 

    I was unsuccessful with FOTA Flashing  with configuration in NCS, 

    CONFIG_BT_PERIPHERAL=y

    CONFIG_BOOTLOADER_MCUBOOT=y

    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    when i tested with 
    cmd = f"nrfutil dfu ble --conn-ic NRF52 -pkg {firmware_file} --timeout 3000"
    I am right now blocked if i am on a right track or should I use MCUmgr library or does Nordic support any other libraries ? I am still unclear with  this SMP sample 
  • Hi,

    PGenius said:
    To be precise, I am using windows platform, NCS  and want to perform FOTA with BLE, Is MCUmgr only the possibility? 

    For PC side, mcumgr is the only possibility (in the sense that we are not developing an alternative, but it is possible to develop this yourself if needed). mcumgr does not work with Bluetooth on Windows, so we do not currently provide any solution for that from the command line.

    PGenius said:
    I am right now blocked if i am on a right track or should I use MCUmgr library or does Nordic support any other libraries ? I am still unclear with  this SMP sample 

    You are not on the right track, as you cannot perform DFU for nRF Connect (MCUboot) via nrfutil.

    One suggestion is to use a Linux computer for your automated testing, and use mcumgr via the command lien there. Another is to do manual testinf of DFU. The third is to develop your own solution.

  • Hi Einar,

    I have installed Linux on my raspberry pi and also mcumgr command installation successfully . I see that all the steps works fine until I confirm the image . I get error 3 for "image confirm" cmd. Due to this my flashed SW is not permanent. I have changed the device name as well. 

    I use nRF Connect SDK Toolchain v2.7.0

    1) I have added these below changes in proj_conf; 

    CONFIG_BOOTLOADER_MCUBOOT=y

    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    2)

    new image is now swapped from slot 1 to slot 0, user@raspberrypi:~ $ sudo mcumgr --conntype ble --connstring 'peer_name=Zephyrtest' image list

    Images:

     image=0 slot=0

        version: 2.6.0

        bootable: true

        flags: active

        hash: 45e6a61863cc78237c8467359fed716e611a346cede52c0df087ec67718472c7

     image=0 slot=1

        version: 2.6.0

        bootable: true

        flags: confirmed

        hash: 8e30aa3cffb62bcf8a05cfb199505bb97843ccab8a5bc99abd97f0c132d2a052

    Split status: N/A (0)

    user@raspberrypi:~ $ 

    sudo mcumgr --conntype ble --connstring 'peer_name=hoetest' image confirm

    Error: 3


    sudo mcumgr --conntype ble --connstring 'peer_name=hoetest' image confirm
    Error: 3

  • Hi,

    I am glad to see most things are wokring. Regardign confirming the image, you need to provide the hash at the enf of you rcommand (so ...image confirm <HASH>)

Related