diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c87994945..469813f9ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,11 @@ cmake_minimum_required (VERSION 3.0) +if(ESP_PLATFORM) + include (${COMPONENT_DIR}/build-scripts/esp-idf/wamr/CMakeLists.txt) + return() +endif() + project (iwasm) set (CMAKE_VERBOSE_MAKEFILE OFF) diff --git a/core/shared/platform/esp-idf/espidf_memmap.c b/core/shared/platform/esp-idf/espidf_memmap.c index 9f3ec47a6a..d8f506cccc 100644 --- a/core/shared/platform/esp-idf/espidf_memmap.c +++ b/core/shared/platform/esp-idf/espidf_memmap.c @@ -27,26 +27,20 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) #else uint32_t mem_caps = MALLOC_CAP_EXEC; #endif + char *ptr; // Memory allocation with MALLOC_CAP_EXEC will return 4-byte aligned // Reserve extra 4 byte to fixup alignment and size for the pointer to // the originally allocated address - void *buf_origin = - heap_caps_malloc(size + 4 + sizeof(uintptr_t), mem_caps); - if (!buf_origin) { + ptr = heap_caps_malloc(size, mem_caps); + if (!ptr) { return NULL; } - void *buf_fixed = buf_origin + sizeof(void *); - if ((uintptr_t)buf_fixed & (uintptr_t)0x7) { - buf_fixed = (void *)((uintptr_t)(buf_fixed + 4) & (~(uintptr_t)7)); - } - uintptr_t *addr_field = buf_fixed - sizeof(uintptr_t); - *addr_field = (uintptr_t)buf_origin; #if (WASM_MEM_DUAL_BUS_MIRROR != 0) - return buf_fixed + MEM_DUAL_BUS_OFFSET; + return ptr + MEM_DUAL_BUS_OFFSET; #else - return buf_fixed; + return ptr; #endif } else { @@ -71,7 +65,7 @@ os_munmap(void *addr, size_t size) #endif // We don't need special handling of the executable allocations // here, free() of esp-idf handles it properly - return os_free(ptr); + return heap_caps_free(ptr); } int diff --git a/idf_component.yml b/idf_component.yml new file mode 100644 index 0000000000..678bf5deaf --- /dev/null +++ b/idf_component.yml @@ -0,0 +1,8 @@ +version: "1.3.2-1" +description: WebAssembly Micro Runtime - A lightweight standalone WebAssembly (Wasm) runtime with small footprint, high performance and highly configurable features +url: https://bytecodealliance.org/ +repository: https://github.com/bytecodealliance/wasm-micro-runtime.git +documentation: https://wamr.gitbook.io/ +issues: https://github.com/bytecodealliance/wasm-micro-runtime/issues +dependencies: + idf: ">=4.4" \ No newline at end of file diff --git a/product-mini/platforms/esp-idf/CMakeLists.txt b/product-mini/platforms/esp-idf/CMakeLists.txt index d8a3d2f96c..8472df8dd8 100644 --- a/product-mini/platforms/esp-idf/CMakeLists.txt +++ b/product-mini/platforms/esp-idf/CMakeLists.txt @@ -6,7 +6,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set (COMPONENTS ${IDF_TARGET} main freertos esptool_py wamr) -list(APPEND EXTRA_COMPONENT_DIRS "$ENV{WAMR_PATH}/build-scripts/esp-idf") - project(wamr-simple) \ No newline at end of file diff --git a/product-mini/platforms/esp-idf/main/CMakeLists.txt b/product-mini/platforms/esp-idf/main/CMakeLists.txt index 55e7256704..1bb61bad94 100644 --- a/product-mini/platforms/esp-idf/main/CMakeLists.txt +++ b/product-mini/platforms/esp-idf/main/CMakeLists.txt @@ -2,5 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception idf_component_register(SRCS "main.c" - INCLUDE_DIRS "." - REQUIRES wamr) + INCLUDE_DIRS ".") diff --git a/product-mini/platforms/esp-idf/main/idf_component.yml b/product-mini/platforms/esp-idf/main/idf_component.yml new file mode 100644 index 0000000000..27325e7631 --- /dev/null +++ b/product-mini/platforms/esp-idf/main/idf_component.yml @@ -0,0 +1,7 @@ +## IDF Component Manager Manifest File +dependencies: + wasm-micro-runtime: + version: "^1.3" + override_path: "../../../.." + idf: + version: ">=4.4" \ No newline at end of file diff --git a/product-mini/platforms/esp-idf/main/main.c b/product-mini/platforms/esp-idf/main/main.c index fbfb04c216..1a34096d7a 100644 --- a/product-mini/platforms/esp-idf/main/main.c +++ b/product-mini/platforms/esp-idf/main/main.c @@ -12,11 +12,7 @@ #include "esp_log.h" -#ifdef CONFIG_IDF_TARGET_ESP32S3 #define IWASM_MAIN_STACK_SIZE 5120 -#else -#define IWASM_MAIN_STACK_SIZE 4096 -#endif #define LOG_TAG "wamr"