ExecuTorch is PyTorch's unified solution for deploying AI models on-device—from smartphones to microcontrollers—built for privacy, performance, and portability. It powers Meta's on-device AI across Instagram, WhatsApp, Quest 3, Ray-Ban Meta Smart Glasses, and more.
This folder adds ExecuTorch so it can be build and run in the Zephyr project as a external module. This includes an example under examples/arm/zephyr of running executor runners with Arm® Ethos™-U backend on a Corstone™ FVP, targeting the Zephyr RTOS.
Setup a venv (or conda)
mkdir <zephyr_build_root>
cd <zephyr_build_root>
python3 -m venv .zephyr_venv
source .zephyr_venv/bin/activate
Install requirements
pip install west cmake==3.29 pyelftools ninja jsonschema
Setup zephyr repo
west init --manifest-rev v4.3.0
Install Zephyr SDK according to Zephyr's guides and set ZEPHYR_SDK_INSTALL_DIR
export ZEPHYR_SDK_INSTALL_DIR=<PATH-TO-ZEPHYR-SDK>
To pull in ExecuTorch as a Zephyr module, either add it as a West project in the west.yaml file or pull it in by adding a submanifest (e.g. zephyr/submanifests/executorch.yaml)
There is an example executorch.yaml in this folder you can copy or just create a new file <zephyr_build_root>/zephyr/submanifests/executorch.yaml with the following content:
<zephyr_build_root>/zephyr/submanifests/executorch.yaml
manifest:
projects:
- name: executorch
url: https://github.com/pytorch/executorch
revision: main
path: modules/lib/executorch
Add ExecuTorch and Ethos-U driver to Zephyr
west config manifest.project-filter -- -.*,+zephyr,+executorch,+cmsis,+cmsis_6,+cmsis-nn,+hal_ethos_u
west update
Setup ExecuTorch
cd modules/lib/executorch/
git submodule sync
git submodule update --init --recursive
./install_executorch.sh
cd ../../..
This is needed to convert python models to PTE files for Ethos™-Ux5 and also installs Corstone™ 300/320 FVP so you can run and test.
Make sure to read and agree to the Corstone™ eula
Install TOSA, vela and FVPs
modules/lib/executorch/examples/arm/setup.sh --i-agree-to-the-contained-eula
. modules/lib/executorch/examples/arm/arm-scratch/setup_path.sh
To run you need to point of the path to the installed Corstone™ FVP and you can then use west to build and run. You point out the model PTE file you want to run with -DET_PTE_FILE_PATH= see below.
The magic to include and use Ethos-U backend is to set CONFIG_ETHOS_U=y/n This is done in the example depending on the board you build for so it you build for a different board then the ones below you might want to add a board config file, or add this line to the prj.conf
Set up FVP paths and macs used, this will also set shutdown_on_eot so the FVP auto stops after it has run the example.
Config Zephyr Corstone300 FVP
export FVP_ROOT=$PWD/modules/lib/executorch/examples/arm/arm-scratch/FVP-corstone300
export ARMFVP_BIN_PATH=${FVP_ROOT}/models/Linux64_GCC-9.3
export ARMFVP_EXTRA_FLAGS="-C mps3_board.uart0.shutdown_on_eot=1 -C ethosu.num_macs=128"
Prepare the Ethos-U55 PTE model
python -m modules.lib.executorch.examples.arm.aot_arm_compiler --model_name=modules/lib/executorch/examples/arm/example_modules/add.py --quantize --delegate -t ethos-u55-128 --output=add_u55_128.pte
--delegate tells the aot_arm_compiler to use Ethos-U backend and -t ethos-u55-128 specify the used Ethos-U variant and numbers of macs used, this must match you hardware or FVP config.
Run the Ethos-U55 PTE model
west build -b mps3/corstone300/fvp modules/lib/executorch/examples/arm/zephyr -t run -- -DET_PTE_FILE_PATH=add_u55_128.pte
Prepare the Cortex-M55 PTE model
python -m modules.lib.executorch.examples.arm.aot_arm_compiler --model_name=modules/lib/executorch/examples/arm/example_modules/add.py --quantize --output=add_m55.pte
Run the Cortex-M55 PTE model
west build -b mps3/corstone300/fvp modules/lib/executorch/examples/arm/zephyr -t run -- -DET_PTE_FILE_PATH=add_m55.pte
Set up FVP paths, libs and macs used, this will also set shutdown_on_eot so the FVP auto stops after it has run the example.
Config Zephyr Corstone320 FVP
export FVP_ROOT=$PWD/modules/lib/executorch/examples/arm/arm-scratch/FVP-corstone320
export ARMFVP_BIN_PATH=${FVP_ROOT}/models/Linux64_GCC-9.3
export LD_LIBRARY_PATH=${FVP_ROOT}/python/lib:${ARMFVP_BIN_PATH}:${LD_LIBRARY_PATH}
export ARMFVP_EXTRA_FLAGS="-C mps4_board.uart0.shutdown_on_eot=1 -C mps4_board.subsystem.ethosu.num_macs=256"
Prepare the Ethos-U85 PTE model
python -m modules.lib.executorch.examples.arm.aot_arm_compiler --model_name=modules/lib/executorch/examples/arm/example_modules/add.py --quantize --delegate -t ethos-u85-256 --output=add_u85_256.pte
--delegate tells the aot_arm_compiler to use Ethos-U backend and -t ethos-u85-256 specify the used Ethos-U variant and numbers of macs used, this must match you hardware or FVP config.
Run the Ethos-U85 PTE model
west build -b mps4/corstone320/fvp modules/lib/executorch/examples/arm/zephyr -t run -- -DET_PTE_FILE_PATH=add_u85_256.pte
You need to add hal_stm32 driver to Zephyr
west config manifest.project-filter -- -.*,+zephyr,+executorch,+cmsis,+cmsis_6,+cmsis-nn,+hal_stm32
west update
Follow and make sure tools are setup according to this:
https://docs.zephyrproject.org/latest/boards/st/nucleo_n657x0_q/doc/index.html
Test the samples/hello_world in that guide to make sure all tools work.
Please note that the ZephyrOS made a fix for the signing tool version v2.21.0 after the v4.3 release in 20 Nov 2025. Make sure to use a later version of ZephyrOS that contains it. Also note that the signing tool must be in your path for it to auto sign your elf.
export PATH=$PATH:~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin
Prepare the Cortex-M55 PTE model
python -m modules.lib.executorch.examples.arm.aot_arm_compiler --model_name=modules/lib/executorch/examples/arm/example_modules/add.py --quantize --output=add_m55.pte
Run the Cortex-M55 PTE model
west build -b nucleo_n657x0_q modules/lib/executorch/examples/arm/zephyr -- -DET_PTE_FILE_PATH=add_m55.pte
west flash
This will run the simple add model on your hardware one and print the output on the serial consol.
Copy this to <zephyr_build_root>/zephyr/submanifests/
Do not remove this file. As mentioned in the official Zephyr documenation, for Executorch to be built as Zephyr module, the file zephyr/module.yml must exist at the top level directory in the project.
- ExecuTorch on Zephyr RTOS with CMSIS — An alternative project structure demonstrating ExecuTorch on Zephyr using CMSIS Toolbox for build management.