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

Spsdk vendor #519

Closed
wants to merge 11 commits into from
Closed

Spsdk vendor #519

wants to merge 11 commits into from

Conversation

sosthene-nitrokey
Copy link
Contributor

Vendor parts of SPSDK needed for LPC55 updates.

Similar to #346

This is currently in a state that works (validating and uploading updates tested), but I can likely remove a lot of code and still keep it working. Ideally we don't need such a large blob.

spsdk is licensed BSD-3 clause, so it's compatible.

The goal is to fix #512

@robin-nitrokey
Copy link
Member

Maintaining the fork in a separate repository that is forked from spsdk would make it easier to pull in upstream changes. It could still be included as a submodule here so that we don’t need to release it separately. What do you think?

@sosthene-nitrokey
Copy link
Contributor Author

Would making it a separate project not bring packaging issues?

@daringer
Copy link
Collaborator

let's pull it in first, like nrf_upload - once we pull out the cli we should think how and if this should also be separate...

@sosthene-nitrokey sosthene-nitrokey marked this pull request as ready for review March 21, 2024 15:57
@sosthene-nitrokey
Copy link
Contributor Author

sosthene-nitrokey commented Mar 21, 2024

I've been able to minimize it even more. This allowed removing the gmssl dependency. We are also rid of pypemicro.

More pruning could be done by removing Class methods (currently no class or file can be removed without breaking stuff).

The imported modules are not type checked because the type definitions are broken (223 errors).

@robin-nitrokey
Copy link
Member

Regading mypy, are there still errors when disabling strict checks?

# disable strict checks for old code, see
# - https://github.com/python/mypy/issues/11401
# - https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options
[[tool.mypy.overrides]]
module = [
"pynitrokey.cli",
"pynitrokey.cli.pro",
"pynitrokey.cli.program",
"pynitrokey.cli.start",
"pynitrokey.cli.storage",
"pynitrokey.cli.update",
"pynitrokey.conftest",
"pynitrokey.libnk",
"pynitrokey.start.*",
"pynitrokey.test_secrets_app",
]

@sosthene-nitrokey
Copy link
Contributor Author

There are still a couple of errors, but much less (36).

Maybe I can try to fix them.

@sosthene-nitrokey
Copy link
Contributor Author

I've fixed the mypy errors in spsdk, bumped mypy to 1.9 and cryptography to 42.

@daringer
Copy link
Collaborator

libusbsio is another weird nxp package, which essentially just wraps hid, right ?
would it make sense to take a look on removing that?

@sosthene-nitrokey
Copy link
Contributor Author

sosthene-nitrokey commented Mar 22, 2024

libusbsio wraps a custom binary library by NXP. Ripping it off would be a bit more involved.

This does mean it would be great to get rid of it though.

@sosthene-nitrokey
Copy link
Contributor Author

We could indeed get it to work with just hidapi, the wrapper appears very thin.

@robin-nitrokey
Copy link
Member

The tricky part with replacing libusbsio is testing on Windows and Mac. I remember that we initially had some problems with the bootloader communication on other platforms than Linux so we should pay close attention not to accidentally break it with refactoring.

@sosthene-nitrokey
Copy link
Contributor Author

I'm not sure I can test on mac. Maybe we should merge the version still using libusbsio at first.

@robin-nitrokey
Copy link
Member

Yes, I would prefer that.

robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Jul 31, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies.  We now also pass strict mypy checks on all imported
modules (except for the libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Jul 31, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Jul 31, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Jul 31, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Jul 31, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Jul 31, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Jul 31, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
@robin-nitrokey
Copy link
Member

robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Aug 5, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Aug 7, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Aug 7, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
robin-nitrokey added a commit to Nitrokey/nitrokey-sdk-py that referenced this pull request Aug 7, 2024
This commit is extracted from:  Nitrokey/pynitrokey#519

I’ve further reduced the included code so that we can get rid of even
more dependencies:  We only need crcmod, cryptography and libusbsio.  We
now also pass strict mypy checks on all imported modules (except for the
libusbsio imports).

Co-authored-by: Sosthène Guédon <sosthene@nitrokey.com>
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.

nitropy - invalid module error with latest python cryptography module
3 participants