Bonjour,
in this link , how to make c module as .mpy file. this file is then 'import' in micropython repl : fine and easy.
https://docs.micropython.org/en/latest/ ... tml#natmod
is it possible for all c module ? for example
https://github.com/russhughes/st7789_mpy
avoid to generate firmware.bin and flash.
thanks for informations.
Regards
Native machine code in .mpy files : question
-
- Posts: 15
- Joined: Thu Feb 18, 2021 4:24 pm
Re: Native machine code in .mpy files : question
I tried, when the native modules were released, but I was not able to make it work. I ran into to the linker limitation described in the docs:
I have not tried to build the driver as a native module since. I'll look into it.Linker limitation: the native module is not linked against the symbol table of the full MicroPython firmware. Rather, it is linked against an explicit table of exported symbols found in mp_fun_table (in py/nativeglue.h), that is fixed at firmware build time. It is thus not possible to simply call some arbitrary HAL/OS/RTOS/system function, for example.
New symbols can be added to the end of the table and the firmware rebuilt. The symbols also need to be added to tools/mpy_ld.py’s fun_table dict in the same location. This allows mpy_ld.py to be able to pick the new symbols up and provide relocations for them when the mpy is imported. Finally, if the symbol is a function, a macro or stub should be added to py/dynruntime.h to make it easy to call the function.
-
- Posts: 15
- Joined: Thu Feb 18, 2021 4:24 pm
Re: Native machine code in .mpy files : question
Bonjour Russ ,
Some news about this subject ?
Regards
Some news about this subject ?
Regards