nrfutil dfu serial shows: TypeError: 'NoneType' object is not iterable

Hi,

i am using nrfutil 6.1.0 in windows (i've installed it typing pip install nrfutil), i am using python 3.6.5 and when trying to serial dfu it shows the following error:

C:\Users\mtapia\Desktop\tools>nrfutil dfu usb-serial -pkg aquana_nrf52840_s140.zip -p COM9 -b 115200
[------------------------------------] 0%
Traceback (most recent call last):
File "C:\Users\mtapia\AppData\Local\Programs\Python\Python36-32\Scripts\nrfutil-script.py", line 11, in <module>
load_entry_point('nrfutil==6.1.0', 'console_scripts', 'nrfutil')()
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1053, in main
rv = self.invoke(ctx)
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\__main__.py", line 1015, in usb_serial
timeout)
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\__main__.py", line 970, in do_serial
dfu.dfu_send_images()
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu.py", line 127, in dfu_send_images
self._dfu_send_image(self.manifest.application)
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu.py", line 88, in _dfu_send_image
self.dfu_transport.open()
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 217, in open
self.__get_mtu()
File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 366, in __get_mtu
self.mtu = struct.unpack('<H', bytearray(response))[0]
TypeError: 'NoneType' object is not iterable

why can cause this? i have taken a look to some of the cases but there is no solution for that.

Thanks in advance for your support.

Manuel

Parents
  • Hello,

    Are you sure that the serial port that you are trying to use (COM9) is not used by anything else on the pc when you call the nrfutil command? Do you use the COM port for e.g. logging, and have a UART terminal open or something?

    One way to quickly disconnect the COM port is to power cycle the DK. Perhaps you can try that.

    If that doesn't work, how did you generate the DFU image that you are trying to use? Can you show me what command you used? Can you upload aquana_nrf52840_s140.zip here? (or another packet that gives the same issue, in case you don't want to share that specific image)

    Best regards,
    Edvin

  • the image is OK, actually i can serial DFU the image in Linux but not in Windows, the image is attached here, what i am doing is i have the COM9 used at the first time as debugging (using tera term) then after applying a CLI command that i created to set the device in dfu mode, once the device is in dfu mode, i am closing the tera term to have the COM9 not used and then using this command to serial dfu:

    nrfutil dfu usb-serial -pkg aquana_nrf52840_s140.zip -p COM9 -b 115200

    aquana_nrf52840_s140.zip

    the same steps and the same image i am following in Linux and it works OK.

    actually i did a test leaving the COM9 opened and the log is different you can see it in the attached file:

    C:\Users\mtapia\Desktop\pc-nrfutil-master>nrfutil dfu usb-serial -pkg aquana_nrf52840_s140.zip -p COM9 -b 115200
      [------------------------------------]    0%
    Traceback (most recent call last):
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 199, in open
        baudrate=self.baud_rate, rtscts=self.flow_control, timeout=self.DEFAULT_SERIAL_PORT_TIMEOUT)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\serial\serialwin32.py", line 33, in __init__
        super(Serial, self).__init__(*args, **kwargs)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\serial\serialutil.py", line 244, in __init__
        self.open()
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\serial\serialwin32.py", line 64, in open
        raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
    serial.serialutil.SerialException: could not open port 'COM9': PermissionError(13, 'Access is denied.', None, 5)
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:\Users\mtapia\AppData\Local\Programs\Python\Python36-32\Scripts\nrfutil-script.py", line 11, in <module>
        load_entry_point('nrfutil==6.1.0', 'console_scripts', 'nrfutil')()
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1128, in __call__
        return self.main(*args, **kwargs)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1053, in main
        rv = self.invoke(ctx)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1659, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1659, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1395, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 754, in invoke
        return __callback(*args, **kwargs)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\__main__.py", line 1015, in usb_serial
        timeout)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\__main__.py", line 970, in do_serial
        dfu.dfu_send_images()
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu.py", line 88, in _dfu_send_image
        self.dfu_transport.open()
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 203, in open
        ". Reason: {1}".format(self.com_port, e.strerror))
    pc_ble_driver_py.exceptions.NordicSemiException: Serial port could not be opened on COM9. Reason: None

    so i am not sure what is wrong because the same steps in linux works OK.

Reply
  • the image is OK, actually i can serial DFU the image in Linux but not in Windows, the image is attached here, what i am doing is i have the COM9 used at the first time as debugging (using tera term) then after applying a CLI command that i created to set the device in dfu mode, once the device is in dfu mode, i am closing the tera term to have the COM9 not used and then using this command to serial dfu:

    nrfutil dfu usb-serial -pkg aquana_nrf52840_s140.zip -p COM9 -b 115200

    aquana_nrf52840_s140.zip

    the same steps and the same image i am following in Linux and it works OK.

    actually i did a test leaving the COM9 opened and the log is different you can see it in the attached file:

    C:\Users\mtapia\Desktop\pc-nrfutil-master>nrfutil dfu usb-serial -pkg aquana_nrf52840_s140.zip -p COM9 -b 115200
      [------------------------------------]    0%
    Traceback (most recent call last):
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 199, in open
        baudrate=self.baud_rate, rtscts=self.flow_control, timeout=self.DEFAULT_SERIAL_PORT_TIMEOUT)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\serial\serialwin32.py", line 33, in __init__
        super(Serial, self).__init__(*args, **kwargs)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\serial\serialutil.py", line 244, in __init__
        self.open()
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\serial\serialwin32.py", line 64, in open
        raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
    serial.serialutil.SerialException: could not open port 'COM9': PermissionError(13, 'Access is denied.', None, 5)
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:\Users\mtapia\AppData\Local\Programs\Python\Python36-32\Scripts\nrfutil-script.py", line 11, in <module>
        load_entry_point('nrfutil==6.1.0', 'console_scripts', 'nrfutil')()
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1128, in __call__
        return self.main(*args, **kwargs)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1053, in main
        rv = self.invoke(ctx)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1659, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1659, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 1395, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\click\core.py", line 754, in invoke
        return __callback(*args, **kwargs)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\__main__.py", line 1015, in usb_serial
        timeout)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\__main__.py", line 970, in do_serial
        dfu.dfu_send_images()
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu.py", line 88, in _dfu_send_image
        self.dfu_transport.open()
      File "c:\users\mtapia\appdata\local\programs\python\python36-32\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 203, in open
        ". Reason: {1}".format(self.com_port, e.strerror))
    pc_ble_driver_py.exceptions.NordicSemiException: Serial port could not be opened on COM9. Reason: None

    so i am not sure what is wrong because the same steps in linux works OK.

Children
Related