wasm-micro-runtime/product-mini/platforms/zephyr/simple
Bananymous 81f0371f63
Fix typo in zephyr's Dockerfile.old (#2354)
Dockerfile had command 'pip install --no-cache-doir' which caused
the image build to fail. Fix this to correctly say '--no-cache-dir'.
2023-07-11 14:41:12 +08:00
..
boards Simplify build setup for zephyr (#789) 2021-10-15 20:15:17 +08:00
src Fix zephyr sample build errors (#1757) 2022-11-28 11:23:51 +08:00
build_and_run.sh Fix Windows compilation warnings (#1171) 2022-05-16 09:12:58 +08:00
CMakeLists.txt Fix zephyr sample build errors (#1757) 2022-11-28 11:23:51 +08:00
Dockerfile Add docker file to fix Zephy ESP32 linking issue (#2314) 2023-07-06 10:11:39 +08:00
Dockerfile.old Fix typo in zephyr's Dockerfile.old (#2354) 2023-07-11 14:41:12 +08:00
esp32_custom_linker.ld Add xtensa AOT support and fix build issue of alios (#223) 2020-04-01 18:38:42 +08:00
README.md Add docker file to fix Zephy ESP32 linking issue (#2314) 2023-07-06 10:11:39 +08:00

How to use WAMR with Zephyr

Build with Docker(recommend approach)

To have a quicker start, a Docker container of the Zephyr setup can be generated. The current docker image would be considerably large(~15GB), it would take some time to build it and enough disk space to store it.

Build Docker images

docker build -t wamr-zephyr .

PS: currently, the esp32 custom linker script only works with a lower version of Zephyr, if you want to use an esp32 board, you can build the Dockerfile with a lower version of Zephyr, Zephyr SDE, ESP-IDF. The old version of Docker image can also build other targets, but probably it's a better choice to use the new Dockerfile for other boards

# If you want to build on esp32 platform
docker build -f Dockerfile.old -t wamr-zephyr .

Run Docker images

Adopt the device or remove if not needed.

docker run -ti --device=/dev/ttyUSB0 wamr-zephyr

And then inside the docker container:

# copy the corresponding board conf file to current directory
cp boards/qemu_x86_nommu.conf prj.conf
# then build
./build_and_run.sh x86

PS: for boards esp32, need to configure some environment first

# configure zephyr with espressif
export ZEPHYR_TOOLCHAIN_VARIANT="espressif"
export ESPRESSIF_TOOLCHAIN_PATH="/root/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/"
export ESP_IDF_PATH="/root/esp/esp-idf"
# copy the corresponding board conf file to current directory
cp boards/esp32.conf prj.conf
# then build
./build_and_run.sh esp32

Build on local environment

Dependencies installation

Following the Zephyr and Espressif official document:

  1. Zephyr installation:

    https://docs.zephyrproject.org/latest/develop/getting_started/index.html

  2. ESP32 installation:

    https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html

And setup the Zephyr for esp32:

https://wiki.amarulasolutions.com/zephyr/esp32/esp32-setup.html

Then Installing QEMU, for example, on Linux:

sudo apt-get install qemu

Run the build script

Make sure you have the environment variable ready, you can use the command env to check:

env
# export ZEPHYR_BASE if it's not present
export ZEPHYR_BASE=~/zephyrproject/zephyr
# and if you install zephyr in virtual environment rather than global
source ~/zephyrproject/.venv/bin/activate

For boards esp32, need to configure some extra environment first, check the following env variable whether in the env list, if not, add them like:

Noted: The esp32 custom linker script doesn't work with the recent version of Zephyr, if you want to use it in the local environment, please install Zephyr 2.3.0 with the corresponding SDK, and ESP-IDF 4.0

export ZEPHYR_TOOLCHAIN_VARIANT="espressif"
export ESPRESSIF_TOOLCHAIN_PATH="~/.espressif/tools/xtensa-esp32-elf/esp-{the version you installed}/xtensa-esp32-elf/"
export ESP_IDF_PATH="~/esp/esp-idf"

Then you can run the build script:

# copy the corresponding board conf file to current directory
cp boards/qemu_x86_nommu.conf prj.conf
# then build
./build_and_run.sh x86