diff --git a/modules/wasm-micro-runtime/CMakeLists.txt b/modules/wasm-micro-runtime/CMakeLists.txt new file mode 100644 index 0000000000000..17e5b8c38e5b3 --- /dev/null +++ b/modules/wasm-micro-runtime/CMakeLists.txt @@ -0,0 +1,429 @@ +# Copyright (c) 2021 Intel Corporation +# SPDX-Licensedentifier: Apache-2.0 + +if(CONFIG_WAMR) + + set(WAMR_DIR ${ZEPHYR_CURRENT_MODULE_DIR}) + + zephyr_library() + + zephyr_include_directories( + ${WAMR_DIR}/core + ${WAMR_DIR}/core/iwasm/include + ${WAMR_DIR}/core/iwasm/common + ${WAMR_DIR}/core/iwasm/interpreter + ${WAMR_DIR}/core/shared/platform/common/libc-util + ${WAMR_DIR}/core/shared/platform/include + ${WAMR_DIR}/core/shared/platform/zephyr + ${WAMR_DIR}/core/shared/utils + ${WAMR_DIR}/core/shared/mem-alloc + ) + + zephyr_library_compile_options(-Wno-unused-variable) + + zephyr_compile_definitions( + BH_PLATFORM_ZEPHYR + BH_MALLOC=wasm_runtime_malloc + BH_FREE=wasm_runtime_free + ) + + # General files + zephyr_library_sources( + ${WAMR_DIR}/core/shared/platform/zephyr/zephyr_platform.c + ${WAMR_DIR}/core/shared/platform/zephyr/zephyr_thread.c + ${WAMR_DIR}/core/shared/platform/zephyr/zephyr_time.c + ${WAMR_DIR}/core/shared/platform/common/math/math.c + ${WAMR_DIR}/core/shared/platform/common/libc-util/libc_errno.c + ${WAMR_DIR}/core/shared/mem-alloc/mem_alloc.c + ${WAMR_DIR}/core/shared/mem-alloc/ems/ems_kfc.c + ${WAMR_DIR}/core/shared/mem-alloc/ems/ems_gc.c + ${WAMR_DIR}/core/shared/mem-alloc/ems/ems_hmu.c + ${WAMR_DIR}/core/shared/mem-alloc/ems/ems_alloc.c + ${WAMR_DIR}/core/shared/utils/bh_assert.c + ${WAMR_DIR}/core/shared/utils/bh_bitmap.c + ${WAMR_DIR}/core/shared/utils/bh_common.c + ${WAMR_DIR}/core/shared/utils/bh_hashmap.c + ${WAMR_DIR}/core/shared/utils/bh_leb128.c + ${WAMR_DIR}/core/shared/utils/bh_list.c + ${WAMR_DIR}/core/shared/utils/bh_log.c + ${WAMR_DIR}/core/shared/utils/bh_queue.c + ${WAMR_DIR}/core/shared/utils/bh_vector.c + ${WAMR_DIR}/core/shared/utils/runtime_timer.c + ${WAMR_DIR}/core/shared/utils/uncommon/bh_getopt.c + ${WAMR_DIR}/core/shared/utils/uncommon/bh_read_file.c + ${WAMR_DIR}/core/iwasm/common/wasm_runtime_common.c + ${WAMR_DIR}/core/iwasm/common/wasm_exec_env.c + ${WAMR_DIR}/core/iwasm/common/wasm_native.c + ${WAMR_DIR}/core/iwasm/common/wasm_memory.c + ${WAMR_DIR}/core/iwasm/common/wasm_shared_memory.c + ${WAMR_DIR}/core/iwasm/common/wasm_c_api.c + ${WAMR_DIR}/core/iwasm/common/wasm_application.c + ${WAMR_DIR}/core/iwasm/common/wasm_loader_common.c + ${WAMR_DIR}/core/iwasm/common/wasm_blocking_op.c + ) + + zephyr_library_sources_ifdef(CONFIG_WAMR_LIBC_WASI + ${WAMR_DIR}/core/shared/platform/zephyr/zephyr_socket.c + ${WAMR_DIR}/core/shared/platform/zephyr/zephyr_file.c + ${WAMR_DIR}/core/shared/platform/zephyr/zephyr_clock.c + ) + + # Build target macros and source files + if(CONFIG_WAMR_BUILD_TARGET) + string(TOUPPER ${CONFIG_WAMR_BUILD_TARGET} CONFIG_WAMR_BUILD_TARGET) + endif() + if((CONFIG_WAMR_BUILD_TARGET STREQUAL "X86_64") OR CONFIG_X86_64 OR + (CONFIG_ARCH_POSIX AND (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64"))) + zephyr_compile_definitions( + BUILD_TARGET_X86_64 + BUILD_TARGET="X86_64" + ) + if(NOT ${CONFIG_WAMR_SIMD}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_em64.s + ) + else() + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_em64_simd.s + ) + endif() + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_x86_64.c + ) + endif() + elseif((CONFIG_WAMR_BUILD_TARGET STREQUAL "X86_32") OR CONFIG_X86 OR + (CONFIG_ARCH_POSIX AND (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86"))) + zephyr_compile_definitions( + BUILD_TARGET_X86_32 + BUILD_TARGET="X86_32" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_ia32.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_x86_32.c + ) + endif() + elseif((CONFIG_WAMR_BUILD_TARGET STREQUAL "XTENSA") OR + (${CONFIG_XTENSA})) + zephyr_compile_definitions( + BUILD_TARGET_XTENSA + BUILD_TARGET="XTENSA" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_xtensa.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_xtensa.c + ) + endif() + elseif((CONFIG_WAMR_BUILD_TARGET STREQUAL "RISCV64") OR + (CONFIG_WAMR_BUILD_TARGET STREQUAL "RISCV64_LP64D")) + zephyr_compile_definitions( + BUILD_TARGET_RISCV64_LP64D + BUILD_TARGET="RISCV64_LP64D" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_riscv.S + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_riscv.c + ) + endif() + elseif((CONFIG_WAMR_BUILD_TARGET STREQUAL "RISCV64_LP64") OR + ((${CONFIG_RISCV}) AND (${CONFIG_64BIT}))) + zephyr_compile_definitions( + BUILD_TARGET_RISCV64_LP64 + BUILD_TARGET="RISCV64_LP64" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_riscv.S + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_riscv.c + ) + endif() + elseif((CONFIG_WAMR_BUILD_TARGET STREQUAL "RISCV32") OR + (CONFIG_WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32D")) + zephyr_compile_definitions( + BUILD_TARGET_RISCV32_ILP32D + BUILD_TARGET="RISCV32_ILP32D" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_riscv.S + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_riscv.c + ) + endif() + elseif((CONFIG_WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32") OR + ((${CONFIG_RISCV}) AND (NOT (${CONFIG_64BIT})))) + zephyr_compile_definitions( + BUILD_TARGET_RISCV32_ILP32 + BUILD_TARGET="RISCV32_ILP32" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_riscv.S + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_riscv.c + ) + endif() + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_riscv.c + ) + elseif((CONFIG_WAMR_BUILD_TARGET STREQUAL "ARC") OR (${CONFIG_ARC})) + zephyr_compile_definitions( + BUILD_TARGET_ARC + BUILD_TARGET="ARC" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_arc.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_arc.c + ) + endif() + elseif(CONFIG_WAMR_BUILD_TARGET MATCHES "ARM.*") + if(CONFIG_WAMR_BUILD_TARGET MATCHES "(ARM.*)_VFP") + add_definitions(-DBUILD_TARGET_ARM_VFP) + add_definitions(-DBUILD_TARGET="${CMAKE_MATCH_1}") + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_arm_vfp.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_arm.c + ) + endif() + else() + add_definitions(-DBUILD_TARGET_ARM) + add_definitions(-DBUILD_TARGET="${CONFIG_WAMR_BUILD_TARGET}") + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_arm.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_arm.c + ) + endif() + endif() + elseif(CONFIG_WAMR_BUILD_TARGET MATCHES "THUMB.*") + if(CONFIG_WAMR_BUILD_TARGET MATCHES "(THUMB.*)_VFP") + add_definitions(-DBUILD_TARGET_THUMB_VFP) + add_definitions(-DBUILD_TARGET="${CMAKE_MATCH_1}") + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_thumb_vfp.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_thumb.c + ) + endif() + else() + add_definitions(-DBUILD_TARGET_THUMB) + add_definitions(-DBUILD_TARGET="${CONFIG_WAMR_BUILD_TARGET}") + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_thumb.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_thumb.c + ) + endif() + endif() + elseif(CONFIG_WAMR_BUILD_TARGET MATCHES "AARCH64.*") + add_definitions(-DBUILD_TARGET_AARCH64) + add_definitions(-DBUILD_TARGET="${CONFIG_WAMR_BUILD_TARGET}") + if(NOT ${CONFIG_WAMR_SIMD}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_aarch64.s + ) + else() + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_aarch64_simd.s + ) + endif() + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_aarch64.c + ) + endif() + elseif(${CONFIG_ARM}) + if(${CONFIG_ISA_THUMB2}) + zephyr_compile_definitions( + BUILD_TARGET_THUMB + BUILD_TARGET="THUMB" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_thumb.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_thumb.c + ) + endif() + else() + zephyr_compile_definitions( + BUILD_TARGET_ARM + BUILD_TARGET="ARM" + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_arm.s + ) + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_arm.c + ) + endif() + endif() + elseif(${CONFIG_ARM64}) + zephyr_compile_definitions( + BUILD_TARGET_AARCH64 + BUILD_TARGET="AARCH64" + ) + if(NOT ${CONFIG_WAMR_SIMD}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_aarch64.s + ) + else() + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/common/arch/invokeNative_aarch64_simd.s + ) + endif() + if(${CONFIG_WAMR_AOT}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/aot/arch/aot_reloc_aarch64.c + ) + endif() + else() + message(FATAL_ERROR "Unsupported CPU architecture") + endif() + + # Interpreter macros and source files + zephyr_compile_definitions_ifdef(CONFIG_WAMR_INTERP + WASM_ENABLE_INTERP=1 + ) + + if(${CONFIG_WAMR_INTERP}) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/interpreter/wasm_loader.c + ${WAMR_DIR}/core/iwasm/interpreter/wasm_runtime.c + ) + if(${CONFIG_WAMR_FAST_INTERP}) + zephyr_compile_definitions( + WASM_ENABLE_FAST_INTERP=1 + ) + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/interpreter/wasm_interp_fast.c + ) + else() + zephyr_library_sources( + ${WAMR_DIR}/core/iwasm/interpreter/wasm_interp_classic.c + ) + endif() + endif() + + # AOT macros and source files + zephyr_compile_definitions_ifdef(CONFIG_WAMR_AOT + WASM_ENABLE_AOT=1 + ) + + zephyr_include_directories_ifdef(CONFIG_WAMR_AOT + ${WAMR_DIR}/core/iwasm/aot + ) + + zephyr_library_sources_ifdef(CONFIG_WAMR_AOT + ${WAMR_DIR}/core/iwasm/aot/aot_loader.c + ${WAMR_DIR}/core/iwasm/aot/aot_runtime.c + ${WAMR_DIR}/core/iwasm/aot/aot_intrinsic.c + ) + + # libc builtin + zephyr_compile_definitions_ifdef(CONFIG_WAMR_LIBC_BUILTIN + WASM_ENABLE_LIBC_BUILTIN=1 + ) + + zephyr_library_sources_ifdef(CONFIG_WAMR_LIBC_BUILTIN + ${WAMR_DIR}/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c + ) + + # libc WASI + zephyr_compile_definitions_ifdef(CONFIG_WAMR_LIBC_WASI + WASM_ENABLE_MODULE_INST_CONTEXT=1 + WASM_ENABLE_LIBC_WASI=1 + ) + + zephyr_include_directories_ifdef(CONFIG_WAMR_LIBC_WASI + ${WAMR_DIR}/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include + ${WAMR_DIR}/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src + ) + + zephyr_library_sources_ifdef(CONFIG_WAMR_LIBC_WASI + ${WAMR_DIR}/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c + ${WAMR_DIR}/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c + ${WAMR_DIR}/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c + ${WAMR_DIR}/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.c + ${WAMR_DIR}/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.c + ) + + # lib pthread + zephyr_compile_definitions_ifdef(CONFIG_WAMR_LIB_PTHREAD + WASM_ENABLE_LIB_PTHREAD=1 + WASM_ENABLE_THREAD_MGR=1 + WASM_ENABLE_BULK_MEMORY=1 + WASM_ENABLE_SHARED_MEMORY=1 + ) + + zephyr_include_directories_ifdef(CONFIG_WAMR_LIB_PTHREAD + ${WAMR_DIR}/core/iwasm/libraries/thread-mgr + ) + + zephyr_library_sources_ifdef(CONFIG_WAMR_LIB_PTHREAD + ${WAMR_DIR}/core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c + ${WAMR_DIR}/core/iwasm/libraries/thread-mgr/thread_manager.c + ) + + # SIMD + zephyr_compile_definitions_ifdef(CONFIG_WAMR_SIMD + WASM_ENABLE_SIMD=1 + ) + + # Reference types + zephyr_compile_definitions_ifdef(CONFIG_WAMR_REF_TYPES + WASM_ENABLE_REF_TYPES=1 + ) + + # Memory profiling + zephyr_compile_definitions_ifdef(CONFIG_WAMR_MEMORY_PROFILING + WASM_ENABLE_MEMORY_PROFILING=1 + ) + + # Performance profiling + zephyr_compile_definitions_ifdef(CONFIG_WAMR_PERF_PROFILING + WASM_ENABLE_PERF_PROFILING=1 + ) + + # Dump call stack + zephyr_compile_definitions_ifdef(CONFIG_WAMR_DUMP_CALL_STACK + WASM_ENABLE_DUMP_CALL_STACK=1 + ) + + # MPU stack count and size + zephyr_compile_definitions_ifdef(CONFIG_WAMR_MPU_STACK_COUNT + BH_ZEPHYR_MPU_STACK_COUNT=${CONFIG_WAMR_MPU_STACK_COUNT} + ) + + zephyr_compile_definitions_ifdef(CONFIG_WAMR_MPU_STACK_SIZE + BH_ZEPHYR_MPU_STACK_SIZE=${CONFIG_WAMR_MPU_STACK_SIZE} + ) + +endif() diff --git a/modules/wasm-micro-runtime/Kconfig b/modules/wasm-micro-runtime/Kconfig new file mode 100644 index 0000000000000..4e58942cbc029 --- /dev/null +++ b/modules/wasm-micro-runtime/Kconfig @@ -0,0 +1,109 @@ +# Configuration for the wasm-micro-runtime (WAMR) module + +# Copyright (c) 2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +config ZEPHYR_WAMR_MODULE + bool + +menuconfig WAMR + bool "WebAssembly Micro Runtime support" + help + This option enables the WebAssembly Micro Runtime library. + +if WAMR + +config WAMR_BUILD_TARGET + string "WAMR build target architecture" + help + Set the target CPU architecture. Current supported targets are: + X86_64, X86_32, AARCH64, ARM, THUMB, XTENSA, ARC, + RISCV64, RSCV32 and MIPS. + If it is not set, system will try to set it according to the + board name and other config info. + For ARM and THUMB, the format is [][_VFP], where + is the ARM sub-architecture and the "_VFP" suffix + means using VFP coprocessor registers s0-s15 (d0-d7) for passing + arguments or returning results in standard procedure-call. Both + and "_VFP" are optional, e.g. ARMV7, ARMV7_VFP, + THUMBV7, THUMBV7_VFP and so on. + For AARCH64, the format is [], VFP is enabled by + default. is optional, e.g. AARCH64, AARCH64V8, + AARCH64V8.1 and so on. + For RISCV64, the format is [_abi], where "_abi" is + optional, currently the supported formats are RISCV64, + RISCV64_LP64D and RISCV64_LP64. RISCV64 and RISCV64_LP64D are + identical, using LP64D as abi (LP64 with hardware floating-point + calling convention for FLEN=64). And RISCV64_LP64 uses LP64 as + abi (Integer calling-convention only, and hardware floating-point + calling convention is not used). + For RISCV32, the format is [_abi], where "_abi" is + optional, currently the supported formats are RISCV32, + RISCV32_ILP32D and RISCV32_ILP32. RISCV32 and RISCV32_ILP32D are + identical, using ILP32D as abi (ILP32 with hardware + floating-point calling convention for FLEN=64). And RISCV32_ILP32 + uses ILP32 as abi (Integer calling-convention only, and hardware + floating-point calling convention is not used). + +config WAMR_INTERP + bool "WebAssembly interpreter support" + default y + help + Enable WebAssembly interpreter + +config WAMR_FAST_INTERP + bool "WebAssembly fast interpreter support" + depends on WAMR_INTERP + default y + help + Enable WebAssembly fast interpreter, if not, the classic + interpreter will be enabled + +config WAMR_AOT + bool "WebAssembly Ahead of Time support" + default y + help + Enable WebAssembly Ahead of Time + +config WAMR_LIBC_BUILTIN + bool "WAMR built-in libc native library support" + default y + help + Enable WAMR built-in libc native library + +config WAMR_LIB_PTHREAD + bool "WAMR pthread native native library support" + help + Enable WAMR built-in libc native library + +config WAMR_SIMD + bool "WAMR 128-bit SIMD support" + depends on WAMR_AOT + default y + help + Enable WAMR 128-bit SIMD feature + +config WAMR_REF_TYPES + bool "WAMR reference types support" + help + Enable WAMR reference types feature + +config WAMR_MPU_STACK_COUNT + int "WAMR MPU stack count" + default 4 + help + The count of MPU stack: when multi-thread and Zephyr MPU are + enabled, the native thread's stack must be previously defined + by Macro provided by Zephyr, this setting configures how many + mpu stacks are enabled, or, how many threads can be created. + +config WAMR_MPU_STACK_SIZE + int "WAMR MPU stack size" + default 4096 + help + The size of each MPU stack: when multi-thread and Zephyr MPU are + enabled, the native thread's stack must be previously defined + by Macro provided by Zephyr, this setting configures the size + of each MPU stack. + +endif # WAMR diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/CMakeLists.txt b/samples/modules/wasm_micro_runtime/wasm_blinky/CMakeLists.txt new file mode 100644 index 0000000000000..63e91cea6d084 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(wasm_hello_world) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/README.rst b/samples/modules/wasm_micro_runtime/wasm_blinky/README.rst new file mode 100644 index 0000000000000..9960e9d71d650 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/README.rst @@ -0,0 +1,103 @@ +.. _wasm-micro-runtime-wasm_hello_world: + +WebAssembly Micro Runtime Hello World +##################################### + +Overview +******** +The sample project illustrates how to run a WebAssembly (WASM) application with +WebAssembly Micro Runtime (WAMR). The WASM application binary is pre-converted into +a byte array defined in ``test_wasm.h``, which is statically linked with the sample. +The bundled WASM program is built with a :abbr:`WIT (WebAssembly Interface Types)` +definition describing its interface to Zephyr. The program configures the +:dtcompatible:`gpio-leds` device referenced by the ``led0`` devicetree alias and +blinks the LED ten times by calling the WIT-described host functions exported from +Zephyr. The WAMR runtime then loads the binary and executes the LED blink loop from +WebAssembly. + +Building and Running +******************** + +This example can be built in the standard way. The target board must provide a +``led0`` devicetree alias that points to a controllable GPIO LED. For example with +the :zephyr:board:`qemu_x86_nommu` target: + +.. zephyr-app-commands:: + :zephyr-app: samples/modules/wasm_micro_runtime/wasm_hello_world/ + :board: qemu_x86_nommu + :goals: build + +For QEMU target, we can launch with following command. + +.. code-block:: console + + west build -t run + +Sample Output +============= + +When the application runs, the LED connected to ``led0`` toggles at 250 ms +intervals for ten cycles. The console shows the elapsed time reported by the host +application once execution completes: + +.. code-block:: console + + elpase: 60 + +Build WASM application +********************** + +Install WASI-SDK +================ +Download WASI-SDK from https://github.com/CraneStation/wasi-sdk/releases and extract the archive to default path "/opt/wasi-sdk" + +Generate WIT bindings and build WASM application with WASI-SDK +============================================================= + +The WebAssembly application consumes a WIT world defined in ``zephyr-led.wit``. +Regenerate the bindings with ``wit-bindgen`` and rebuild the WASM binary whenever +the interface or guest source changes. The provided ``Makefile`` automates the +binding generation and compilation steps: + +.. code-block:: console + + cd wasm-app + cargo install wit-bindgen-cli # if wit-bindgen is not already installed + make + +The build rules default to the WASI SDK installation at ``/opt/wasi-sdk`` and +rebuild the bindings when ``zephyr-led.wit`` changes. Override the ``WASI_SDK`` +environment variable if your SDK is installed elsewhere. + +Dump WASM binary file into byte array file +========================================== + +.. code-block:: console + + cd wasm-app + make embed + +The ``embed`` target depends only on standard POSIX tools (``od``, ``tr``, ``sed`` +and ``awk``) to regenerate ``../src/test_wasm.h``. The following one-liner mirrors +the rule when the conversion needs to be run manually: + +.. code-block:: console + + od -An -v -tx1 test.wasm | tr -s ' ' '\n' | sed '/^$/d' | \ + awk 'BEGIN {print "unsigned char __aligned(4) wasm_test_file[] = {"} \ + {bytes[NR]=$1} \ + END {for (i=1; i<=NR; ++i) { \ + if ((i-1)%12==0) printf(" "); \ + printf("0x%s", bytes[i]); \ + if (i!=NR) { \ + if (i%12==0) printf(",\\n"); \ + else printf(", "); \ + } else { \ + printf("\\n"); \ + } \ + } print("};");}' > ../src/test_wasm.h + +References +********** + + - WAMR sample: https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/product-mini/platforms/zephyr/simple diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/boards/nucleo_f767zi.conf b/samples/modules/wasm_micro_runtime/wasm_blinky/boards/nucleo_f767zi.conf new file mode 100644 index 0000000000000..f065a95957ea6 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/boards/nucleo_f767zi.conf @@ -0,0 +1 @@ +CONFIG_ARM_MPU=y diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/boards/qemu_cortex_a53.conf b/samples/modules/wasm_micro_runtime/wasm_blinky/boards/qemu_cortex_a53.conf new file mode 100644 index 0000000000000..6144e0b15bee0 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/boards/qemu_cortex_a53.conf @@ -0,0 +1,3 @@ +CONFIG_ARM_MMU=n +#CONFIG_TEST_RANDOM_GENERATOR=y +#CONFIG_TIMER_RANDOM_GENERATOR=y diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/prj.conf b/samples/modules/wasm_micro_runtime/wasm_blinky/prj.conf new file mode 100644 index 0000000000000..c65c1affdf852 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/prj.conf @@ -0,0 +1,21 @@ +CONFIG_STACK_SENTINEL=y +CONFIG_PRINTK=y +CONFIG_LOG=y +CONFIG_WAMR=y +CONFIG_WAMR_INTERP=y +CONFIG_WAMR_AOT=y +#CONFIG_WAMR_LIBC_WASI=y +#CONFIG_HEAP_MEM_POOL_SIZE=81292 +#CONFIG_TEST_RANDOM_GENERATOR=y +#CONFIG_NETWORKING=y +#CONFIG_FILE_SYSTEM=y +#CONFIG_POSIX_API=y + + +CONFIG_WAMR_LIB_PTHREAD=y +CONFIG_WAMR_SIMD=y +CONFIG_WAMR_REF_TYPES=y +#CONFIG_WAMR_MEMORY_PROFILING=y +#CONFIG_WAMR_PERF_PROFILING=y +#CONFIG_WAMR_DUMP_CALL_STACK=y + diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/src/main.c b/samples/modules/wasm_micro_runtime/wasm_blinky/src/main.c new file mode 100644 index 0000000000000..357dd72f97d3b --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/src/main.c @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "bh_platform.h" +#include "wasm_export.h" +#include "test_wasm.h" + +#define GLOBAL_HEAP_BUF_SIZE 131072 +#define APP_STACK_SIZE 8192 +#define APP_HEAP_SIZE 8192 + +#ifdef CONFIG_NO_OPTIMIZATIONS +#define MAIN_THREAD_STACK_SIZE 8192 +#else +#define MAIN_THREAD_STACK_SIZE 4096 +#endif + +#define MAIN_THREAD_PRIORITY 5 + +static int app_argc; +static char **app_argv; + +#if DT_NODE_HAS_STATUS(DT_ALIAS(led0), okay) +static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios); +#else +#error "LED0 alias is required to run this sample" +#endif + +static bool led_initialized; + +static int32_t +native_led_configure(wasm_exec_env_t exec_env) +{ + ARG_UNUSED(exec_env); + + if (!device_is_ready(led.port)) { + return -ENODEV; + } + + if (!led_initialized) { + int ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE); + if (ret != 0) { + return ret; + } + + led_initialized = true; + } + + return 0; +} + +static int32_t +native_led_set(wasm_exec_env_t exec_env, int32_t value) +{ + ARG_UNUSED(exec_env); + + if (!led_initialized) { + return -EIO; + } + + return gpio_pin_set_dt(&led, value != 0); +} + +static int32_t +native_sleep_ms(wasm_exec_env_t exec_env, int32_t timeout_ms) +{ + ARG_UNUSED(exec_env); + + if (timeout_ms < 0) { + return -EINVAL; + } + + k_msleep(timeout_ms); + + return 0; +} + +static NativeSymbol zephyr_native_symbols[] = { + { "configure", native_led_configure, "()i", NULL }, + { "set", native_led_set, "(i)i", NULL }, + { "sleep-ms", native_sleep_ms, "(i)i", NULL }, +}; + +static void* +app_instance_main(wasm_module_inst_t module_inst) +{ + const char *exception; + + wasm_application_execute_main(module_inst, app_argc, app_argv); + exception = wasm_runtime_get_exception(module_inst); + if (exception != NULL) + printf("%s\n", exception); + return NULL; +} + +static char global_heap_buf[GLOBAL_HEAP_BUF_SIZE] = { 0 }; + +void +iwasm_main(void *arg1, void *arg2, void *arg3) +{ + int start = k_uptime_get_32(), end; + uint8 *wasm_file_buf = NULL; + uint32 wasm_file_size; + wasm_module_t wasm_module = NULL; + wasm_module_inst_t wasm_module_inst = NULL; + RuntimeInitArgs init_args; + char error_buf[128]; + int log_verbose_level = 2; + + (void) arg1; + (void) arg2; + (void) arg3; + + memset(&init_args, 0, sizeof(RuntimeInitArgs)); + + init_args.mem_alloc_type = Alloc_With_Pool; + init_args.mem_alloc_option.pool.heap_buf = global_heap_buf; + init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf); + + /* initialize runtime environment */ + if (!wasm_runtime_full_init(&init_args)) { + printf("Init runtime environment failed.\n"); + return; + } + + bh_log_set_verbose_level(log_verbose_level); + + if (!wasm_runtime_register_natives("zephyr:led/driver", + zephyr_native_symbols, + ARRAY_SIZE(zephyr_native_symbols))) { + printf("Failed to register Zephyr native functions.\n"); + goto fail1; + } + + /* load WASM byte buffer from byte buffer of include file */ + wasm_file_buf = (uint8 *)wasm_test_file; + wasm_file_size = sizeof(wasm_test_file); + + /* load WASM module */ + wasm_module = + wasm_runtime_load(wasm_file_buf, + wasm_file_size, + error_buf, + sizeof(error_buf)); + if (!wasm_module) { + printf("%s\n", error_buf); + goto fail1; + } + + /* instantiate the module */ + wasm_module_inst = + wasm_runtime_instantiate(wasm_module, + APP_STACK_SIZE, + APP_HEAP_SIZE, + error_buf, + sizeof(error_buf)); + if (!wasm_module_inst) { + printf("%s\n", error_buf); + goto fail3; + } + + /* invoke the main function */ + app_instance_main(wasm_module_inst); + + /* destroy the module instance */ + wasm_runtime_deinstantiate(wasm_module_inst); + +fail3: + /* unload the module */ + wasm_runtime_unload(wasm_module); + +fail1: + /* destroy runtime environment */ + wasm_runtime_destroy(); + end = k_uptime_get_32(); + printf("elpase: %d\n", (end - start)); +} + +K_THREAD_STACK_DEFINE(iwasm_main_thread_stack, MAIN_THREAD_STACK_SIZE); +static struct k_thread iwasm_main_thread; + +static bool iwasm_init(void) +{ + k_tid_t tid = k_thread_create(&iwasm_main_thread, + iwasm_main_thread_stack, + MAIN_THREAD_STACK_SIZE, + iwasm_main, + NULL, NULL, NULL, + MAIN_THREAD_PRIORITY, + 0, K_NO_WAIT); + return tid ? true : false; +} + +int main(void) +{ + bool success = iwasm_init(); + + return success ? 0 : -1; +} diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/src/test_wasm.h b/samples/modules/wasm_micro_runtime/wasm_blinky/src/test_wasm.h new file mode 100644 index 0000000000000..fcf00c9e45bdb --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/src/test_wasm.h @@ -0,0 +1,89 @@ +unsigned char __aligned(4) wasm_test_file[] = { + 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x1b, 0x05, 0x60, + 0x02, 0x7f, 0x7f, 0x01, 0x7f, 0x60, 0x00, 0x00, 0x60, 0x00, 0x01, 0x7f, + 0x60, 0x01, 0x7f, 0x01, 0x7f, 0x60, 0x04, 0x7f, 0x7f, 0x7f, 0x7f, 0x01, + 0x7f, 0x02, 0x6e, 0x05, 0x03, 0x65, 0x6e, 0x76, 0x07, 0x72, 0x65, 0x61, + 0x6c, 0x6c, 0x6f, 0x63, 0x00, 0x00, 0x03, 0x65, 0x6e, 0x76, 0x05, 0x61, + 0x62, 0x6f, 0x72, 0x74, 0x00, 0x01, 0x11, 0x7a, 0x65, 0x70, 0x68, 0x79, + 0x72, 0x3a, 0x6c, 0x65, 0x64, 0x2f, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, + 0x09, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x00, 0x02, + 0x11, 0x7a, 0x65, 0x70, 0x68, 0x79, 0x72, 0x3a, 0x6c, 0x65, 0x64, 0x2f, + 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x03, 0x73, 0x65, 0x74, 0x00, 0x03, + 0x11, 0x7a, 0x65, 0x70, 0x68, 0x79, 0x72, 0x3a, 0x6c, 0x65, 0x64, 0x2f, + 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x08, 0x73, 0x6c, 0x65, 0x65, 0x70, + 0x2d, 0x6d, 0x73, 0x00, 0x03, 0x03, 0x0b, 0x0a, 0x01, 0x02, 0x00, 0x04, + 0x02, 0x03, 0x03, 0x01, 0x01, 0x01, 0x04, 0x05, 0x01, 0x70, 0x01, 0x01, + 0x01, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x13, 0x03, 0x7f, 0x01, 0x41, + 0x80, 0x28, 0x0b, 0x7f, 0x00, 0x41, 0x80, 0x08, 0x0b, 0x7f, 0x00, 0x41, + 0x80, 0x28, 0x0b, 0x07, 0x41, 0x06, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, + 0x79, 0x02, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x07, 0x0c, 0x63, + 0x61, 0x62, 0x69, 0x5f, 0x72, 0x65, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x00, + 0x08, 0x03, 0x72, 0x75, 0x6e, 0x00, 0x0c, 0x0a, 0x5f, 0x5f, 0x64, 0x61, + 0x74, 0x61, 0x5f, 0x65, 0x6e, 0x64, 0x03, 0x01, 0x0b, 0x5f, 0x5f, 0x68, + 0x65, 0x61, 0x70, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x03, 0x02, 0x0a, 0xf6, + 0x03, 0x0a, 0x89, 0x03, 0x00, 0x02, 0x40, 0x10, 0x89, 0x80, 0x80, 0x80, + 0x00, 0x0d, 0x00, 0x41, 0x01, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, + 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x00, + 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, + 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x01, 0x10, 0x8a, 0x80, 0x80, 0x80, + 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, + 0x41, 0x00, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, + 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x01, 0x10, 0x8a, 0x80, + 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, + 0x00, 0x1a, 0x41, 0x00, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, + 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x01, 0x10, + 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, + 0x80, 0x80, 0x00, 0x1a, 0x41, 0x00, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, + 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, + 0x01, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, + 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x00, 0x10, 0x8a, 0x80, 0x80, + 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, + 0x1a, 0x41, 0x01, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, + 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x00, 0x10, 0x8a, + 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, + 0x80, 0x00, 0x1a, 0x41, 0x01, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, + 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x00, + 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, + 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x01, 0x10, 0x8a, 0x80, 0x80, 0x80, + 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, + 0x41, 0x00, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, + 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x01, 0x10, 0x8a, 0x80, + 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, + 0x00, 0x1a, 0x41, 0x00, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, + 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0x01, 0x10, + 0x8a, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, + 0x80, 0x80, 0x00, 0x1a, 0x41, 0x00, 0x10, 0x8a, 0x80, 0x80, 0x80, 0x00, + 0x1a, 0x41, 0xfa, 0x01, 0x10, 0x8b, 0x80, 0x80, 0x80, 0x00, 0x1a, 0x0b, + 0x0b, 0x0a, 0x00, 0x10, 0x85, 0x80, 0x80, 0x80, 0x00, 0x41, 0x00, 0x0b, + 0x08, 0x00, 0x10, 0x86, 0x80, 0x80, 0x80, 0x00, 0x0b, 0x21, 0x00, 0x02, + 0x40, 0x20, 0x03, 0x45, 0x0d, 0x00, 0x20, 0x00, 0x20, 0x03, 0x10, 0x80, + 0x80, 0x80, 0x80, 0x00, 0x22, 0x02, 0x0d, 0x00, 0x10, 0x81, 0x80, 0x80, + 0x80, 0x00, 0x00, 0x0b, 0x20, 0x02, 0x0b, 0x08, 0x00, 0x10, 0x82, 0x80, + 0x80, 0x80, 0x00, 0x0b, 0x0a, 0x00, 0x20, 0x00, 0x10, 0x83, 0x80, 0x80, + 0x80, 0x00, 0x0b, 0x0a, 0x00, 0x20, 0x00, 0x10, 0x84, 0x80, 0x80, 0x80, + 0x00, 0x0b, 0x08, 0x00, 0x10, 0x85, 0x80, 0x80, 0x80, 0x00, 0x0b, 0x08, + 0x00, 0x10, 0x8e, 0x80, 0x80, 0x80, 0x00, 0x0b, 0x02, 0x00, 0x0b, 0x00, + 0x8b, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, + 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x62, 0x6c, 0x69, 0x6e, 0x6b, 0x00, + 0x61, 0x73, 0x6d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x19, 0x16, 0x77, 0x69, + 0x74, 0x2d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2d, + 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x04, 0x00, 0x07, 0x7e, + 0x01, 0x41, 0x02, 0x01, 0x41, 0x04, 0x01, 0x42, 0x06, 0x01, 0x40, 0x00, + 0x00, 0x7a, 0x04, 0x00, 0x09, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, + 0x72, 0x65, 0x01, 0x00, 0x01, 0x40, 0x01, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x7f, 0x00, 0x7a, 0x04, 0x00, 0x03, 0x73, 0x65, 0x74, 0x01, 0x01, + 0x01, 0x40, 0x01, 0x02, 0x6d, 0x73, 0x79, 0x00, 0x7a, 0x04, 0x00, 0x08, + 0x73, 0x6c, 0x65, 0x65, 0x70, 0x2d, 0x6d, 0x73, 0x01, 0x02, 0x03, 0x00, + 0x11, 0x7a, 0x65, 0x70, 0x68, 0x79, 0x72, 0x3a, 0x6c, 0x65, 0x64, 0x2f, + 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x05, 0x00, 0x01, 0x40, 0x00, 0x01, + 0x00, 0x04, 0x00, 0x03, 0x72, 0x75, 0x6e, 0x01, 0x01, 0x04, 0x00, 0x10, + 0x7a, 0x65, 0x70, 0x68, 0x79, 0x72, 0x3a, 0x6c, 0x65, 0x64, 0x2f, 0x62, + 0x6c, 0x69, 0x6e, 0x6b, 0x04, 0x00, 0x0b, 0x0b, 0x01, 0x00, 0x05, 0x62, + 0x6c, 0x69, 0x6e, 0x6b, 0x03, 0x00, 0x00, 0x00, 0x44, 0x09, 0x70, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x65, 0x72, 0x73, 0x01, 0x0c, 0x70, 0x72, 0x6f, + 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x2d, 0x62, 0x79, 0x02, 0x0d, 0x77, + 0x69, 0x74, 0x2d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, + 0x07, 0x30, 0x2e, 0x32, 0x33, 0x39, 0x2e, 0x30, 0x0d, 0x77, 0x69, 0x74, + 0x2d, 0x62, 0x69, 0x6e, 0x64, 0x67, 0x65, 0x6e, 0x2d, 0x63, 0x06, 0x30, + 0x2e, 0x34, 0x36, 0x2e, 0x30 +}; diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/Makefile b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/Makefile new file mode 100644 index 0000000000000..029c33c5c60a6 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/Makefile @@ -0,0 +1,66 @@ +# Copyright 2024 The Zephyr Authors +# SPDX-License-Identifier: Apache-2.0 + +.PHONY: all bindings embed clean + +WASI_SDK ?= /opt/wasi-sdk +WIT_BINDGEN ?= wit-bindgen +OD ?= od +TR ?= tr +SED ?= sed +AWK ?= awk + +CLANG := $(WASI_SDK)/bin/clang +WIT_WORLD := blink +WIT_FILE := zephyr-led.wit +BINDINGS_DIR := wit-bindgen +WASM_BINARY := test.wasm +HEADER := ../src/test_wasm.h + +WIT_BINDING_SRCS := $(BINDINGS_DIR)/blink.c $(BINDINGS_DIR)/blink_component_type.o +WIT_BINDING_HDRS := $(BINDINGS_DIR)/blink.h +WIT_BINDINGS := $(WIT_BINDING_SRCS) $(WIT_BINDING_HDRS) + +CLANG_FLAGS := -O3 -I$(BINDINGS_DIR) +CLANG_LDFLAGS := \ + -z stack-size=4096 -Wl,--initial-memory=65536 \ + -Wl,--export=main -Wl,--export=__main_argc_argv \ + -Wl,--export=__data_end -Wl,--export=__heap_base \ + -Wl,--strip-all,--no-entry \ + -Wl,--allow-undefined \ + -nostdlib + +all: $(WASM_BINARY) + +bindings: $(WIT_BINDINGS) + +$(BINDINGS_DIR): + mkdir -p $@ + +$(WIT_BINDINGS): $(WIT_FILE) | $(BINDINGS_DIR) + $(WIT_BINDGEN) c --out-dir $(BINDINGS_DIR) --world $(WIT_WORLD) $(WIT_FILE) + +$(WASM_BINARY): main.c $(WIT_BINDINGS) + $(CLANG) $(CLANG_FLAGS) -o $@ main.c $(WIT_BINDING_SRCS) $(CLANG_LDFLAGS) + +embed: $(HEADER) + +$(HEADER): $(WASM_BINARY) + mkdir -p $(dir $(HEADER)) + $(OD) -An -v -tx1 $< | $(TR) -s ' ' '\n' | $(SED) '/^$$/d' | \ + $(AWK) 'BEGIN {print "unsigned char __aligned(4) wasm_test_file[] = {"} \ + {bytes[NR]=$$1} \ + END {for (i=1; i<=NR; ++i) { \ + if ((i-1)%12==0) printf(" "); \ + printf("0x%s", bytes[i]); \ + if (i!=NR) { \ + if (i%12==0) printf(",\\n"); \ + else printf(", "); \ + } else { \ + printf("\\n"); \ + } \ + } print("};");}' > $@ + +clean: + rm -f $(WASM_BINARY) + rm -rf $(BINDINGS_DIR) diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/main.c b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/main.c new file mode 100644 index 0000000000000..efe9ba40556e5 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/main.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include "wit-bindgen/blink.h" + +void exports_blink_run(void) +{ + int32_t ret; + + ret = zephyr_led_driver_configure(); + if (ret != 0) { + return; + } + + for (int i = 0; i < 10; ++i) { + zephyr_led_driver_set(true); + zephyr_led_driver_sleep_ms(250); + zephyr_led_driver_set(false); + zephyr_led_driver_sleep_ms(250); + } +} + +int main(void) +{ + exports_blink_run(); + + return 0; +} diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/wit-bindgen/blink.c b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/wit-bindgen/blink.c new file mode 100644 index 0000000000000..e9bf7d92d55e7 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/wit-bindgen/blink.c @@ -0,0 +1,58 @@ +// Generated by `wit-bindgen` 0.46.0. DO NOT EDIT! +#include "blink.h" +#include + +// Imported Functions from `zephyr:led/driver` + +__attribute__((__import_module__("zephyr:led/driver"), __import_name__("configure"))) +extern int32_t __wasm_import_zephyr_led_driver_configure(void); + +__attribute__((__import_module__("zephyr:led/driver"), __import_name__("set"))) +extern int32_t __wasm_import_zephyr_led_driver_set(int32_t); + +__attribute__((__import_module__("zephyr:led/driver"), __import_name__("sleep-ms"))) +extern int32_t __wasm_import_zephyr_led_driver_sleep_ms(int32_t); + +// Exported Functions from `blink` + + +// Canonical ABI intrinsics + +__attribute__((__weak__, __export_name__("cabi_realloc"))) +void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { + (void) old_size; + if (new_size == 0) return (void*) align; + void *ret = realloc(ptr, new_size); + if (!ret) abort(); + return ret; +} + +// Component Adapters + +int32_t zephyr_led_driver_configure(void) { + int32_t ret = __wasm_import_zephyr_led_driver_configure(); + return ret; +} + +int32_t zephyr_led_driver_set(bool value) { + int32_t ret = __wasm_import_zephyr_led_driver_set(value); + return ret; +} + +int32_t zephyr_led_driver_sleep_ms(uint32_t ms) { + int32_t ret = __wasm_import_zephyr_led_driver_sleep_ms((int32_t) (ms)); + return ret; +} + +__attribute__((__export_name__("run"))) +void __wasm_export_exports_blink_run(void) { + exports_blink_run(); +} + +// Ensure that the *_component_type.o object is linked in + +extern void __component_type_object_force_link_blink(void); +__attribute__((used)) +void __component_type_object_force_link_blink_public_use_in_this_compilation_unit(void) { + __component_type_object_force_link_blink(); +} diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/wit-bindgen/blink.h b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/wit-bindgen/blink.h new file mode 100644 index 0000000000000..009ac1cdaba02 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/wit-bindgen/blink.h @@ -0,0 +1,23 @@ +// Generated by `wit-bindgen` 0.46.0. DO NOT EDIT! +#ifndef __BINDINGS_BLINK_H +#define __BINDINGS_BLINK_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +// Imported Functions from `zephyr:led/driver` +extern int32_t zephyr_led_driver_configure(void); +extern int32_t zephyr_led_driver_set(bool value); +extern int32_t zephyr_led_driver_sleep_ms(uint32_t ms); + +// Exported Functions from `blink` +void exports_blink_run(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/zephyr-led.wit b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/zephyr-led.wit new file mode 100644 index 0000000000000..048252ede30ec --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_blinky/wasm-app/zephyr-led.wit @@ -0,0 +1,12 @@ +package zephyr:led; + +interface driver { + configure: func() -> s32; + set: func(value: bool) -> s32; + sleep-ms: func(ms: u32) -> s32; +} + +world blink { + import driver; + export run: func(); +} diff --git a/samples/modules/wasm_micro_runtime/wasm_hello_world/CMakeLists.txt b/samples/modules/wasm_micro_runtime/wasm_hello_world/CMakeLists.txt new file mode 100644 index 0000000000000..63e91cea6d084 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_hello_world/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(wasm_hello_world) + +target_sources(app PRIVATE src/main.c) diff --git a/samples/modules/wasm_micro_runtime/wasm_hello_world/README.rst b/samples/modules/wasm_micro_runtime/wasm_hello_world/README.rst new file mode 100644 index 0000000000000..13fdcd3b12fa7 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_hello_world/README.rst @@ -0,0 +1,73 @@ +.. _wasm-micro-runtime-wasm_hello_world: + +WebAssembly Micro Runtime Hello World +##################################### + +Overview +******** +The sample project illustrates how to run WebAssembly (WASM) application with +WebAssembly Micro Runtime (WAMR). The WASM application binary is pre-converted into +a byte array defined in test_wasm.h, which is statically linked with the sample. +The WAMR runtime then loads and executes the WASM application binary. + +Building and Running +******************** + +This example can be built in the standard way, +or example with the :zephyr:board:`qemu_x86_nommu` target: + +.. zephyr-app-commands:: + :zephyr-app: samples/modules/wasm_micro_runtime/wasm_hello_world/ + :board: qemu_x86_nommu + :goals: build + +For QEMU target, we can launch with following command. + +.. code-block:: console + + west build -t run + +Sample Output +============= + +.. code-block:: console + + Hello world! + buf ptr: 0x00010018 + buf: 1234 + elpase: 60 + +Build WASM application +********************** + +Install WASI-SDK +================ +Download WASI-SDK from https://github.com/CraneStation/wasi-sdk/releases and extract the archive to default path "/opt/wasi-sdk" + +Build WASM application with WASI-SDK +==================================== + +.. code-block:: console + + cd wasm-app + /opt/wasi-sdk/bin/clang -O3 \ + -z stack-size=4096 -Wl,--initial-memory=65536 \ + -o test.wasm main.c \ + -Wl,--export=main -Wl,--export=__main_argc_argv \ + -Wl,--export=__data_end -Wl,--export=__heap_base \ + -Wl,--strip-all,--no-entry \ + -Wl,--allow-undefined \ + -nostdlib \ + +Dump WASM binary file into byte array file +========================================== + +.. code-block:: console + + cd wasm-app + xxd -i test.wasm > test_wasm.h + +References +********** + + - WAMR sample: https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/product-mini/platforms/zephyr/simple diff --git a/samples/modules/wasm_micro_runtime/wasm_hello_world/boards/nucleo_f767zi.conf b/samples/modules/wasm_micro_runtime/wasm_hello_world/boards/nucleo_f767zi.conf new file mode 100644 index 0000000000000..f065a95957ea6 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_hello_world/boards/nucleo_f767zi.conf @@ -0,0 +1 @@ +CONFIG_ARM_MPU=y diff --git a/samples/modules/wasm_micro_runtime/wasm_hello_world/boards/qemu_cortex_a53.conf b/samples/modules/wasm_micro_runtime/wasm_hello_world/boards/qemu_cortex_a53.conf new file mode 100644 index 0000000000000..6144e0b15bee0 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_hello_world/boards/qemu_cortex_a53.conf @@ -0,0 +1,3 @@ +CONFIG_ARM_MMU=n +#CONFIG_TEST_RANDOM_GENERATOR=y +#CONFIG_TIMER_RANDOM_GENERATOR=y diff --git a/samples/modules/wasm_micro_runtime/wasm_hello_world/prj.conf b/samples/modules/wasm_micro_runtime/wasm_hello_world/prj.conf new file mode 100644 index 0000000000000..c65c1affdf852 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_hello_world/prj.conf @@ -0,0 +1,21 @@ +CONFIG_STACK_SENTINEL=y +CONFIG_PRINTK=y +CONFIG_LOG=y +CONFIG_WAMR=y +CONFIG_WAMR_INTERP=y +CONFIG_WAMR_AOT=y +#CONFIG_WAMR_LIBC_WASI=y +#CONFIG_HEAP_MEM_POOL_SIZE=81292 +#CONFIG_TEST_RANDOM_GENERATOR=y +#CONFIG_NETWORKING=y +#CONFIG_FILE_SYSTEM=y +#CONFIG_POSIX_API=y + + +CONFIG_WAMR_LIB_PTHREAD=y +CONFIG_WAMR_SIMD=y +CONFIG_WAMR_REF_TYPES=y +#CONFIG_WAMR_MEMORY_PROFILING=y +#CONFIG_WAMR_PERF_PROFILING=y +#CONFIG_WAMR_DUMP_CALL_STACK=y + diff --git a/samples/modules/wasm_micro_runtime/wasm_hello_world/src/main.c b/samples/modules/wasm_micro_runtime/wasm_hello_world/src/main.c new file mode 100644 index 0000000000000..c5979db1e4d27 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_hello_world/src/main.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +#include "bh_platform.h" +#include "wasm_export.h" +#include "test_wasm.h" + +#define GLOBAL_HEAP_BUF_SIZE 131072 +#define APP_STACK_SIZE 8192 +#define APP_HEAP_SIZE 8192 + +#ifdef CONFIG_NO_OPTIMIZATIONS +#define MAIN_THREAD_STACK_SIZE 8192 +#else +#define MAIN_THREAD_STACK_SIZE 4096 +#endif + +#define MAIN_THREAD_PRIORITY 5 + +static int app_argc; +static char **app_argv; + +static void* +app_instance_main(wasm_module_inst_t module_inst) +{ + const char *exception; + + wasm_application_execute_main(module_inst, app_argc, app_argv); + exception = wasm_runtime_get_exception(module_inst); + if (exception != NULL) + printf("%s\n", exception); + return NULL; +} + +static char global_heap_buf[GLOBAL_HEAP_BUF_SIZE] = { 0 }; + +void +iwasm_main(void *arg1, void *arg2, void *arg3) +{ + int start = k_uptime_get_32(), end; + uint8 *wasm_file_buf = NULL; + uint32 wasm_file_size; + wasm_module_t wasm_module = NULL; + wasm_module_inst_t wasm_module_inst = NULL; + RuntimeInitArgs init_args; + char error_buf[128]; + int log_verbose_level = 2; + + (void) arg1; + (void) arg2; + (void) arg3; + + memset(&init_args, 0, sizeof(RuntimeInitArgs)); + + init_args.mem_alloc_type = Alloc_With_Pool; + init_args.mem_alloc_option.pool.heap_buf = global_heap_buf; + init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf); + + /* initialize runtime environment */ + if (!wasm_runtime_full_init(&init_args)) { + printf("Init runtime environment failed.\n"); + return; + } + + bh_log_set_verbose_level(log_verbose_level); + + /* load WASM byte buffer from byte buffer of include file */ + wasm_file_buf = (uint8 *)wasm_test_file; + wasm_file_size = sizeof(wasm_test_file); + + /* load WASM module */ + wasm_module = + wasm_runtime_load(wasm_file_buf, + wasm_file_size, + error_buf, + sizeof(error_buf)); + if (!wasm_module) { + printf("%s\n", error_buf); + goto fail1; + } + + /* instantiate the module */ + wasm_module_inst = + wasm_runtime_instantiate(wasm_module, + APP_STACK_SIZE, + APP_HEAP_SIZE, + error_buf, + sizeof(error_buf)); + if (!wasm_module_inst) { + printf("%s\n", error_buf); + goto fail3; + } + + /* invoke the main function */ + app_instance_main(wasm_module_inst); + + /* destroy the module instance */ + wasm_runtime_deinstantiate(wasm_module_inst); + +fail3: + /* unload the module */ + wasm_runtime_unload(wasm_module); + +fail1: + /* destroy runtime environment */ + wasm_runtime_destroy(); + end = k_uptime_get_32(); + printf("elpase: %d\n", (end - start)); +} + +K_THREAD_STACK_DEFINE(iwasm_main_thread_stack, MAIN_THREAD_STACK_SIZE); +static struct k_thread iwasm_main_thread; + +static bool iwasm_init(void) +{ + k_tid_t tid = k_thread_create(&iwasm_main_thread, + iwasm_main_thread_stack, + MAIN_THREAD_STACK_SIZE, + iwasm_main, + NULL, NULL, NULL, + MAIN_THREAD_PRIORITY, + 0, K_NO_WAIT); + return tid ? true : false; +} + +int main(void) +{ + bool success = iwasm_init(); + + return success ? 0 : -1; +} diff --git a/samples/modules/wasm_micro_runtime/wasm_hello_world/src/test_wasm.h b/samples/modules/wasm_micro_runtime/wasm_hello_world/src/test_wasm.h new file mode 100644 index 0000000000000..1226134cda9df --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_hello_world/src/test_wasm.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +unsigned char __aligned(4) wasm_test_file[] = { + 0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x10, 0x03, 0x60, + 0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x01, + 0x7F, 0x00, 0x02, 0x31, 0x04, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x70, 0x75, + 0x74, 0x73, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x61, 0x6C, + 0x6C, 0x6F, 0x63, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x70, 0x72, + 0x69, 0x6E, 0x74, 0x66, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x66, + 0x72, 0x65, 0x65, 0x00, 0x02, 0x03, 0x02, 0x01, 0x01, 0x04, 0x05, 0x01, + 0x70, 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x07, 0x01, + 0x7F, 0x01, 0x41, 0xC0, 0x28, 0x0B, 0x07, 0x11, 0x02, 0x06, 0x6D, 0x65, + 0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x04, 0x6D, 0x61, 0x69, 0x6E, 0x00, + 0x04, 0x0A, 0xB2, 0x01, 0x01, 0xAF, 0x01, 0x01, 0x03, 0x7F, 0x23, 0x80, + 0x80, 0x80, 0x80, 0x00, 0x41, 0x20, 0x6B, 0x22, 0x02, 0x24, 0x80, 0x80, + 0x80, 0x80, 0x00, 0x41, 0x9B, 0x88, 0x80, 0x80, 0x00, 0x10, 0x80, 0x80, + 0x80, 0x80, 0x00, 0x1A, 0x02, 0x40, 0x02, 0x40, 0x41, 0x80, 0x08, 0x10, + 0x81, 0x80, 0x80, 0x80, 0x00, 0x22, 0x03, 0x0D, 0x00, 0x41, 0xA8, 0x88, + 0x80, 0x80, 0x00, 0x10, 0x80, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x41, 0x7F, + 0x21, 0x04, 0x0C, 0x01, 0x0B, 0x20, 0x02, 0x20, 0x03, 0x36, 0x02, 0x10, + 0x41, 0x80, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x41, 0x10, 0x6A, 0x10, + 0x82, 0x80, 0x80, 0x80, 0x00, 0x1A, 0x41, 0x00, 0x21, 0x04, 0x20, 0x03, + 0x41, 0x04, 0x6A, 0x41, 0x00, 0x2F, 0x00, 0x91, 0x88, 0x80, 0x80, 0x00, + 0x3B, 0x00, 0x00, 0x20, 0x03, 0x41, 0x00, 0x28, 0x00, 0x8D, 0x88, 0x80, + 0x80, 0x00, 0x36, 0x00, 0x00, 0x20, 0x02, 0x20, 0x03, 0x36, 0x02, 0x00, + 0x41, 0x93, 0x88, 0x80, 0x80, 0x00, 0x20, 0x02, 0x10, 0x82, 0x80, 0x80, + 0x80, 0x00, 0x1A, 0x20, 0x03, 0x10, 0x83, 0x80, 0x80, 0x80, 0x00, 0x0B, + 0x20, 0x02, 0x41, 0x20, 0x6A, 0x24, 0x80, 0x80, 0x80, 0x80, 0x00, 0x20, + 0x04, 0x0B, 0x0B, 0x41, 0x01, 0x00, 0x41, 0x80, 0x08, 0x0B, 0x3A, 0x62, + 0x75, 0x66, 0x20, 0x70, 0x74, 0x72, 0x3A, 0x20, 0x25, 0x70, 0x0A, 0x00, + 0x31, 0x32, 0x33, 0x34, 0x0A, 0x00, 0x62, 0x75, 0x66, 0x3A, 0x20, 0x25, + 0x73, 0x00, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, + 0x64, 0x21, 0x00, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x20, 0x62, 0x75, + 0x66, 0x20, 0x66, 0x61, 0x69, 0x6C, 0x65, 0x64, 0x00 +}; diff --git a/samples/modules/wasm_micro_runtime/wasm_hello_world/wasm-app/main.c b/samples/modules/wasm_micro_runtime/wasm_hello_world/wasm-app/main.c new file mode 100644 index 0000000000000..0db94697b208e --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_hello_world/wasm-app/main.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +int main(int argc, char **argv) +{ + char *buf; + + printf("Hello world!\n"); + + buf = malloc(1024); + if (!buf) { + printf("malloc buf failed\n"); + return -1; + } + + printf("buf ptr: %p\n", buf); + + snprintf(buf, 1024, "%s", "1234\n"); + printf("buf: %s", buf); + + free(buf); + return 0; +} diff --git a/samples/modules/wasm_micro_runtime/wasm_micro_runtime.rst b/samples/modules/wasm_micro_runtime/wasm_micro_runtime.rst new file mode 100644 index 0000000000000..24f45ea56b3f1 --- /dev/null +++ b/samples/modules/wasm_micro_runtime/wasm_micro_runtime.rst @@ -0,0 +1,10 @@ +.. _wasm_micro_runtime: + +WebAssembly Micro Runtime (WAMR) Samples +######################################## + +.. toctree:: + :maxdepth: 1 + :glob: + + **/* diff --git a/west.yml b/west.yml index 7505a16302b40..5b38677cc9b14 100644 --- a/west.yml +++ b/west.yml @@ -23,6 +23,8 @@ manifest: url-base: https://github.com/zephyrproject-rtos - name: babblesim url-base: https://github.com/BabbleSim + - name: bytecodealliance + url-base: https://github.com/bytecodealliance group-filter: [-babblesim, -optional] @@ -376,6 +378,10 @@ manifest: - name: uoscore-uedhoc revision: 54abc109c9c0adfd53c70077744c14e454f04f4a path: modules/lib/uoscore-uedhoc + - name: wasm-micro-runtime + remote: bytecodealliance + revision: 3f4145e6914d5cfc717a257aa660605490f26908 + path: modules/lib/wasm-micro-runtime - name: zcbor revision: 9b07780aca6fb21f82a241ba386ad9b379809337 path: modules/lib/zcbor