mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/wamr: improve makefile and doc
This commit is contained in:
parent
51c94a1217
commit
57e380d173
@ -28,9 +28,15 @@ RIOT_INCLUDES = $(filter-out -%,$(subst -I,,$(INCLUDES)))
|
||||
#no msp430, no AVR support for now
|
||||
|
||||
ifeq ($(CPU),native)
|
||||
#$(CPU) is defined for every CPU
|
||||
#everyone build on x86_32
|
||||
ifeq ($(findstring x86,$(OS_ARCH)),x86)
|
||||
WAMR_BUILD_TARGET = X86_32
|
||||
endif
|
||||
ifeq ($(findstring arm,$(OS_ARCH)),arm)
|
||||
WAMR_BUILD_TARGET = ARM
|
||||
endif
|
||||
ifeq ($(findstring aarch,$(OS_ARCH)),aarch)
|
||||
WAMR_BUILD_TARGET = ARM
|
||||
endif
|
||||
else ifeq ($(findstring arm,$(CPU_ARCH)),arm)
|
||||
WAMR_BUILD_TARGET = THUMB
|
||||
else ifeq ($(CPU_ARCH),mips32r2)
|
||||
@ -39,6 +45,8 @@ else ifeq ($(CPU_ARCH),xtensa)
|
||||
WAMR_BUILD_TARGET = XTENSA
|
||||
else ifeq ($(CPU_ARCH),rv32)
|
||||
WAMR_BUILD_TARGET = RISCV32
|
||||
else
|
||||
$(error "WASM is not supported for architecture $(CPU_ARCH)")
|
||||
endif
|
||||
|
||||
ifeq ($(QUIET),0)
|
||||
@ -57,6 +65,7 @@ WAMR_CMAKE_FLAGS += "-DRIOT_INCLUDES=$(RIOT_INCLUDES)"\
|
||||
-DCMAKE_SYSTEM_PROCESSOR="$(MCPU)" \
|
||||
-DCMAKE_C_COMPILER=$(CC) \
|
||||
-DCMAKE_C_COMPILER_WORKS=TRUE \
|
||||
#
|
||||
|
||||
all: $(BINDIR)/libwamr.a
|
||||
|
||||
@ -71,6 +80,7 @@ $(PKG_BUILD_DIR)/Makefile: $(PKG_PREPARED) print_build_target
|
||||
|
||||
print_build_target:
|
||||
@echo PKG_VERSION: $(PKG_VERSION)
|
||||
@echo native OS_ARCH: $(OS_ARCH)
|
||||
@echo CPU_ARCH: $(CPU_ARCH)
|
||||
@echo CPU: $(CPU)
|
||||
@echo CFLAGS: $(CFLAGS)
|
||||
|
@ -1,5 +1,4 @@
|
||||
USEMODULE += sema
|
||||
|
||||
#WAMR supports "X86_32/64", "AARCH64", "ARM", "THUMB", "MIPS" and "XTENSA"
|
||||
#no 8/16 Bit TODO: might need to blacklist more
|
||||
FEATURES_BLACKLIST += arch_8bit arch_16bit
|
||||
#WAMR supports "X86_32/64", "AARCH64", "ARM", "THUMB", "MIPS", "XTENSA" and RISCV
|
||||
FEATURES_REQUIRED_ANY += arch_native|arch_arm|arch_mips32r2|arch_esp32|arch_riscv
|
||||
|
@ -1,10 +1,11 @@
|
||||
IWASM_CORE = $(PKGDIRBASE)/wamr/core
|
||||
IWASM_ROOT = $(IWASM_CORE)/iwasm
|
||||
SHARED_LIB_ROOT = $(IWASM_CORE)/shared
|
||||
IWASM_CORE := $(PKGDIRBASE)/wamr/core
|
||||
IWASM_ROOT := $(IWASM_CORE)/iwasm
|
||||
SHARED_LIB_ROOT := $(IWASM_CORE)/shared
|
||||
|
||||
IWASM_INCLUDES += ${IWASM_ROOT}/include \
|
||||
${SHARED_LIB_ROOT}/platform/include \
|
||||
${SHARED_LIB_ROOT}/platform/riot \
|
||||
#
|
||||
|
||||
INCLUDES += $(addprefix -I,${IWASM_INCLUDES})
|
||||
|
||||
|
@ -3,4 +3,65 @@
|
||||
* @ingroup pkg
|
||||
* @brief Provides WebAssembly support for RIOT
|
||||
* @see https://github.com/bytecodealliance/wasm-micro-runtime
|
||||
*
|
||||
* # WebAssembly Micro Runtime Riot Package
|
||||
*
|
||||
* "WebAssembly Micro Runtime (WAMR) is a standalone WebAssembly (WASM)
|
||||
* runtime with a small footprint."
|
||||
*
|
||||
* @see https://github.com/bytecodealliance/wasm-micro-runtime
|
||||
*
|
||||
* ## Status
|
||||
*
|
||||
* WAMR integration into RIOT should be considered experimental.
|
||||
* Changes that had to be done in WAMR are send to and integrated into upstream.
|
||||
* WAMR provides support for numerous architectures:
|
||||
*
|
||||
* "X86_32", "AARCH64", "ARM", "THUMB", "MIPS", "XTENSA" and "RISCV"
|
||||
* tested : Cortex-M - "THUMB", native - "X86_32"
|
||||
*
|
||||
* ## Memory usage
|
||||
*
|
||||
* WebAssembly defines its pages to be 64kB -> WAMR needs a good amount of RAM to run.
|
||||
*
|
||||
* WASM files can be linked to use just a part of the first page.
|
||||
* In this case the VM can be run with less ram.
|
||||
* (see `wasm_sample/Makefile` in `examples/wasm` for linker options to help with this)
|
||||
* While running the example configured with 8KiB Heap and 8KiB Stack,
|
||||
* ~24KiB of System Heap are used.
|
||||
* The thread, the WAMR interpreter (iwasm) is executed in,
|
||||
* should be configured to have more than 3KiB of Stack,
|
||||
* this also depend on the architecture and the native functions that are called.
|
||||
*
|
||||
* ## building wasm-bytecode
|
||||
*
|
||||
* `clang` and `wasm-ld` of the *same version* must be used
|
||||
* The Makefile in `examples/wasm/wasm_sample/Makefile` will try to guess
|
||||
* a matching clang, wasm-ld pair, if they do not match linking will fail.
|
||||
*
|
||||
* ## Configuration
|
||||
*
|
||||
* WAMR compilation is configured using a CMAKE config file (see `pkg/wamr/config.cmake`)
|
||||
* Add `export WAMR_CONFIG := $(abspath config.cmake)` to Makefile to apply a specific config.
|
||||
* Most options (e.g. WASI) are not supported in RIOT since they have OS requirements,
|
||||
* that are no yet fulfilled.
|
||||
*
|
||||
* ## Details
|
||||
*
|
||||
* WAMR should be used using the functions provided by the WAMR project their API-headers
|
||||
* can be found in `<RIOT>/build/pkg/wamr/core/iwasm/include/`.
|
||||
* See the example in `examples/wasm` there are currently no riot specialities provided.
|
||||
* For simple usages like in the example `iwasm.c` in `examples/wasm` might be useful and
|
||||
* if used should be copied in case.
|
||||
*
|
||||
* While WebAssembly does not define a set native functions. WAMR provides its own builtin-libc.
|
||||
* Other native functions may be provided by registering native_api to WAMR.
|
||||
* @see https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/export_native_api.md
|
||||
*
|
||||
* ## Upstream Documentation
|
||||
*
|
||||
* @see https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/README.md
|
||||
* @see https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/doc
|
||||
* @see https://github.com/bytecodealliance/wasm-micro-runtime/wiki
|
||||
*
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user