cannot convert 'NoneType' object to bytearray while flashing with nrfutil

Hi, devzone,

I'm currently trying to flash the nrf52840 dongle from a custom IMX6-Ull board where it is attached and I'm also able to communicate and run the application flashed in the dongle. 

I want to integrate the nrfutil tool into the board for firmware upgrade purposes and get the following error while running the dfu usb-serial command.

> nrfutil dfu usb-serial -pkg zephyr.zip -p /dev/ttymxc6

This is the error I'm getting as a response TypeError: cannot convert 'NoneType' object to byte array

  [------------------------------------]    0%
Traceback (most recent call last):
  File "/usr/bin/nrfutil", line 33, in <module>
    sys.exit(load_entry_point('nrfutil==6.1.7', 'console_scripts', 'nrfutil')())
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/nordicsemi/__main__.py", line 1032, in usb_serial
    do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, serial_number, False,
  File "/usr/lib/python3.8/site-packages/nordicsemi/__main__.py", line 988, in do_serial
    dfu.dfu_send_images()
  File "/usr/lib/python3.8/site-packages/nordicsemi/dfu/dfu.py", line 127, in dfu_send_images
    self._dfu_send_image(self.manifest.application)
  File "/usr/lib/python3.8/site-packages/nordicsemi/dfu/dfu.py", line 88, in _dfu_send_image
    self.dfu_transport.open()
  File "/usr/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 217, in open
    self.__get_mtu()
  File "/usr/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 366, in __get_mtu
    self.mtu = struct.unpack('<H', bytearray(response))[0]
TypeError: cannot convert 'NoneType' object to bytearray

While trying through the USB interface(ttyACM0) from the PC I'm able to flash the firmware successfully

Any suggestions? 

Thank you in advance

  • Hi,

    The Python traceback shows that the script fails because it does not receive anything in response from the DFU target after it sends the MTU Get request. But I am not sure why this would happen. Would it be possible to run the Command Line Interface (CLI) Example on your dongle and connect it to your IMX6-Ull to verify if the USB communication is working? 

    Best regards,

    Vidar

  • Hi  ,

    Thanks for the reply.

    In the dongle, I've already flashed the rcp coprocessor open-thread application program which gives a CLI for interaction called ot-ctl.

    I'm able to send commands and get the firmware version and other information from the dongle through uart

    so I think the connection is fine through /dev/ttymxc6.

  • Hi,

    Thanks When using nrfutil, please for confirming. It is good to know that the USB communication works with the OT CLI, at least. 

    Please try to use nrfutil with verbose logging in case the log may provide us some additional clues:

    nrfutil -v -v -v -v dfu usb-serial -pkg zephyr.zip -p /dev/ttymxc6

  • Hi  ,

    I've run the command with the verbose as you've said and this is the output.

    root@12046998:~# nrfutil -v -v -v -v dfu usb-serial -pkg /real/zephyr.zip -p /dev/ttymxc6
    2023-02-03 11:12:24,138 Using board at serial port: /dev/ttymxc6
    2023-02-03 11:12:24,199 Sending Application image.
    2023-02-03 11:12:57,383 Serial: Set Packet Receipt Notification 0
    2023-02-03 11:12:57,386 SLIP: --> [2, 0, 0]
    2023-02-03 11:12:58,395 SLIP: --> [7]
    Traceback (most recent call last):
      File "/usr/bin/nrfutil", line 33, in <module>
        sys.exit(load_entry_point('nrfutil==6.1.7', 'console_scripts', 'nrfutil')())
      File "/usr/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
        return self.main(*args, **kwargs)
      File "/usr/lib/python3.8/site-packages/click/core.py", line 1055, in main
        rv = self.invoke(ctx)
      File "/usr/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/lib/python3.8/site-packages/click/core.py", line 760, in invoke
        return __callback(*args, **kwargs)
      File "/usr/lib/python3.8/site-packages/nordicsemi/__main__.py", line 1032, in usb_serial
        do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, serial_number, False,
      File "/usr/lib/python3.8/site-packages/nordicsemi/__main__.py", line 990, in do_serial
        dfu.dfu_send_images()
      File "/usr/lib/python3.8/site-packages/nordicsemi/dfu/dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "/usr/lib/python3.8/site-packages/nordicsemi/dfu/dfu.py", line 88, in _dfu_send_image
        self.dfu_transport.open()
      File "/usr/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 217, in open
        self.__get_mtu()
      File "/usr/lib/python3.8/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 366, in __get_mtu
        self.mtu = struct.unpack('<H', bytearray(response))[0]
    TypeError: cannot convert 'NoneType' object to bytearray
    

  • Hi,

    The logs confirm there is no response from the dongle. Can you please double check that the dongle is in DFU mode when you are testing this? The red LED should be blinking to indicate DFU mode if you are using our nRF52840 Dongle.

Related