Error when trying to use nrfutil pkg generate

while trying to package my hex file from zephyr  and I have gotten the following error 

nrfutil pkg generate --hw-version 52 --sd-req=0x00 \                                        

        --application build/zephyr/zephyr.hex \

        --application-version 1 blinky.zip

|===============================================================|

|##      ##    ###    ########  ##    ## #### ##    ##  ######  |

|##  ##  ##   ## ##   ##     ## ###   ##  ##  ###   ## ##    ## |

|##  ##  ##  ##   ##  ##     ## ####  ##  ##  ####  ## ##       |

|##  ##  ## ##     ## ########  ## ## ##  ##  ## ## ## ##   ####|

|##  ##  ## ######### ##   ##   ##  ####  ##  ##  #### ##    ## |

|##  ##  ## ##     ## ##    ##  ##   ###  ##  ##   ### ##    ## |

| ###  ###  ##     ## ##     ## ##    ## #### ##    ##  ######  |

|===============================================================|

|You are not providing a signature key, which means the DFU     |

|files will not be signed, and are vulnerable to tampering.     |

|This is only compatible with a signature-less bootloader and is|

|not suitable for production environments.                      |

|===============================================================|

Traceback (most recent call last):

  File "/opt/homebrew/bin/nrfutil", line 8, in <module>

    sys.exit(cli())

             ^^^^^

  File "/opt/homebrew/lib/python3.12/site-packages/click/core.py", line 829, in __call__

    return self.main(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/homebrew/lib/python3.12/site-packages/click/core.py", line 782, in main

    rv = self.invoke(ctx)

         ^^^^^^^^^^^^^^^^

  File "/opt/homebrew/lib/python3.12/site-packages/click/core.py", line 1259, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/homebrew/lib/python3.12/site-packages/click/core.py", line 1259, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/homebrew/lib/python3.12/site-packages/click/core.py", line 1066, in invoke

    return ctx.invoke(self.callback, **ctx.params)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/homebrew/lib/python3.12/site-packages/click/core.py", line 610, in invoke

    return callback(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/homebrew/lib/python3.12/site-packages/nordicsemi/__main__.py", line 867, in generate

    package.generate_package(zipfile_path)

  File "/opt/homebrew/lib/python3.12/site-packages/nordicsemi/dfu/package.py", line 403, in generate_package

    for key, firmware_data in self.firmwares_data.iteritems():

                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: 'dict' object has no attribute 'iteritems'

  • Hello,

    The nrfutil pkg generate is a command used in the "old"/"Legacy" nRF5 SDK, and not in Zephyr. Are you intentionally using this with a Zephyr/NCS application? It will not work out of the box, although I do believe some customers have made it work. 

    Perhaps what you are looking for is the MCUBOOT bootloader in NCS? I believe the Nordic Developer Academy course nRF Connect SDK Intermediate covers this quite good.

    If you are intentionally trying to use the nRF5 SDK bootloader? If so, I believe I need some more details on what you are trying to do.

    Best regards,

    Edvin

  • Actually,
    I have been following the Zephyr Documentation,(https://docs.zephyrproject.org/latest/boards/nordic/nrf52840dongle/doc/index.html)
    where it written that the board is factory-programmed with Nordic’s bootloader from Nordic’s nRF5 SDK, such that we would need to use nrfutil,
    if there are other tools which would help other than MCUBOOT, nrfutil to help in flashing, could you suggest that

    The problem with MCUBOOT is the need of manual intervention, I had seen the nrf5 sdk has a way to do buttonless DFU, are there such way to do in nrfconnect SDK, if yes, could you lead to towards those resources and samples.

  • Ok, I understand.

    the nRF52840 dongle is pre-programmed with a serial bootloader, because it doesn't have a bootloader.

    However, to update the FW on the dongle, the intention is to use nRF Connect for Desktop - Programmer app. The dongle, however does require you to interfere with the dongle to put it back in DFU mode. Both the nRF5 SDK bootloader and the MCUBOOT bootloader are capable of doing this without interfering with the device, but not the particular bootloader that is preprogrammed into that dongle. If you want to change the pre-programmed bootloader on the dongle, you still need an eternal programmer to do so.

    Either way, the dongle is not intended for app development. It is meant as a companion tool. For app development, I suggest that you get hold of a proper development kit of some sort (nRF52840 DK). This has a built in/on board debugger, which makes development much easier. And if you intend to use the nRF Connect SDK (NCS, based on Zephyr), then you should use the mcuboot bootloader.

    You can however, build a sample in NCS, and program it to the dongle using nRF Connect for Desktop -> programmer. But that will be over serial, and you need to put the dongle in DFU mode by pressing the reset button (not the big button, but the small one next to it, going sideways).

    Best regards,

    Edvin

  • Hello Edwin,
    Thank you for your response,
    but the problems is we require a small form factor + only BLE and USB which led us to the dongle,
    As of the moment, the firmware is no big of problem,

    The problem is with the nRF Connect, as is that it's interaction based, we require a CLI, no interaction based flashing solution for our deployment. Could you give any methods go forward with this?

    And related to the question of MCUBOOT, I remember seeing buttonless DFU using MCUBOOT on the nRF5 SDK,
    are the same available in the NCS?

  • There is no such thing as MCUBOOT in the nRF5 SDK. The MCUBOOT bootloader was introduced with NCS. 

    Indeed, there is something called buttonless DFU in the nRF5 SDK. This is a BLE service that tells the nRF to enter DFU mode. In fact, you can use any kind of event that you can grab onto from the application to enter DFU mode. It can be a buttonpress, a particular BLE event (which is the case in the buttonless DFU example), it can be a particular UART or USB message.

    But please note that this is not the bootloader that is pre-programmed onto the nRF52840 dongle. If you want this kind of bootloader, you need to use an external programmer to re-program the nRF52dongle. Please see this blog post. Particularly notice the section on the REGOUT0 register.

    So what kind of bootloader do you want? Do you want to be able to program it over BLE? Or via USB only?

    BR,
    Edvin

Related