Introduction ============== This sample demonstrates that a graphic user interface application in WebAssembly integrates the LittlevGL, an open-source embedded 2d graphic library. In this sample, the whole LittlevGL source code is built into the WebAssembly code with the user application. The platform interfaces defined by LittlevGL is implemented in the runtime and exported to the application through the declarations from source "ext_lib_export.c" as below: EXPORT_WASM_API(display_init), EXPORT_WASM_API(display_input_read), EXPORT_WASM_API(display_flush), EXPORT_WASM_API(display_fill), EXPORT_WASM_API(display_vdb_write), EXPORT_WASM_API(display_map), EXPORT_WASM_API(time_get_ms), }; The runtime component supports building target for Linux and Zephyr/STM Nucleo board. The beauty of this sample is the WebAssembly application can have identical display and behavior when running from both runtime environments. That implies we can do majority of application validation from desktop environment as long as two runtime distributions support the same set of application interface. The sample also provides the native Linux version of application without the runtime under folder "vgl-native-ui-app". It can help to check differences between the implementations in native and WebAssembly. The number on top will plus one each second, and the number on the bottom will plus one when clicked. Install required SDK and libraries ============== - 32 bit SDL(simple directmedia layer) Use apt-get `sudo apt-get install libsdl2-dev:i386` Or download source from www.libsdl.org `./configure C_FLAGS=-m32 CXX_FLAGS=-m32 LD_FLAGS=-m32` `make` `sudo make install` - Install EMSDK
https://emscripten.org/docs/tools_reference/emsdk.htmlBuild and Run ============== Linux -------------------------------- - Build `./build.sh` All binaries are in "out", which contains "host_tool", "vgl_native_ui_app", "TestApplet1.wasm" and "vgl_wasm_runtime". - Run native Linux application `./vgl_native_ui_app` - Run WASM VM Linux applicaton & install WASM APP First start vgl_wasm_runtime in server mode. `./vgl_wasm_runtime -s` Then install wasm APP use host tool. `./host_tool -i ui_app -f ui_app.wasm` Zephyr -------------------------------- WASM VM and native extension method can be built into Zephyr, Then we can install wasm app into STM32. - Build WASM VM into Zephyr system a. clone zephyr source code Refer to Zephyr getting started. https://docs.zephyrproject.org/latest/getting_started/index.html `west init zephyrproject` `cd zephyrproject` `west update` b. copy samples `cd zephyr/samples/` `cp -a