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

nrfutil UnicodeDecodeError

HI

    when I use nrfutil.exe to generate .zip file on win10 64bit, I got the UnicodeDecodeError. 

    And :

         Python version 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32

        nrfutil version 3.3.2.

        SDK 15.3.0

         the example is "\examples\dfu\secure_bootloader\pca10056_uart"

         I use the command is "nrfutil pkg generate --hw-version 52 --application-version 1 --application nrf52840_xxaa.hex --sd-req 0xae --key-file private.key app_dfu_package.zip"

        but I got the UnicodeDecodeError,the error message is :

        

C:\packet>nrfutil pkg generate --hw-version 52 --application-version 1 --application nrf52840_xxaa.hex --sd-req 0xae --key-file private.key app_dfu_package.zip
Traceback (most recent call last):
File "nordicsemi\__main__.py", line 871, 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 580, in generate
File "nordicsemi\dfu\package.py", line 339, in generate_package
File "nordicsemi\dfu\package.py", line 486, in normalize_firmware_to_bin
File "ntpath.py", line 85, in join
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcd in position 7: ordinal not in range(128)
Failed to execute script __main__

C:\packet>

The "packet" folder only two files : nrf52840_xxaa.hex and private.key

I refer to the Nordic blog :https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader.

How should I solve this problem?

  • I changed the version of nrfutil into 5.2.0(Everything else is the same as before)

    The error message is:

    Traceback (most recent call last):
    File "nordicsemi\__main__.py", line 1464, in <module>
    File "click\core.py", line 764, in __call__
    File "click\core.py", line 717, in main
    File "click\core.py", line 1137, in invoke
    File "click\core.py", line 1137, in invoke
    File "click\core.py", line 956, in invoke
    File "click\core.py", line 555, in invoke
    File "nordicsemi\__main__.py", line 867, in generate
    File "nordicsemi\dfu\package.py", line 407, in generate_package
    File "nordicsemi\dfu\package.py", line 602, in normalize_firmware_to_bin
    File "ntpath.py", line 85, in join
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xcd in position 7: ordinal not in range(128)
    [15032] Failed to execute script __main__

  • Did you install nrfutil using pip or are you using the nrfutil.exe from https://github.com/NordicSemiconductor/pc-nrfutil/releases?

  • I have solved the problem.

    This is the problem with python2.7,it default encoding is ASCII,Change the encoding mode to GBK.

    But I ran into another problem when I was using the DFU USB upgrade.

    I use the command is "nrfutil dfu usb-serial -pkg .\app_dfu_package.zip -p COM8",

    It return "NordicSemiException: Extended Error 0x07: The array of supported SoftDevices for the update does not contain the FWID of the current SoftDevice". But i don`t use softdevice,My application only uses a Master Boot Record (MBR).

    Can you help me how should I solve this problem?  

  • Which --sd-req did you set when you generated the app_dfu_package.zip using nrfutil? Try using 0xFFFE.

1 2 3