Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nk3: Use mboot instead of spsdk for bootloader #166

Closed
wants to merge 1 commit into from

Conversation

robin-nitrokey
Copy link
Member

With this patch, we use mboot instead of spsdk for bootloader
communication. This speeds up the process noticably on Linux and by
several orders of magnitude on Windows.


Currently, basic communication works but the update fails with this error:

  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/pynitrokey/nk3/bootloader.py", line 92, in list                                                                                               
    for device in RawHid.enumerate(VID_NITROKEY, PID_NITROKEY3_BOOTLOADER):                              
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/mboot/connection/usb.py", line 337, in enumerate                                                                                              
    config = dev.get_active_configuration()                                                              
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/usb/core.py", line 875, in get_active_configuration                                                                                           
    return self._ctx.get_active_configuration(self)                                                      
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/usb/core.py", line 102, in wrapper
    return f(self, *args, **kwargs)                                                                      
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/usb/core.py", line 236, in get_active_configuration                                                                                           
    self.managed_open()  
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/usb/core.py", line 102, in wrapper  
    return f(self, *args, **kwargs)                                                                      
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/usb/core.py", line 120, in managed_open
    self.handle = self.backend.open_device(self.dev)                                                                                                                                                               
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/usb/backend/libusb1.py", line 786, in open_device                                                                                             
    return _DeviceHandle(dev)                                                                            
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/usb/backend/libusb1.py", line 643, in __init__                                                                                                
    _check(_lib.libusb_open(self.devid, byref(self.handle)))         
  File "/home/robin/reps/pynitrokey/venv/lib/python3.9/site-packages/usb/backend/libusb1.py", line 595, in _check                                                                                                  
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])                                              
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

With this patch, we use mboot instead of spsdk for bootloader
communication.  This speeds up the process noticably on Linux and by
several orders of magnitude on Windows.
@robin-nitrokey
Copy link
Member Author

The speed issue with spsdk has been fixed so we no longer need this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant