-
Notifications
You must be signed in to change notification settings - Fork 727
ESP IDF fixes #927
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
Merged
Merged
ESP IDF fixes #927
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b2e6143
esp-idf: Fix type for compilation error
wallento 60facc1
esp-idf: Implement os_thread_get_stack_boundary
wallento 47504da
esp-idf: Fix AoT capabilities on heap
wallento 8d06bda
esp-idf: deactivate memory protection
wallento 3786805
esp-idf: Generalize for other platforms
wallento f6ccbf0
esp-idf: Increase main pthread stack size
wallento 0cd9390
esp-idf: Use wasm-micro-runtime as component
wallento b4f6765
esp-idf: Reorganize product-mini as example
wallento 44bdf8d
esp-idf: Don't use memcpy on relocation for xtensa
wallento 4b255d4
esp-idf: Return NULL from malloc/mmap on allocation failure
wallento 845b4a4
esp-idf: Fix license headers
wallento fd2f444
esp-idf: Fix naming of definitions
wallento ee2b17e
esp-idf: Fix realloc
wallento db1990b
esp-idf: Set WAMR_PATH to default if not overwritten
wallento File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # wasm-micro-runtime as ESP-IDF component | ||
|
|
||
| You can build an ESP-IDF project with wasm-micro-runtime as a component: | ||
|
|
||
| - Make sure you have the ESP-IDF properly installed and setup | ||
| - In particular have the following paths set: | ||
| - `WAMR_PATH` to point to your wasm-micro-runtime repository | ||
| - `IDF_PATH` to point to your ESP-IDF | ||
| - `source $IDF_PATH/export.sh` | ||
| - Create a new project, e.g.: `idf.py create-project wamr-hello` | ||
| - In the newly created project folder edit the `CMakeList.txt`: | ||
|
|
||
| ``` | ||
| 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-hello) | ||
| ``` | ||
| - Develop your project in it's `main` component folder. | ||
|
|
||
| You can find an example [here](../../product-mini/platforms/esp-idf). | ||
|
|
||
| - Set target platform: `idf.py set-target esp32c3` | ||
| - Build: `idf.py build` | ||
| - Flash: `idf.py flash` | ||
| - Check the output: `idf.py monitor` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Copyright (C) 2021 Intel Corporation and others. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| # Set WAMR's build options | ||
| if("${IDF_TARGET}" STREQUAL "esp32c3") | ||
| set(WAMR_BUILD_TARGET "RISCV32") | ||
| else() | ||
| set(WAMR_BUILD_TARGET "XTENSA") | ||
| endif() | ||
|
|
||
| set(WAMR_BUILD_PLATFORM "esp-idf") | ||
|
|
||
| if (NOT CMAKE_BUILD_TYPE) | ||
| set(CMAKE_BUILD_TYPE Release) | ||
| endif () | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_INTERP) | ||
| set (WAMR_BUILD_INTERP 1) | ||
| endif () | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_FAST_INTERP) | ||
| set (WAMR_BUILD_FAST_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 () | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_APP_FRAMEWORK) | ||
| set (WAMR_BUILD_APP_FRAMEWORK 0) | ||
| endif () | ||
|
|
||
| if (NOT CMAKE_BUILD_EARLY_EXPANSION) | ||
| if (WAMR_BUILD_TARGET STREQUAL "XTENSA") | ||
| idf_build_set_property(COMPILE_DEFINITIONS "-DBUILD_TARGET_XTENSA=1" APPEND) | ||
| endif () | ||
| if (WAMR_BUILD_INTERP) | ||
| idf_build_set_property(COMPILE_DEFINITIONS "-DWASM_ENABLE_INTERP=1" APPEND) | ||
| endif () | ||
| if (WAMR_BUILD_AOT) | ||
| idf_build_set_property(COMPILE_DEFINITIONS "-DWASM_ENABLE_AOT=1" APPEND) | ||
| endif () | ||
|
|
||
| set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) | ||
| include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) | ||
| endif() | ||
|
|
||
| idf_component_register(SRCS ${WAMR_RUNTIME_LIB_SOURCE} ${PLATFORM_SHARED_SOURCE} | ||
| INCLUDE_DIRS ${IWASM_DIR}/include ${UTILS_SHARED_DIR} ${PLATFORM_SHARED_DIR} ${PLATFORM_SHARED_DIR}/../include | ||
| REQUIRES pthread | ||
| ) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| sdkconfig | ||
| sdkconfig.old |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,77 +1,12 @@ | ||
| # Copyright (C) 2019 Intel Corporation. All rights reserved. | ||
| # Copyright (C) 2019-21 Intel Corporation and others. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| # from ESP-IDF 4.0 examples/build_system/cmake/idf_as_lib | ||
| cmake_minimum_required(VERSION 3.5) | ||
| project(wamr_on_esp32c3) | ||
|
|
||
| enable_language(ASM) | ||
| include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
|
|
||
| if (NOT CMAKE_BUILD_TYPE) | ||
| set(CMAKE_BUILD_TYPE Release) | ||
| endif () | ||
| set (COMPONENTS ${IDF_TARGET} main freertos esptool_py wamr) | ||
| list(APPEND EXTRA_COMPONENT_DIRS "$ENV{WAMR_PATH}/build-scripts/esp-idf") | ||
|
|
||
| if("${IDF_TARGET}" STREQUAL "") | ||
| message(FATAL_ERROR "You need to set IDF_TARGET to your target string") | ||
| endif() | ||
|
|
||
| # Include for ESP-IDF build system functions | ||
| include($ENV{IDF_PATH}/tools/cmake/idf.cmake) | ||
| # Create idf::esp32c3 and idf::freertos static libraries | ||
| idf_build_process(${IDF_TARGET} | ||
| # try and trim the build; additional components | ||
| # will be included as needed based on dependency tree | ||
| # | ||
| # although esptool_py does not generate static library, | ||
| # processing the component is needed for flashing related | ||
| # targets and file generation | ||
| COMPONENTS ${IDF_TARGET} freertos esptool_py | ||
| SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig | ||
| BUILD_DIR ${CMAKE_BINARY_DIR}) | ||
|
|
||
| # Set WAMR's build options | ||
| if("${IDF_TARGET}" STREQUAL "esp32c3") | ||
| set(WAMR_BUILD_TARGET "RISCV32") | ||
| else() | ||
| set(WAMR_BUILD_TARGET "XTENSA") | ||
| add_compile_options(-DWAMR_BUILD_TARGET_XTENSA=1) | ||
| endif() | ||
|
|
||
| set(WAMR_BUILD_PLATFORM "esp-idf") | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_INTERP) | ||
| set (WAMR_BUILD_INTERP 0) | ||
| endif () | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_FAST_INTERP) | ||
| set (WAMR_BUILD_FAST_INTERP 0) | ||
| 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 () | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_APP_FRAMEWORK) | ||
| set (WAMR_BUILD_APP_FRAMEWORK 0) | ||
| endif () | ||
|
|
||
|
|
||
| # Set the compile time variable so that the right binary is selected | ||
| add_compile_options(-DWAMR_BUILD_INTERP=${WAMR_BUILD_INTERP}) | ||
|
|
||
| set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) | ||
| include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) | ||
|
|
||
| # define WAMR as library and provide it the esp-idf srcs | ||
| add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) | ||
| target_link_libraries(vmlib PUBLIC idf::pthread idf::${IDF_TARGET} idf::freertos) | ||
|
|
||
| # Define the final executable | ||
| set(elf_file ${CMAKE_PROJECT_NAME}.elf) | ||
| add_executable(${elf_file} main.c test_wasm.h) | ||
| target_link_libraries(${elf_file} idf::${IDF_TARGET} idf::freertos idf::spi_flash vmlib) | ||
| idf_build_executable(${elf_file}) | ||
| project(wamr-simple) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| # Copyright (C) 2019-21 Intel Corporation and others. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| ESP32_TARGET="esp32" | ||
| ESP32C3_TARGET="esp32c3" | ||
|
|
||
| usage () | ||
| { | ||
| echo "USAGE:" | ||
| echo "$0 $ESP32_TARGET|$ESP32C3_TARGET" | ||
| echo "Example:" | ||
| echo " $0 $ESP32_TARGET" | ||
| echo " $0 $ESP32C3_TARGET" | ||
| exit 1 | ||
| } | ||
|
|
||
| if [ $# != 1 ] ; then | ||
| usage | ||
| fi | ||
|
|
||
| TARGET=$1 | ||
|
|
||
wallento marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if [[ -z "${WAMR_PATH}" ]]; then | ||
| export WAMR_PATH=$PWD/../../.. | ||
| fi | ||
|
|
||
| rm -rf build | ||
| idf.py set-target $TARGET | ||
| idf.py build | ||
| idf.py flash | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.