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

DFU don't start with nrfutil dfu ble

Hi, 

I face a problem when trying to perform a DFU firmware update via command line using nrfutil dfu ble. 

I'm using windows 10 and nrfutil.exe version 3.5.0

nrfutil dfu ble -ic NRF52 -pkg app_dfu_package.zip -p COM7 -n "DfuBoot_2018_07_18"
  [------------------------------------]    0%
Traceback (most recent call last):
  File "nordicsemi\__main__.py", line 983, in <module>
  File "site-packages\click\core.py", line 722, in __call__
  File "site-packages\click\core.py", line 697, in main
  File "site-packages\click\core.py", line 1066, in invoke
  File "site-packages\click\core.py", line 1066, in invoke
  File "site-packages\click\core.py", line 895, in invoke
  File "site-packages\click\core.py", line 535, in invoke
  File "nordicsemi\__main__.py", line 834, in ble
  File "nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
  File "nordicsemi\dfu\dfu.py", line 90, in _dfu_send_image
  File "nordicsemi\dfu\dfu_transport_ble.py", line 450, in open
  File "nordicsemi\dfu\dfu_transport_ble.py", line 106, in open
  File "site-packages\pc_ble_driver_py\ble_driver.py", line 126, in wrapper
pc_ble_driver_py.exceptions.NordicSemiException: Failed to open. Error code: 13
Failed to execute script __main__

I am using for the PCA10040 EVB as connectivity device

The SoftDevice is: s132_nrf52_5.0.0_softdevice.hex

The SDK is: nRF5_SDK_14.2.0_17b948a

The comport is COM7, since this is the com that I see when using the "nRF Connect" PC application and also with the Device manager.

COM7     DEV

I am sure that I have the connectivity firmware on the connectivity device, since when I try it with option -f it give a feedback: "Board already flashed with connectivity firmware."

When I am using the  "nRF Connect" PC application, the secure DFU process is working, but I want to use the command line DFU since I have the nrfutil python source code and in this way I may try to change some timeouts for our development process.

Thanks,

Yosi.

  • Hello,

    I do have 2 EVBs, but one is PCA10040 (nrf52) and the other is PCA10028 (nrf51).

    For trying your files, can I use the PCA10028 as the connectivity board and the PCA10040 as the target board?

    My Segger JLink version is "JLink_V620i".

    The Segger JLink version is OK, since both of the EVBs work fine as connectivity boards when I work with the "nRF Connect v2.3.0" running on my PC (see attached figures).

    PCA10040  as connectivity board:

    PCA10028 as connectivity board:

    In both cases I can perform successful secure DFU with many ZIP packages that I have created.

    The only problem is with the nrfutil when used as DFU controller.

  • You need to change the bottom nrfutil line in the .bat-file.

    Attached the modified .bat file. Make sure to replace the original file (It has to have the same path as the one included in the zip folder)

    nrfjprog -e --snr 682654319
    nrfjprog --program hex\s132_nrf52_5.0.0_softdevice.hex --verify --snr 682654319
    nrfjprog --program hex\buttonless.hex --verify --snr 682654319
    nrfjprog --program hex\bootloader.hex --verify --snr 682654319
    
    
    nrfutil settings generate --family NRF52 --application hex\buttonless.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 hex\settings.hex
    
    nrfjprog --program hex\settings.hex --verify --snr 682654319
    
    nrfjprog --reset --snr 682654319
    
    nrfutil pkg generate --hw-version 52 --application-version 1 --application hex\buttonless.hex --sd-req 0x9D --key-file keys\private.key dfu_packages\app_dfu_package1.zip
    nrfutil pkg generate --hw-version 52 --application-version 2 --application hex\buttonless.hex --sd-req 0x9D --key-file keys\private.key dfu_packages\app_dfu_package2.zip
    nrfutil pkg generate --hw-version 52 --application-version 3 --application hex\buttonless.hex --sd-req 0x9D --key-file keys\private.key dfu_packages\app_dfu_package3.zip
    
    nrfutil dfu ble -pkg dfu_packages\app_dfu_package2.zip -ic NRF51 -p "COM20" -n "Nordic_Buttonless" -f

     

    Try it, and let me know whether it works or not.

     

    EDIT:

    You still need to remember to change COM20 to whatever COM port that the nRF51DK is connected to.

    Also change the --snr <serial_number> with the serial number of your dfu target DK.

     

    Best regards,

    Edvin

  • Hello,

    Thank you for your help and for the files.

    I have changed all the required changes in the batch file. 

    I have downloaded the SoftDevice, buttonless, bootloader and settings to my nrf52 target board and used the nrf51 as the controller board.

    I used the command prompt window in administrator mode and it failed as usual.

    Here are the results:

    C:\Projects\Dalton\DFU_test>nrfutil dfu ble -pkg dfu_packages\app_dfu_package2.zip -ic NRF51 -p "COM8" -n "Nordic_Buttonless" -f
    Board already flashed with connectivity firmware.
      [------------------------------------]    0%
    Traceback (most recent call last):
      File "C:\Python27\Scripts\nrfutil-script.py", line 9, in <module>
        load_entry_point('nrfutil==3.5.1', 'console_scripts', 'nrfutil')()
      File "c:\python27\lib\site-packages\click\core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "c:\python27\lib\site-packages\click\core.py", line 697, in main
        rv = self.invoke(ctx)
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "c:\python27\lib\site-packages\click\core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 838, in ble
        dfu.dfu_send_images()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 90, in _dfu_send_image
        self.dfu_transport.open()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 450, in open
        self.dfu_adapter.open()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_ble.py", line 106, in open
        self.adapter.driver.open()
      File "c:\python27\lib\site-packages\wrapt\wrappers.py", line 562, in __call__
        args, kwargs)
      File "c:\python27\lib\site-packages\pc_ble_driver_py\ble_driver.py", line 126, in wrapper
        raise NordicSemiException('Failed to {}. Error code: {}'.format(wrapped.__name__, err_code))
    pc_ble_driver_py.exceptions.NordicSemiException: Failed to open. Error code: 13
    

    I really start to believe that this failure has to do with the drivers that connect Python to Windows.

    Could anyone suggest any clue in that direction?

    As usual the same combination of boards and packages worked fine with my PC nRF connect program.

    Here are some screenshots:

  • At last the issue has been solved.

    In the bottom line: the problem is due to the fact the nRF connect and nfrutil do not use the same connectivity FW.

    When ever I used the EVB with nrfutil, even with the parameter "-f ", it found a connectivity FW, but is was the connectivity FW that suites the nRF connect. Only after I start the session of nrfutil from something else (not connectivity FW), the "-f " parameter took place and the appropriate connectivity FW for nrfutil was downloaded to the EVB and afterwards nrfutil worked as expected.

    Thanks for all the support.

    C:\Projects\Dalton\DFU_test>nrfutil dfu ble -pkg Fake_app.zip -ic NRF52 -p "COM7" -n "DfuBoot_2018_08_21" -f
    Board already flashed with connectivity firmware.
      [####################################]  100%
    Device programmed.
    

  • Glad it worked out. I was not aware that it interpreted the nRF Connect firmware as "firmware already installed". Nice catch!

     

    Best regards,
    Edvin

Related