mpremote mip install: Better support for natmods, substitute arch/version specific info - #19478
mpremote mip install: Better support for natmods, substitute arch/version specific info#19478jonnor wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19478 +/- ##
==========================================
- Coverage 98.55% 98.51% -0.04%
==========================================
Files 179 179
Lines 23243 23243
==========================================
- Hits 22907 22899 -8
- Misses 336 344 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Code size report: |
Signed-off-by: Jon Nordby <jononor@gmail.com>
Signed-off-by: Jon Nordby <jononor@gmail.com>
Signed-off-by: Jon Nordby <jononor@gmail.com>
198429f to
b51154f
Compare
|
I believe you forgot about https://github.com/micropython/micropython/blob/master/docs/reference/mpyfiles.rst#architecture-specific-flags. |
|
@agatti good point. How do I configure those flags for a natmod build? And how are/should they be serialized in a path? |
|
That's been introduced as part of the natmod toolchain in b87d73f - tl;dr: set Right now this is only available for RV32/RV64, but it is supposed to also cover Xtensa once a PR containing that gets through (see 1c51263). Regarding how to serialise and encode that, it depends whether you want to get things explicit or not. Loading a natmod for the right architecture kind but with the wrong architecture flags will fail the same way as if you'd load, say, an x86 natmod on an ESP32. If you want to get things explicit then you'd have to keep track of which strings mean what value, which requires active maintenance. Right now all flags are exposed as bitfields/variable-length integers so the quick way out of this is to encode things as either [1] micropython/docs/reference/mpyfiles.rst Lines 57 to 69 in 7b6130a |
|
Thanks for the info! Hex serialization of the flags is pragmatic. We could have the marker be MPY_ARCH_FLAGS_HEX - that way if we pick another more explicit/readable serialization later, it would be easy to support without breaking compatibility? Is the mapping between the flags reported by |
|
You may still want to handle cases where the arch flags aren't there, otherwise the vast majority of modules you'll ever see will end up having a 0 in there. For the load/reject rules, I'm afraid you'll have to write a per-architecture checker. RV32/RV64 a module is loaded successfully if all requested extensions are supported by the interpreter (ie. Xtensa/Xtensawin instead - whilst this is not set in stone yet - will need to have an interpreter CPU core version equal or higher than what is requested by the module, with no flags indicating the bare minimum core version (LX3 - the one in the ESP8266). In other words, |
|
My proposal would be the possibility to add to the single |
Summary
This change allows using a single URL to specify a native module package - regardless of the ABI/architecture. mip will then lookup the correct hardware architecture and MicroPython ABI version, and substitute this into the URL before doing the download/install.
For more details and motivation, see the corresponding change to micropython-lib
mipfor more details: micropython/micropython-lib#1140Testing
Tested on Linux PC, connecting to a RPi Pico. By installing module from https://github.com/emlearn/emlearn-micropython
The below examples should work on any hardware supported by emlearn-micropython.
Installing a module
Should now be possible to import the installed module
Generative AI
I did not use generative AI tools when creating this PR.