Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROP-6 - Deploy WAMR on Zephyr RTOS #48

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3e56f63
Initial commit
JeffMboya Jan 9, 2025
ae36a48
Update submodule wasm-micro-runtime to latest commit
JeffMboya Jan 9, 2025
eaa22f4
Force shared library off if building for Zephyr
JeffMboya Jan 9, 2025
3a304ef
Force shared library off if building for Zephyr
JeffMboya Jan 9, 2025
85d5bd2
Fix autoconf.h not found
JeffMboya Jan 9, 2025
4f9b7b6
Refactor mqtt client
JeffMboya Jan 9, 2025
28ef9b8
Fix dependencies
JeffMboya Jan 9, 2025
4186be7
Add WAMR support for Zephyr build
JeffMboya Jan 10, 2025
e47cd34
Handle CONFIG_COMMON_LIBC_ABORT conflicts for Zephyr
JeffMboya Jan 10, 2025
80bf5fe
Fix Wi-Fi struct and function usage errors
JeffMboya Jan 10, 2025
6132ca0
Fix null network interface
JeffMboya Jan 10, 2025
f249964
Fix Wi-Fi not in station mode
JeffMboya Jan 12, 2025
1cad335
Add logging config documentation
JeffMboya Jan 12, 2025
04cd2f7
Update proj.cof
JeffMboya Jan 12, 2025
44340cd
Update proj.cof
JeffMboya Jan 12, 2025
16bf8cf
Enable thread analyzer
JeffMboya Jan 12, 2025
734f062
Fix STA mode
JeffMboya Jan 13, 2025
c3464e6
Increase stack sizes
JeffMboya Jan 13, 2025
939a281
modularize network; add mqtt client
JeffMboya Jan 13, 2025
802445d
Fix undefined error in mqtt implemetation
JeffMboya Jan 13, 2025
397ccc3
move mqtt initialization after network connection
JeffMboya Jan 13, 2025
fdbfcb8
synchronize the Wi-Fi connection status between the wifi_manager.c an…
JeffMboya Jan 13, 2025
5539203
Add mqtt config
JeffMboya Jan 13, 2025
d372b43
Fix mqtt client initialization error
JeffMboya Jan 13, 2025
706dcc1
Rename test channel and propled ID
JeffMboya Jan 13, 2025
a29e64e
Connect to local mqtt broker
JeffMboya Jan 13, 2025
b9230f5
Increase CONFIG_MQTT_KEEPALIVE
JeffMboya Jan 14, 2025
a716f37
Add polling for sockets
JeffMboya Jan 14, 2025
489a2f0
Fix failed Proplet discovery and keep alive publishing
JeffMboya Jan 14, 2025
1755517
Handle missing mqtt events
JeffMboya Jan 15, 2025
f5475e0
Add missing sub/pub methods
JeffMboya Jan 15, 2025
689f000
Fix errors due to added missing sub/pub methods
JeffMboya Jan 15, 2025
2a429d7
Fix dram0_0_seg overflow
JeffMboya Jan 15, 2025
81d110f
Add LWT
JeffMboya Jan 15, 2025
6843f42
Remove duplicate logging
JeffMboya Jan 15, 2025
0b3b381
Remove binary chunk assembly logic
JeffMboya Jan 15, 2025
f0235b7
Remove binary chunk assembly logic
JeffMboya Jan 15, 2025
3889bd1
Fix runtime errors
JeffMboya Jan 16, 2025
896cf1c
Replace function_name with app_name
JeffMboya Jan 16, 2025
b1698fa
Add wasm binary handlers
JeffMboya Jan 16, 2025
8231e9e
increase MQTT processing frequency
JeffMboya Jan 16, 2025
9a3fc51
Remove extra fields
JeffMboya Jan 21, 2025
363b921
Fix comments
JeffMboya Jan 21, 2025
62579b9
encode decoded json for validation
JeffMboya Jan 21, 2025
679e064
switch from zephyr JSON to cJSON
JeffMboya Jan 21, 2025
87a28f4
Increase logger buffer size
JeffMboya Jan 21, 2025
bdf402d
Remove extra comments
JeffMboya Jan 21, 2025
d9020b7
Add execution env
JeffMboya Jan 21, 2025
4aaeca4
Get results from exec env
JeffMboya Jan 21, 2025
3607638
Publish results back to manager
JeffMboya Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "embed-proplet/modules/wamr/wasm-micro-runtime"]
path = embed-proplet/modules/wamr/wasm-micro-runtime
url = https://github.com/bytecodealliance/wasm-micro-runtime.git
54 changes: 54 additions & 0 deletions embed-proplet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.20.0)

set(BOARD esp32s3_devkitc)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(proplet_mqtt_client)

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 ()

set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/modules/wamr/wasm-micro-runtime)
include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)

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/cJSON.c src/main.c src/mqtt_client.c src/wasm_handler.c src/wifi_manager.c)

target_link_libraries(app PRIVATE wamr_lib)
8 changes: 8 additions & 0 deletions embed-proplet/boards/esp32s3_devkitc_procpu.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ESP32 Wi-Fi Configuration
CONFIG_WIFI_ESP32=y
CONFIG_ESP32_WIFI_STA_RECONNECT=y
CONFIG_ESP32_WIFI_STA_AUTO_DHCPV4=y
CONFIG_ESP32_WIFI_AP_STA_MODE=n
CONFIG_ESP32_WIFI_DEBUG_PRINT=y


3 changes: 3 additions & 0 deletions embed-proplet/boards/esp32s3_devkitc_procpu.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
&wifi {
status = "okay";
};
63 changes: 63 additions & 0 deletions embed-proplet/modules/wamr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# modules/wamr/CMakeLists.txt
#

cmake_minimum_required(VERSION 3.20)

#
# Force WAMR to treat this build as Zephyr + Xtensa
# (Adjust target name if needed: "XTENSA", "esp32", etc.)
#
set(WAMR_BUILD_PLATFORM "zephyr" CACHE STRING "" FORCE)
set(WAMR_BUILD_TARGET "XTENSA" CACHE STRING "" FORCE)

#
# Minimal build settings
#
set(WAMR_BUILD_INTERP 1 CACHE BOOL "Enable WAMR interpreter" FORCE)
set(WAMR_BUILD_AOT 0 CACHE BOOL "Disable AOT" FORCE)
set(WAMR_BUILD_JIT 0 CACHE BOOL "Disable JIT" FORCE)
set(WAMR_BUILD_FAST_INTERP 1 CACHE BOOL "Enable fast interpreter" FORCE)
set(WAMR_BUILD_LIBC_BUILTIN 1 CACHE BOOL "Enable builtin libc" FORCE)
set(WAMR_BUILD_LIBC_WASI 1 CACHE BOOL "Enable WASI libc" FORCE)

# Disable pthread library in WAMR
set(WAMR_BUILD_LIB_PTHREAD 0 CACHE BOOL "" FORCE)

#
# Optional features you can uncomment if desired:
#
# set(WAMR_BUILD_MULTI_MODULE 1 CACHE BOOL "Enable multiple modules" FORCE)
# set(WAMR_BUILD_LIB_WASI_THREADS 1 CACHE BOOL "Enable WASI threads library" FORCE)

#
# Add the official WAMR subdirectory
#
add_subdirectory(wasm-micro-runtime
${CMAKE_CURRENT_BINARY_DIR}/wamr_build
)

#
# If iwasm_static is created by the WAMR build, force it to include Zephyr's paths
#
if(TARGET iwasm_static)
message(STATUS "WAMR: Forcing Zephyr includes for iwasm_static")

# Typically, Zephyr sets $ENV{ZEPHYR_BASE} or uses a CMake variable.
# We'll assume $ENV{ZEPHYR_BASE} is defined. Adjust if needed.
target_include_directories(iwasm_static PRIVATE
$ENV{ZEPHYR_BASE}/include
# If you need more subfolders, uncomment or add them here:
# $ENV{ZEPHYR_BASE}/include/zephyr
# $ENV{ZEPHYR_BASE}/subsys
)
endif()

#
# Provide a function for linking WAMR to the Zephyr 'app' target.
# WAMR typically builds a static library named 'vmlib',
# output from 'iwasm_static' with OUTPUT_NAME vmlib.
#
function(link_wamr_to_zephyr TARGET)
target_link_libraries(${TARGET} PRIVATE vmlib)
endfunction()
1 change: 1 addition & 0 deletions embed-proplet/modules/wamr/wasm-micro-runtime
Submodule wasm-micro-runtime added at a18f36
95 changes: 95 additions & 0 deletions embed-proplet/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# General Networking
CONFIG_WIFI=y
CONFIG_WIFI_NM=y
CONFIG_NET_MGMT=y
CONFIG_NETWORKING=y
CONFIG_NET_CONFIG_AUTO_INIT=n
CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_MGMT_EVENT_INFO=y
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=10
CONFIG_NET_MGMT_EVENT_STACK_SIZE=4096
CONFIG_NET_MGMT_EVENT_QUEUE_TIMEOUT=5000

# Protocols
CONFIG_NET_DHCPV4=y
CONFIG_NET_DHCPV4_SERVER=y
CONFIG_NET_IPV4=y
# Uncomment to enable IPv6
# CONFIG_NET_IPV6=y
CONFIG_NET_TCP=y
CONFIG_NET_UDP=y

# Interface Configuration
CONFIG_NET_IF_MAX_IPV4_COUNT=2
# required only if NET_IPV6 is set
# CONFIG_NET_IF_MAX_IPV6_COUNT=2
CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_L2_WIFI_MGMT=y
CONFIG_WIFI_NM_MAX_MANAGED_INTERFACES=2

# Buffer and Packet Management
CONFIG_NET_BUF_RX_COUNT=64
CONFIG_NET_BUF_TX_COUNT=64
CONFIG_NET_BUF_DATA_SIZE=256
CONFIG_NET_PKT_RX_COUNT=32
CONFIG_NET_PKT_TX_COUNT=32
CONFIG_NET_RX_STACK_SIZE=2048
CONFIG_NET_TX_STACK_SIZE=2048
CONFIG_NET_MAX_CONTEXTS=10

# MQTT Client
CONFIG_MQTT_LIB=y
# Enable Sockets (used by MQTT lib)
CONFIG_NET_SOCKETS=y

# Uncomment to enable TLS support for socket MQTT Library.
# CONFIG_MQTT_LIB_TLS=y
CONFIG_MQTT_KEEPALIVE=30
CONFIG_MQTT_CLEAN_SESSION=n
CONFIG_MQTT_LIB_WEBSOCKET=n
# Uncomment to enable ALPN protocol for socket MQTT Library.
# CONFIG_MQTT_LIB_TLS_USE_ALPN=y

# JSON Parsing
# CONFIG_JSON_LIBRARY=y
# Note: Zephyr's JSON library has been replaced by cJSON for JSON parsing and encoding.
# Uncomment the line above only if reverting to the Zephyr JSON library is necessary.

# Logging
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_LOG_MODE_DEFERRED=n
# Uncomment to enable debug logs for mqtt, networking stack, Wi-Fi operations, and DHCPv4 server component.
# CONFIG_MQTT_LOG_LEVEL_DBG=y
# CONFIG_NET_LOG=y
# CONFIG_WIFI_LOG_LEVEL_DBG=y
# CONFIG_NET_DHCPV4_SERVER_LOG_LEVEL_DBG=y

# Debugging and Early Boot
CONFIG_EARLY_CONSOLE=y
CONFIG_INIT_STACKS=y
CONFIG_STACK_SENTINEL=y

# Statistics and Diagnostics
CONFIG_NET_STATISTICS=y
CONFIG_NET_STATISTICS_PERIODIC_OUTPUT=n

# Thread Analyzer
# Uncomment to debug thread-related issues.
# CONFIG_THREAD_NAME=y
# CONFIG_THREAD_ANALYZER=y
# CONFIG_THREAD_ANALYZER_AUTO=y
# CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
# CONFIG_THREAD_ANALYZER_LOG_LEVEL_DBG=y
# CONFIG_THREAD_ANALYZER_ISR_STACK_USAGE=y

# Miscellaneous
CONFIG_BASE64=y
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_IDLE_STACK_SIZE=2048
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096
CONFIG_DYNAMIC_THREAD_STACK_SIZE=4096
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_NET_SOCKETS_SERVICE_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=65536
Loading
Loading