Skip to content

Commit

Permalink
Add WAMR support for Zephyr build
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffMboya committed Jan 10, 2025
1 parent 4205366 commit 65cc048
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
45 changes: 40 additions & 5 deletions embed-proplet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,50 @@ set(BOARD esp32s3_devkitc)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(proplet_mqtt_client)

include_directories(${ZEPHYR_BASE}/include/zephyr)
set(WAMR_BUILD_PLATFORM "zephyr")
set(WAMR_BUILD_TARGET "XTENSA")

if (NOT DEFINED WAMR_BUILD_INTERP)
set(WAMR_BUILD_INTERP 1)
endif ()

if (NOT DEFINED WAMR_BUILD_AOT)
set(WAMR_BUILD_AOT 1)
endif ()

if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
set(WAMR_BUILD_LIBC_BUILTIN 1)
endif ()

# Disable libc wasi support by default. In the future,
# it can be enabled if libc wasi file/socket/lock support is ready on Zephyr platform
if (NOT DEFINED WAMR_BUILD_LIBC_WASI)
set(WAMR_BUILD_LIBC_WASI 0)
endif ()

set(WAMR_BUILD_GLOBAL_HEAP_POOL 1)
if (NOT DEFINED WAMR_BUILD_GLOBAL_HEAP_SIZE)
set(WAMR_BUILD_GLOBAL_HEAP_SIZE 40960)
endif ()

list(APPEND ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/modules/wamr/wasm-micro-runtime/product-mini/platforms/zephyr)
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/modules/wamr/wasm-micro-runtime)
include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)

# Add WAMR include paths
target_include_directories(app PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/modules/wamr/wasm-micro-runtime/core/iwasm/include
list(APPEND ZEPHYR_EXTRA_MODULES ${WAMR_ROOT_DIR}/product-mini/platforms/zephyr)

include_directories(${ZEPHYR_BASE}/include/zephyr)

target_include_directories(app PRIVATE
${WAMR_ROOT_DIR}/core/iwasm/include
)

# Embed WAMR as a Zephyr library
zephyr_library_named(wamr_lib)

zephyr_library_sources(${WAMR_RUNTIME_LIB_SOURCE})

zephyr_library_app_memory(wamr_partition)

target_sources(app PRIVATE src/main.c src/wasm_handler.c)

target_link_libraries(app PRIVATE wamr_lib)
2 changes: 1 addition & 1 deletion embed-proplet/modules/wamr/wasm-micro-runtime
8 changes: 6 additions & 2 deletions embed-proplet/prj.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CONFIG_USERSPACE=y
CONFIG_STACK_SENTINEL=y

CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=16384

CONFIG_THREAD_RUNTIME_STATS=y

CONFIG_WIFI=y
CONFIG_WIFI_CREDENTIALS_STATIC=y
CONFIG_WIFI_CREDENTIALS_STATIC_SSID="Nakuja"
Expand All @@ -16,9 +17,12 @@ CONFIG_NET_DHCPV4=y
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y

CONFIG_PRINTK=y
CONFIG_LOG=y
CONFIG_LOG_BUFFER_SIZE=8096
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_THREAD_RUNTIME_STATS=y

CONFIG_JSON_LIBRARY=y

Expand Down

0 comments on commit 65cc048

Please sign in to comment.