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

SD + BL + APP dfu serial update failed

Hi, I try to update a nRF52832 with SDK 14.2.0 to SDK 15.3. I created a package with SD + BL + APP with the following command:

nrfutil pkg generate --hw-version 52 --key-file private.key \
        --application-version 2 --application application.hex \
        --sd-req 0x9D,0x98,0xB7 --softdevice softdevice.hex --sd-id 0xB7 \
        --bootloader bootloader.hex --bootloader-version 2 \
        app_dfu_package.zip

I'm using nrfutil (v5.1.0) to download the update via serial (nrfutil dfu serial -pkg ... ). Now the first part (SD + BL) succeeded, but somehow the second part, updating application, failed.
Nrfutil gives the following error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nordicsemi/__main__.py", line 89, in do_main
    do_serial(package = args.package[0], port = args.port[0], dfuStart = args.dfuStart)
  File "/usr/lib/python2.7/site-packages/nordicsemi/__main__.py", line 69, in do_serial
    dfu.dfu_send_images()
  File "/usr/lib/python2.7/site-packages/nordicsemi/dfu/dfu.py", line 120, in dfu_send_images
    self._dfu_send_image(self.manifest.application)
  File "/usr/lib/python2.7/site-packages/nordicsemi/dfu/dfu.py", line 81, in _dfu_send_image
    self.dfu_transport.open()
  File "/usr/lib/python2.7/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 204, in open
    self.__get_mtu()
  File "/usr/lib/python2.7/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 306, in __get_mtu
    self.mtu = struct.unpack('<H', bytearray(response))[0]
TypeError: 'NoneType' object is not iterable

After updating the Bootloader and Softdevice, will still the old bootloader handle the application update or is already the new bootloader started? I read some threads about a problem with the softdevice size, but this should be fixed in SDK v15.3, correct? I also tried to do a package with SD + BL + APP from SDK 14.2.0 and the error is the same...

Parents
  • Hi,

    Which platform do you run nrfutil on? Linux? Do you get the same behavior with nrfutil 5.2, and is it the same if you use Python 2 or Python 3 (you can easily test both if using pip2 or pip3 if you have that installed)? Is this relevant?

    After updating the Bootloader and Softdevice, will still the old bootloader handle the application update or is already the new bootloader started?

    Yes. When you have a combined BL + SD + app update, the BL + SD is updated first, and after resetting the MBR activates/copies the BL + SD in place. This means that the new bootloader is used to update the application. 

  • Hi Einar,

    I'm run nrfutil on linux with python 2. I now updated to nrfutil 6.0.0a0, but with this version I get error while start:

    Traceback (most recent call last):
      File "/usr/local/bin/nrfutil", line 11, in <module>
        load_entry_point('nrfutil==6.0.0a0', 'console_scripts', 'nrfutil')()
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 489, in load_entry_point
        return get_distribution(dist).load_entry_point(group, name)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
        return ep.load()
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2411, in load
        return self.resolve()
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2417, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
      File "/usr/local/lib/python3.7/dist-packages/nrfutil_dfu_serial-3.4.0-py3.7.egg/nordicsemi/__main__.py", line 42
        print os.getcwd()
               ^
    SyntaxError: invalid syntax

  • Hi,

    The error message "SyntaxError: invalid syntax" is because in this case, you are using Python3, but the python code you are executing is for python 2 (print being used as a keyword, not a function). Please check your versions and make sure they are compatible. I highly recommend using pip to install nrfutil if you have not done so before since that will ensure that dependencies are correct.

  • you're right, I mixed up the installations... I now using the nrfutil 5.2.0 from pip3 (with python 3.7). But now I have the next python error:

    sudo nrfutil -v -v -v dfu serial -b 115200 -p /dev/ttyUSB0 -pkg app_dfu_package.zip
    2019-10-18 17:32:00,363 Using board at serial port: /dev/ttyUSB0
    2019-10-18 17:32:00,364 Sending Application image.
    2019-10-18 17:32:03,888 Serial: Set Packet Receipt Notification 0
    Traceback (most recent call last):
      File "/usr/local/bin/nrfutil", line 8, in <module>
        sys.exit(cli())
      File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 764, in __call__
        return self.main(*args, **kwargs)
      File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main
        rv = self.invoke(ctx)
      File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 956, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 555, in invoke
        return callback(*args, **kwargs)
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/__main__.py", line 1042, in serial
        timeout)
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/__main__.py", line 958, in do_serial
        dfu.dfu_send_images()
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu.py", line 129, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu.py", line 90, in _dfu_send_image
        self.dfu_transport.open()
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu_transport_serial.py", line 216, in open
        self.__set_prn()
      File "/usr/local/lib/python3.7/dist-packages/nordicsemi/dfu/dfu_transport_serial.py", line 360, in __set_prn
        + map(ord, struct.pack('<H', self.prn)))
    TypeError: can only concatenate list (not "map") to list

    Do I still have not a python3 version of nrfutil? I installed nrfutil with pip3 install nrfutil, so there is not so much to do wrong...

  • To be honest, I don't know what is going on, but the error "TypeError: can only concatenate list (not "map") to list" indicates python version mismatch. Can you remove anything nordic related and make sure you erase everything within /usr/local/lib/python3.7/dist-packages/nordicsemi/ and anywhere else you could have something related and try installing again (just an idea, may not be sensible)?

Reply
  • To be honest, I don't know what is going on, but the error "TypeError: can only concatenate list (not "map") to list" indicates python version mismatch. Can you remove anything nordic related and make sure you erase everything within /usr/local/lib/python3.7/dist-packages/nordicsemi/ and anywhere else you could have something related and try installing again (just an idea, may not be sensible)?

Children
  • I now completly removed all files and reinstall nrfutil and it now run with python 3.7...
    But now I again have the same issue as with the v 5.1.0 of nrfutil:

    sudo nrfutil -v -v -v dfu serial -b 115200 -p /dev/ttyUSB0 -pkg app_dfu_package.zip
    2019-10-21 16:46:41,364 Using board at serial port: /dev/ttyUSB0
    2019-10-21 16:46:41,365 Sending SoftDevice+Bootloader image.
    2019-10-21 16:46:44,379 Serial: Set Packet Receipt Notification 0
    2019-10-21 16:46:44,411 Sending init packet...
    2019-10-21 16:46:44,411 Serial: Selecting Object: type:1
    2019-10-21 16:46:44,427 Serial: Object selected:  max_size:256 offset:0 crc:0
    2019-10-21 16:46:44,443 Serial: Streaming Data: len:154 offset:0 crc:0x00000000
    2019-10-21 16:46:44,635 Sending firmware file...
    2019-10-21 16:46:44,636 Serial: Selecting Object: type:2
    2019-10-21 16:46:44,651 Serial: Object selected:  max_size:4096 offset:0 crc:0
    2019-10-21 16:46:44,667 Serial: Streaming Data: len:4096 offset:0 crc:0x00000000
    2019-10-21 16:46:45,152 Serial: Streaming Data: len:4096 offset:4096 crc:0x086FE1F0
    ......
    2019-10-21 16:47:04,451 Serial: Streaming Data: len:596 offset:167936 crc:0x9E5B00C2
    2019-10-21 16:47:04,819 Image sent in 20.407888889312744s
    2019-10-21 16:47:04,820 Sending Application image.
    2019-10-21 16:47:08,824 Serial: No ping response
    2019-10-21 16:47:09,826 Serial: No ping response
    2019-10-21 16:47:10,827 Serial: No ping response
    2019-10-21 16:47:11,829 Serial: No ping response
    

    I noticed that the device after download the first image, the LED 3 shortly ligths up (1-2s).  How can I check, that the update of bootloader + softdevice is successfully? If I enable log, the image is too big (insufficient ressources)...

    Edit:
    I today checked, if I flash the device with programmer to SDK 15.3 and then try update with nrftool, every thing was successfully. So from my point of view something went wrong while exchange the bootloader. Or could it be that the softdevice or bootloader is at wrong place? If I use the wrong sd-req or sd-id, would I get an error from nrfutil?

  • Hi,

    The printout now indicates that things are working from the nrfutil perspective, though there is an error with the image transfer.

    The best way to debug the bootloader is using logging, but as you write you will get an error by enabling logging out of the box. Therefore, the SDK has a separate set of bootloader projects suffixes with _debug, which has RTT logging enabled, and a lower start address to make it fit. Using this when facing bootloader issues is highly recommended, as it most of the time helps to narrow down the issue significantly. I suggest you do this first.

    The SoftDevice always needs to start at address 0. Your application should always start immediately after the bootloader. Regarding the SoftDevice ID, this is checked based on what you enter when you make the DFU image. So if you enter the wrong ID's (or include ID's that should not have been included), it will not prevent an incompatible update. The idea here is that it should protect the end customer since you test the upgrade image before you ship it, but you need to have control. If the bootloader is built to use the SoftDevice, it needs to be a compatible version.

    Therefore, a bootloader upgrade should always be accompanied by a new SoftDevice if the versions change. For the application, it is the same, but you do not risk bricking the device if you have a way of putting it in DFU mode, so the requirement is relaxed. But if you set the sd-req wrong, the bootloader may accept the application even though it has an incompatible SoftDevice, and the application will start and crash. Can you list all versions you upgrade from and to?

Related