https://github.com/wasm3/wasm3? https://github.com/espressif/esp-wasmachine ? https://github.com/bytecodealliance/wasm-micro-runtime/tree/... ? https://github.com/TOPLLab/WARDuino ?
Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
11–20 of 41 posts
Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#12Earlier quoted context omitted.
> i do think it would be clearer, though, to explain up front that the module being built is not made of python code, but rather callable from python code I know nothing about micropython. Do the modules contain bytecode?
.mpy modules can contain MicroPython bytecode and/or native machine code. In this case, WASM is compiled (via C) to native code. So the performance is very good, much better than interpreting either MicroPython bytecode or WASM bytecode. The conventional way of creating native modules for MicroPython is to write them in C. This work allows to use any language that supports WASM output target.
Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#13These .mpy files are dynamically loaded into MicroPython using a regular python import.
Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#14Earlier quoted context omitted.
.mpy modules can contain MicroPython bytecode and/or native machine code. In this case, WASM is compiled (via C) to native code. So the performance is very good, much better than interpreting either MicroPython bytecode or WASM bytecode. The conventional way of creating native modules for MicroPython is to write them in C. This work allows to use any language that supports WASM output target.
Oh, I didn't know MicroPython was fully AOT. I'm surprised, since vanilla Python is typically interpreted with maybe a bytecode cache, right?
Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#15Earlier quoted context omitted.
> i do think it would be clearer, though, to explain up front that the module being built is not made of python code, but rather callable from python code I know nothing about micropython. Do the modules contain bytecode?
In this case, the modules contain native code compiled for the target architecture. Micropython has something approximating a dynamic linker to load them. https://docs.micropython.org/en/latest/develop/natmod.html
tools/mpy-tool.py lists opcodes: https://github.com/micropython/micropython/blob/master/tools...
Can the same be done with .pyc files; what are the advantages of MicroPython native modules?
Why does it need wasm2c?
Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#16I feel like this project is a classic example of the README missing a "Why?" section. Not to justify the project, it just makes it hard to evaluate without understanding why they choose implementing a transpiler rather than an embedded WASM VM. Or why not transpile to native assembly? I'm sure they have good reasons but they aren't listed here.
i think your questions are implicitly answered in the top page of the readme, but by showing rather than telling esp32 and stm32 run three different native assembly instruction sets (though this only supports two of them, the others listed in the first line of the readme are all arm) the coremark results seem like an adequate answer to why you'd use a compiler rather than an interpreter i do think it would be clearer…
WASM is an almost "ideal" bytecode target for embedded AOT native compilation as well, though yeah, you'd have to implement all of the backend targets.
Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#17Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#18Earlier quoted context omitted.
> i do think it would be clearer, though, to explain up front that the module being built is not made of python code, but rather callable from python code I know nothing about micropython. Do the modules contain bytecode?
.mpy modules can contain MicroPython bytecode and/or native machine code. In this case, WASM is compiled (via C) to native code. So the performance is very good, much better than interpreting either MicroPython bytecode or WASM bytecode. The conventional way of creating native modules for MicroPython is to write them in C. This work allows to use any language that supports WASM output target.
Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#19Can we have python compiled to wasm compiled to python compiled to wasm compiled to python - just for obfuscation reasons?
Re: Wasm2Mpy: Compiling WASM to MicroPython so it can run on Raspberrys
#20I feel like this project is a classic example of the README missing a "Why?" section. Not to justify the project, it just makes it hard to evaluate without understanding why they choose implementing a transpiler rather than an embedded WASM VM. Or why not transpile to native assembly? I'm sure they have good reasons but they aren't listed here.