4 ms·
I was wondering if it would be suitable for micro controllers (with let's say a few hundred kB of memory, not MB). I can't immediately find the answer but there
by janekm 7y ago
I was wondering if it would be suitable for micro controllers (with let's say a few hundred kB of memory, not MB). I can't immediately find the answer but there appears to be a port to Zephyr OS in the repo so that is promising.
There's also the beginnings of a sensor manager and API so clearly small embedded use cases are intended.
It's still a very small project (looks like one contributor so far), but that's no bad thing...
- justinclift 7y agoTinyGo (Go for embedded devices - AVR, Cortex, Bluepill, STM32F4, etc) compiles to Wasm as well: https://github.com/tinygo-org/tinygo/ https://github.com/tinygo-org/tinygo/ No garbage collector yet, but it's on the ToDo list and probably not too far off. :)
- snarfy 7y agoDo you really want garbage collection when your device has 2KB of ram?
- justinclift 7y agoIt depends. There's no one-size-fits-everything approach for this stuff. :)
- kbumsik 7y agoNo, you can't run GC at all. The minimum size of WASM heap is 64KiB by its spec. Otherwise it should run in stack-only mode. So running GC for microcontroller with less than that size doesn't make much sense.
- zaarn 7y agoI would imagine a scaled down and cut version of WASM could be viable on MCU's as a form of interpreted program to be loaded from an external memory device, the WASM compiler/interpreter would likely already take much of a small MCU's memory.
- i4t 7y agoYes, definitely aimed at embedded devices.
- baybal2 7y agoIt will be much more ahead of interpreters running on MCUs (overhead of parsing alone is enough to disqualify them for production use,) but still hopelessly far behind native code. WASM was made with running on regular desktop CPUs in mind. Wasm is not a truly a state machine, nor stack machine, but a horrible hybrid in between them thanks to design by committee. Changeable locals, accessible undefineds, use of stack pointer protection technique that kills both pipelining and speculative execution. Yes, that's combined downsides of both stack and register VMs. There were MCU that were naively running Java long time ago, but all failed on the market. The idea proved non feasible
- Zardoz84 7y agoSo BASIC Stamp, was a dream... I know that was popular to do some automatization on industrial machines.
- boomlinde 7y ago> It will be much more ahead of interpreters running on MCUs (overhead of parsing alone is enough to disqualify them for production use,) but still hopelessly far behind native code. To be clear, this is also interpreted, so it doesn't have an advantage there.
- rjsw 7y ago> There were MCU that were naively running Java long time ago, but all failed on the market. The idea proved non feasible Not sure they failed for technical reasons, embedded CPUs just got fast enough and typical memory big enough to run a JIT.
- sitkack 7y agoWe already have Lua [1] and MicroPython [2] as well as a myriad of Forths, Scheme, etc running on MCUs. So arguably Wasm would be a better fit for an MCU over these two as it doesn't need to be parsed and the interpreter doesn't need to handle dynamic types. [1] http://www.eluaproject.net/ http://www.eluaproject.net/ [2] https://micropython.org/ https://micropython.org/
- deleted 7y ago[deleted]
- radarsat1 7y agoWhat would be the advantage of running WASM on a microcontroller instead of compiling the code directly for the microcontroller's architecture?
- yorwba 7y agoI assume this is meant for cases where there's no LLVM backend for the target architecture and you're forced to use the vendor's proprietary C compiler. Then you can use that to compile this runtime and run any program written in a WASM-targeting language on top of it.
- janekm 7y agoI'm assuming safer loadable modules (there's no memory protection on most mcus) and choice of languages that have wasm backends. In some circumstances being able to run the same code in a browser in a test environment as on the device could also be great (for education for example).
- jononor 7y agoI'm interested in WASM for microcontrollers to have the application guaranteed free of side-effects (due to the sandboxing). This allows to be test the logic thoroughly in isolation, and have reasonably high certainty that it does not do anything funky - like write to some hardware register in some edge-case. Such code would not be able to do I/O directly, but must receive it from outside the sandbox. It could be a pure function implementing a state machine on form `state, outputs = next(state, inputs)`, where state,inputs and outputs are plain data. This structure is amendable to generating testcases, be it via property testing or fuzzing. Or regression tests by capturing a stream of state transitions in serialized form. There are languages which makes this possible, like Haskell, or maybe even Rust or Ada. However in the embedded world, C is what everyone knows and uses, so there would be a benefit to staying within that ecosystem.
- unwind 7y agoCool, but aren't side-effects just what you want when using a microcontroller to, you know, control things? I work in embedded development and the amount of pure logic is really small in our software but I guess that varies with the niche you're in.