bytecodealliance / wasm-micro-runtime

WebAssembly Micro Runtime (WAMR)
Apache License 2.0
4.66k stars 576 forks source link

Adding support for new hardware platform (MCU) #3161

Open silabs-theophilel opened 4 months ago

silabs-theophilel commented 4 months ago

Hi there,

I started to get my eyes on WAMR for an experimental project that aims to offer a uniform way of generating code uniformly across various hardware MCU platforms (STM, NXP, Silabs, Infenion, ...), for IoT specifically.

I see that in the shared lib inside the VMcore building block, the platform-defined code is done at the os level and that there is no hardware-specific code.

What does it mean for porting current WAMR implementation on, for example, an ARM Cortex-M33 chip? What would be the required step for that? I have seen this tutorial, about creating a new platform but, it is os-level not hardware level.

So to not get confused I prefer asking here first: before porting the WAMR onto new MCUs, is there any required modification on the code itself to support other hardware platforms not tested (stated above)? As long as I use the same OSs that are supported (Zephyr or FreeRTOS for example).


TLDR: Is any more work on the WAMR codebase needed, other than the one described here and here, for running WAMR hello-world with an example STM32 with Zephyr-OS or FreeRTOS?

TianlongLiang commented 4 months ago

We do have support for multiple MCU platforms with Zephyr-OS, you can refer to this directory. I think in most cases (including STM32 with Zephyr-OS you asked), you don't have to modify the codebase. You can simply use existing or add more board configs in the Zephyr board subdirectory. Feel free to play with some example configs in this directory.

However, there is no guarantee that all new platforms won't need modifications. There are always corner cases; there may be some hardware platform-specific modifications needed for a new platform, some instructions or relocation types that are unavailable on the toolchain, and different linking mechanisms may be required, etc. What we can do is fix it on a case-by-case basis when encountering it.

Here is an example of what platform-specific problem can be.