Hi,
How do I create mpy module with bindings to IDF API? What needs to be included into Makefile or example?
Toolchain bindings in mpy files
Re: Toolchain bindings in mpy files
Unfortunately .mpy files cannot access any functions other than what's in dynruntime.h. At this stage they're mostly intended for writing high performance self-contained functionality in C.
The problem is that the IDF functions don't actually exist on the device at runtime (because only the ones used by hte micropython firmware will be linked into the final binary). Additionally, your .mpy file knows nothing about the layout of the code in the micropython firmware - the only thing it knows is the location of the functions in dynruntime.h (via a lookup table).
On a full operating system, this is all solved by the linker and loader, but MicroPython (for space and efficiency reasons) doesn't have this.
For more details (and a proposed solution), see https://github.com/micropython/micropython/pull/5711