Trouble flashing my nitrokey 3c NFC

I am having trouble flashing my Nitrokey 3c NFC.

I have the nitrokey udev rules installed

My nitrokey initially shows up as /dev/hidraw2

I can verify they are working because i can see the special user facl with getfacl /dev/hidraw2

After attempting to flash, /dev/hidraw2 disappears and i see a /dev/hidraw3, also with proper ACLs

dmesg output shows

[ 1830.608158] usb usb4-port2: attempt power cycle
[ 1839.062546] usb usb4-port2: unable to enumerate USB device
[ 1853.065735] usb 1-3: USB disconnect, device number 14
[ 1853.315860] usb 1-3: new high-speed USB device number 15 using xhci_hcd
[ 1853.708741] usb 1-3: New USB device found, idVendor=20a0, idProduct=42dd, bcdDevice= 3.00
[ 1853.708753] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1853.708757] usb 1-3: Product: USB COMPOSITE DEVICE
[ 1853.708760] usb 1-3: Manufacturer: NXP SEMICONDUCTOR INC.
[ 1853.712013] hid-generic 0003:20A0:42DD.000E: hiddev96,hidraw3: USB HID v1.00 Device [NXP SEMICONDUCTOR INC. USB COMPOSITE DEVICE] on usb-0000:00:14.0-3/input0

nitropy log follows

451        INFO pynitrokey.cli Timestamp: 2024-04-17 20:02:08.837469
451        INFO pynitrokey.cli OS: uname_result(system='Linux', node='garden', release='6.6.18', version='#1-NixOS SMP PREEMPT_DYNAMIC Fri Feb 23 08:25:28 UTC 2024', machine='x86_64')
451        INFO pynitrokey.cli Python version: 3.11.8
451        INFO pynitrokey.cli Cli arguments: ['nk3', 'update']
453        INFO pynitrokey.cli pynitrokey version: 0.4.46
453        INFO pynitrokey.cli cryptography version: 41.0.7
454        INFO pynitrokey.cli ecdsa version: 0.18.0
454        INFO pynitrokey.cli fido2 version: 1.1.3
455        INFO pynitrokey.cli pyusb version: 1.2.1
456        INFO pynitrokey.cli spsdk version: 2.1.1
458        INFO  libusbsio Loading SIO library: /nix/store/59fsvjycqsxjhcwqvvx5ifq62apyw73q-libusbsio-2.1.11/lib/libusbsio.so
460        INFO  libusbsio HID enumeration[18689504]: initialized
460       DEBUG  libusbsio HID enumeration[18689504]: device #0: Nitrokey 3
460        INFO  libusbsio HID enumeration[18689504]: finished, total 1 devices
463       DEBUG fido2.hid.linux Failed opening device /dev/hidraw0
Traceback (most recent call last):
  File "/nix/store/836fq7kbn0zhjwzf9i89wbwhzs3l0xh7-python3.11-fido2-1.1.3/lib/python3.11/site-packages/fido2/hid/linux.py", line 98, in list_descriptors
    devices.append(get_descriptor(hidraw))
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/836fq7kbn0zhjwzf9i89wbwhzs3l0xh7-python3.11-fido2-1.1.3/lib/python3.11/site-packages/fido2/hid/linux.py", line 55, in get_descriptor
    with open(path, "rb") as f:
         ^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/dev/hidraw0'
463       DEBUG fido2.hid.linux Failed opening device /dev/hidraw1
Traceback (most recent call last):
  File "/nix/store/836fq7kbn0zhjwzf9i89wbwhzs3l0xh7-python3.11-fido2-1.1.3/lib/python3.11/site-packages/fido2/hid/linux.py", line 98, in list_descriptors
    devices.append(get_descriptor(hidraw))
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/836fq7kbn0zhjwzf9i89wbwhzs3l0xh7-python3.11-fido2-1.1.3/lib/python3.11/site-packages/fido2/hid/linux.py", line 55, in get_descriptor
    with open(path, "rb") as f:
         ^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/dev/hidraw1'
593        INFO pynitrokey.nk3.updates Firmware version before update: v1.2.0
597       DEBUG urllib3.connectionpool Starting new HTTPS connection (1): api.github.com:443
6466      DEBUG urllib3.connectionpool https://api.github.com:443 "GET /repos/Nitrokey/nitrokey-3-firmware/releases/latest HTTP/1.1" 200 None
6469       INFO pynitrokey.nk3.updates Latest firmware version: v1.6.0
6469       INFO pynitrokey.nk3.updates Current firmware version: v1.2.0
6469       INFO pynitrokey.nk3.updates Updated firmware version: v1.6.0
7844       INFO pynitrokey.nk3.updates Trying to download firmware update from URL: https://github.com/Nitrokey/nitrokey-3-firmware/releases/download/v1.6.0/firmware-nk3-v1.6.0.zip
7847      DEBUG urllib3.connectionpool Starting new HTTPS connection (1): github.com:443
8303      DEBUG urllib3.connectionpool https://github.com:443 "GET /Nitrokey/nitrokey-3-firmware/releases/download/v1.6.0/firmware-nk3-v1.6.0.zip HTTP/1.1" 302 0
8306      DEBUG urllib3.connectionpool Starting new HTTPS connection (1): objects.githubusercontent.com:443
8786      DEBUG urllib3.connectionpool https://objects.githubusercontent.com:443 "GET /github-production-release-asset-2e65be/366410832/193535e2-672a-4450-ba93-8ffd96c04759?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240418T010216Z&X-Amz-Expires=300&X-Amz-Signature=4710fff68ce84575bb535e99c9601688aee63e7b77bbd39e5b9b894daa023b4a&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=366410832&response-content-disposition=attachment%3B%20filename%3Dfirmware-nk3-v1.6.0.zip&response-content-type=application%2Foctet-stream HTTP/1.1" 200 909211
9368      DEBUG       root print: Current firmware version:  v1.2.0
9369      DEBUG       root print: Updated firmware version:  v1.6.0
9369      DEBUG       root print: Please do not remove the Nitrokey 3 or insert any other Nitrokey 3 devices during the update. Doing so may damage the Nitrokey 3.
10732     DEBUG       root print: Please press the touch button to reboot the device into bootloader mode ...
21730     DEBUG pynitrokey.trussed.device./dev/hidraw2 ignoring OSError after reboot
Traceback (most recent call last):
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/admin_app.py", line 197, in reboot
    self._call(AdminCommand.UPDATE)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/admin_app.py", line 168, in _call
    return self.device._call(
           ^^^^^^^^^^^^^^^^^^
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/device.py", line 80, in _call
    response = self.device.call(command, data=data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/836fq7kbn0zhjwzf9i89wbwhzs3l0xh7-python3.11-fido2-1.1.3/lib/python3.11/site-packages/fido2/hid/__init__.py", line 191, in call
    recv = self._connection.read_packet()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/836fq7kbn0zhjwzf9i89wbwhzs3l0xh7-python3.11-fido2-1.1.3/lib/python3.11/site-packages/fido2/hid/base.py", line 80, in read_packet
    return os.read(self.handle, self.descriptor.report_size_in)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 5] Input/output error
22733     DEBUG pynitrokey.nk3.updates Trying to connect to bootloader (try 1 of 3)
22733     DEBUG pynitrokey.cli.trussed Searching Nitrokey 3 bootloader device (try 1 of 30)
22737      INFO  libusbsio HID enumeration[24705744]: initialized
22737     DEBUG  libusbsio HID enumeration[24705744]: device #0: MCU HID GENERIC DEVICE
22737      INFO  libusbsio HID enumeration[24705744]: finished, total 1 devices
22740     DEBUG fido2.hid.linux Failed opening device /dev/hidraw3
Traceback (most recent call last):
  File "/nix/store/836fq7kbn0zhjwzf9i89wbwhzs3l0xh7-python3.11-fido2-1.1.3/lib/python3.11/site-packages/fido2/hid/linux.py", line 98, in list_descriptors
    devices.append(get_descriptor(hidraw))
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/836fq7kbn0zhjwzf9i89wbwhzs3l0xh7-python3.11-fido2-1.1.3/lib/python3.11/site-packages/fido2/hid/linux.py", line 55, in get_descriptor
    with open(path, "rb") as f:
         ^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/dev/hidraw3'
22740      INFO spsdk.mboot.mcuboot Connect: identifier='usb', device=MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn=''
22740     DEBUG spsdk.utils.interfaces.device.usb_device Opening the Interface: MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn=''
22740      INFO libusbsio.hidapi.dev Opening HID device at path: 'b'/dev/hidraw3''
22740     ERROR libusbsio.hidapi.dev HID device 'b'/dev/hidraw3'' opening failed.
23697     DEBUG pynitrokey.nk3.updates Starting firmware update
23697      INFO spsdk.mboot.mcuboot CMD: ReceiveSBfile(data_length=461136)
23697      INFO spsdk.mboot.mcuboot CMD: GetProperty(MaxPacketSize, index=0)
23698     DEBUG spsdk.mboot.mcuboot TX-PACKET: Tag=GetProperty, Flags=0x00, P[0]=0x0000000B, P[1]=0x00000000
23698     DEBUG spsdk.mboot.protocol.bulk_protocol OUT[16]: 01, 00, 0C, 00, 07, 00, 00, 02, 0B, 00, 00, 00, 00, 00, 00, 00
23698      INFO spsdk.mboot.mcuboot Closing: identifier='usb', device=MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn=''
23698     DEBUG spsdk.utils.interfaces.device.usb_device Closing the Interface: MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn=''
23698    WARNING pynitrokey.cli An unhandled exception occurred
Traceback (most recent call last):
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/utils/interfaces/device/usb_device.py", line 133, in write
    bytes_written = self._device.Write(data, timeout_ms=timeout)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/y3ipy64jv55za9rcgql4vbv1jq3vv3wa-python3.11-libusbsio-2.1.11/lib/python3.11/site-packages/libusbsio/libusbsio.py", line 1357, in wrapper
    self._check_device_open()
  File "/nix/store/y3ipy64jv55za9rcgql4vbv1jq3vv3wa-python3.11-libusbsio-2.1.11/lib/python3.11/site-packages/libusbsio/libusbsio.py", line 1342, in _check_device_open
    raise LIBUSBSIO_Exception("HID DEVICE is not open.")
libusbsio.libusbsio.LIBUSBSIO_Exception: LIBUSBSIO: HID DEVICE is not open.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 367, in _perform_update
    device.update(image, callback=callback)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/bootloader/lpc55.py", line 97, in update
    success = self.device.receive_sb_file(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 676, in receive_sb_file
    data_chunks = self._split_data(data=data)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 285, in _split_data
    max_packet_size = self._get_max_packet_size()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 267, in _get_max_packet_size
    packet_size_property = self.get_property(prop_tag=PropertyTag.MAX_PACKET_SIZE)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 640, in get_property
    cmd_response = self._process_cmd(cmd_packet)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 120, in _process_cmd
    self._interface.write_command(cmd_packet)
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/protocol/bulk_protocol.py", line 77, in write_command
    self.device.write(frame)
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/utils/interfaces/device/usb_device.py", line 135, in write
    raise SPSDKConnectionError(str(e)) from e
spsdk.exceptions.SPSDKConnectionError: SPSDK: LIBUSBSIO: HID DEVICE is not open.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 345, in _get_bootloader
    yield bootloader
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 214, in update
    self._perform_update(bootloader, container)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 369, in _perform_update
    raise self.ui.error("Failed to perform firmware update", e)
pynitrokey.cli.exceptions.CliException: Failed to perform firmware update
SPSDK: LIBUSBSIO: HID DEVICE is not open.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/utils/interfaces/device/usb_device.py", line 96, in close
    self._device.Close()
  File "/nix/store/y3ipy64jv55za9rcgql4vbv1jq3vv3wa-python3.11-libusbsio-2.1.11/lib/python3.11/site-packages/libusbsio/libusbsio.py", line 1357, in wrapper
    self._check_device_open()
  File "/nix/store/y3ipy64jv55za9rcgql4vbv1jq3vv3wa-python3.11-libusbsio-2.1.11/lib/python3.11/site-packages/libusbsio/libusbsio.py", line 1342, in _check_device_open
    raise LIBUSBSIO_Exception("HID DEVICE is not open.")
libusbsio.libusbsio.LIBUSBSIO_Exception: LIBUSBSIO: HID DEVICE is not open.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/cli/__init__.py", line 136, in main
    nitropy()
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/decorators.py", line 45, in new_func
    return f(get_current_context().obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/cli/nk3/__init__.py", line 119, in update
    exec_update(ctx, image, version, ignore_pynitrokey_version)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/cli/nk3/update.py", line 140, in update
    return updater.update(device, image, version, ignore_pynitrokey_version)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 192, in update
    with self._get_bootloader(device) as bootloader:
  File "/nix/store/gd3shnza1i50zn8zs04fa729ribr88m9-python3-3.11.8/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 342, in _get_bootloader
    with self.await_bootloader() as bootloader:
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/base.py", line 29, in __exit__
    self.close()
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/bootloader/lpc55.py", line 67, in close
    self.device.close()
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 297, in close
    self._interface.close()
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/protocol/bulk_protocol.py", line 43, in close
    self.device.close()
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/utils/interfaces/device/usb_device.py", line 99, in close
    raise SPSDKConnectionError(f"Unable to close device '{str(self)}'") from error
spsdk.exceptions.SPSDKConnectionError: SPSDK: Unable to close device 'MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn='''
23701     DEBUG       root print: Critical error:
23702     DEBUG       root print: An unhandled exception occurred
23702     ERROR       root SPSDK: Unable to close device 'MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn='''
Traceback (most recent call last):
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/utils/interfaces/device/usb_device.py", line 133, in write
    bytes_written = self._device.Write(data, timeout_ms=timeout)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/y3ipy64jv55za9rcgql4vbv1jq3vv3wa-python3.11-libusbsio-2.1.11/lib/python3.11/site-packages/libusbsio/libusbsio.py", line 1357, in wrapper
    self._check_device_open()
  File "/nix/store/y3ipy64jv55za9rcgql4vbv1jq3vv3wa-python3.11-libusbsio-2.1.11/lib/python3.11/site-packages/libusbsio/libusbsio.py", line 1342, in _check_device_open
    raise LIBUSBSIO_Exception("HID DEVICE is not open.")
libusbsio.libusbsio.LIBUSBSIO_Exception: LIBUSBSIO: HID DEVICE is not open.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 367, in _perform_update
    device.update(image, callback=callback)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/bootloader/lpc55.py", line 97, in update
    success = self.device.receive_sb_file(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 676, in receive_sb_file
    data_chunks = self._split_data(data=data)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 285, in _split_data
    max_packet_size = self._get_max_packet_size()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 267, in _get_max_packet_size
    packet_size_property = self.get_property(prop_tag=PropertyTag.MAX_PACKET_SIZE)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 640, in get_property
    cmd_response = self._process_cmd(cmd_packet)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 120, in _process_cmd
    self._interface.write_command(cmd_packet)
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/protocol/bulk_protocol.py", line 77, in write_command
    self.device.write(frame)
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/utils/interfaces/device/usb_device.py", line 135, in write
    raise SPSDKConnectionError(str(e)) from e
spsdk.exceptions.SPSDKConnectionError: SPSDK: LIBUSBSIO: HID DEVICE is not open.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 345, in _get_bootloader
    yield bootloader
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 214, in update
    self._perform_update(bootloader, container)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 369, in _perform_update
    raise self.ui.error("Failed to perform firmware update", e)
pynitrokey.cli.exceptions.CliException: Failed to perform firmware update
SPSDK: LIBUSBSIO: HID DEVICE is not open.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/utils/interfaces/device/usb_device.py", line 96, in close
    self._device.Close()
  File "/nix/store/y3ipy64jv55za9rcgql4vbv1jq3vv3wa-python3.11-libusbsio-2.1.11/lib/python3.11/site-packages/libusbsio/libusbsio.py", line 1357, in wrapper
    self._check_device_open()
  File "/nix/store/y3ipy64jv55za9rcgql4vbv1jq3vv3wa-python3.11-libusbsio-2.1.11/lib/python3.11/site-packages/libusbsio/libusbsio.py", line 1342, in _check_device_open
    raise LIBUSBSIO_Exception("HID DEVICE is not open.")
libusbsio.libusbsio.LIBUSBSIO_Exception: LIBUSBSIO: HID DEVICE is not open.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/cli/__init__.py", line 136, in main
    nitropy()
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fslvacr1jmwrlhmf5dnc4avgfg4zvz92-python3.11-click-8.1.7/lib/python3.11/site-packages/click/decorators.py", line 45, in new_func
    return f(get_current_context().obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/cli/nk3/__init__.py", line 119, in update
    exec_update(ctx, image, version, ignore_pynitrokey_version)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/cli/nk3/update.py", line 140, in update
    return updater.update(device, image, version, ignore_pynitrokey_version)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 192, in update
    with self._get_bootloader(device) as bootloader:
  File "/nix/store/gd3shnza1i50zn8zs04fa729ribr88m9-python3-3.11.8/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/nk3/updates.py", line 342, in _get_bootloader
    with self.await_bootloader() as bootloader:
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/base.py", line 29, in __exit__
    self.close()
  File "/nix/store/j471sr4xplmrprg2kk0k4s67v2qlrlx5-python3.11-pynitrokey-0.4.46/lib/python3.11/site-packages/pynitrokey/trussed/bootloader/lpc55.py", line 67, in close
    self.device.close()
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/mcuboot.py", line 297, in close
    self._interface.close()
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/mboot/protocol/bulk_protocol.py", line 43, in close
    self.device.close()
  File "/nix/store/x374rjjb5l9fdbn914z29hlrwrrbw1rw-python3.11-spsdk-2.1.1/lib/python3.11/site-packages/spsdk/utils/interfaces/device/usb_device.py", line 99, in close
    raise SPSDKConnectionError(f"Unable to close device '{str(self)}'") from error
spsdk.exceptions.SPSDKConnectionError: SPSDK: Unable to close device 'MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn='''
23703     DEBUG       root listing all connected devices:
23756     DEBUG       root :: 'Nitrokey FIDO2' keys
23757     DEBUG       root :: 'Nitrokey Start' keys:
23769     DEBUG       root :: 'Nitrokey 3' keys
23771      INFO  libusbsio HID enumeration[26784016]: initialized
23771     DEBUG  libusbsio HID enumeration[26784016]: device #0: MCU HID GENERIC DEVICE
23771      INFO  libusbsio HID enumeration[26784016]: finished, total 1 devices
23825      INFO spsdk.mboot.mcuboot Connect: identifier='usb', device=MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn=''
23826     DEBUG spsdk.utils.interfaces.device.usb_device Opening the Interface: MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn=''
23826      INFO libusbsio.hidapi.dev Opening HID device at path: 'b'/dev/hidraw3''
23878      INFO libusbsio.hidapi.dev HID device 20857376 is now open
23878      INFO spsdk.mboot.mcuboot CMD: GetProperty(UniqueDeviceIdent, index=0)
23878     DEBUG spsdk.mboot.mcuboot TX-PACKET: Tag=GetProperty, Flags=0x00, P[0]=0x00000012, P[1]=0x00000000
23878     DEBUG spsdk.mboot.protocol.bulk_protocol OUT[16]: 01, 00, 0C, 00, 07, 00, 00, 02, 12, 00, 00, 00, 00, 00, 00, 00
23879     DEBUG libusbsio.hidapi.dev HID device 20857376 writing[16]: 0x01000c00070000021200000000000000
23880     DEBUG libusbsio.hidapi.dev HID device 20857376 wrote 59 bytes
23881     DEBUG libusbsio.hidapi.dev HID device 20857376 read[60]: 0x03001800a70000050000000058ea46dfee40a45d8707603a8c05b10f0000000000000000000000000000000000000000000000000000000000000000
23881     DEBUG spsdk.mboot.protocol.bulk_protocol IN [60]: 03, 00, 18, 00, A7, 00, 00, 05, 00, 00, 00, 00, 58, EA, 46, DF, EE, 40, A4, 5D, 87, 07, 60, 3A, 8C, 05, B1, 0F, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
23882     DEBUG spsdk.mboot.mcuboot RX-PACKET: Tag=GetPropertyResponse, Status=Success, v0=0xDF46EA58, v1=0x5DA440EE, v2=0x3A600787, v3=0x0FB1058C
23882      INFO spsdk.mboot.mcuboot CMD: Status: 0 (0x0) Success.
23882     DEBUG       root /dev/hidraw3: Nitrokey 3 Bootloader (LPC55) 58EA46DFEE40A45D8707603A8C05B10F
23882      INFO spsdk.mboot.mcuboot Closing: identifier='usb', device=MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn=''
23882     DEBUG spsdk.utils.interfaces.device.usb_device Closing the Interface: MCU HID GENERIC DEVICE (0x20A0, 0x42DD)path=b'/dev/hidraw3' sn=''
23882      INFO libusbsio.hidapi.dev HID device 20857376 closed
23882     DEBUG       root :: 'Nitrokey Passkey' keys
23938     DEBUG       root print: --------------------------------------------------------------------------------
23938     DEBUG       root print: Critical error occurred, exiting now
23938     DEBUG       root print: Unexpected? Is this a bug? Would you like to get support/help?
23938     DEBUG       root print: - You can report issues at: https://support.nitrokey.com/
23938     DEBUG       root print: - Writing an e-mail to support@nitrokey.com is also possible
23938     DEBUG       root print: - Please attach the log: '/tmp/nitropy.log.l95t8fw2' with any support/help request!
23938     DEBUG       root print: - Please check if you have udev rules installed: https://docs.nitrokey.com/nitrokey3/linux/firmware-update.html#troubleshooting

Are you using NixOS or Nix package manager?

I once flashed with nitropy from Nix package manager from a Debian box as root. So I can confirm that it is possible.

Maybe you could try with a Live Linux like Ubuntu or Debian and nitropy installed using pipx?

I think this is a better supported way to use a more mainstream Linux for flashing.

I am indeed using nixos. I am using the nitropy from nixpkgs master since they fixed a build bug present in stable (cryptography library too new / version mismatch).

I didn’t see anything in the logs to suggest it was due to the nix side of things, but i am having trouble following the logic of what is actually happening in the logs. It seems to fall back to hidraw devices that aren’t even associated with my nitrokey, but maybe that’s because it’s panicing on what to do (hidraw0 and hidraw1 are preexisting devices in my case).

Also: “unable to enumerate USB device” seems kind of weird but i’m not sure that’s the issue. It does get to the point where it asks me to press the button. I’m not sure if that message is emitted before or after i press the button, but it’s definitely a part of the flash process.

I think the live boot ubuntu seems like a good idea, regardless. Do you have any ubuntu version suggestions for better support? Maybe just current 22.04 LTS.

Most of the time I use Debian Bookworm with pipx. However, I found a thread, where I explained the configuration using nixpkg to reproduce a bug.

Virtual machines can be risky since you may lose connectivity to the USB device and it’s preferable to use physical hardware without any USB hubs for flashing.

I was able to get it flashed booting Ubuntu Desktop 22.04 LTS LiveCD, once i got everything installed (you have to add universe repos to apt to get python3-pip and friends, and set up the udev rules as documented by nitrokey).

I realized my NixOS is not on stable – that may be related if others are not having any problems on NixOS.