Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ tmp/
fvp_stdout.log

# Editor config. The CMSIS Solution extension regenerates tasks.json,
# settings.json and cmsis.json; only the FVP run/debug wiring is kept: the
# model shim + its Dockerfile, and launch.json, whose Arm-FVP launch config is
# "manual" (see the comment in it). The leading negation overrides a global
# excludes file that ignores every .vscode directory.
# settings.json, cmsis.json and launch.json; only the macOS FVP wiring is kept:
# the model shim + its Dockerfile, and launch.json.mac, an Arm-FVP launch
# config that waits for the model in Docker (see the comment in it). The
# leading negation overrides a global excludes file that ignores every .vscode
# directory.
!.vscode/
.vscode/*
!.vscode/fvp.sh
!.vscode/fvp.Dockerfile
!.vscode/launch.json
!.vscode/launch.json.mac
13 changes: 7 additions & 6 deletions .vscode/fvp.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
# Stand-in for the FVP_Corstone_SSE-320 executable, referenced from the
# `debugger: model:` node of the SSE-320-U85 target-set. The CMSIS Solution
# extension runs it both as the "CMSIS Run" task and as the gdbtarget debug
# server, in the latter case with
# Stand-in for the FVP_Corstone_SSE-320 executable on macOS, where the
# `debugger: model:` node of the SSE-320-U85 target-set points at it (see the
# README). The CMSIS Solution extension runs it both as the "CMSIS Run" task
# and as the gdbtarget debug server (.vscode/launch.json.mac), in the latter
# case with
#
# -D --plugin $AVH_FVP_PLUGINS/GDBServer.so -C GDBServer.port=3333 \
# -f board/Corstone-320/fvp_config.txt --simlimit 60 -a <application>.hex
Expand All @@ -15,8 +16,8 @@
# * runs the model in Docker on macOS, where Arm publishes no FVP build, with
# the GDB port forwarded to the host so arm-none-eabi-gdb can reach it.
#
# On Linux it just execs the real model. On Windows, where the extension cannot
# run a bash script, point the csolution's `model:` at FVP_Corstone_SSE-320.exe.
# On Linux it just execs the real model. Windows and Linux need no shim: the
# csolution's `model:` names FVP_Corstone_SSE-320 directly.
set -euo pipefail

MODEL="${FVP_MODEL:-FVP_Corstone_SSE-320}"
Expand Down
4 changes: 4 additions & 0 deletions .vscode/launch.json → .vscode/launch.json.mac
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"version": "0.2.0",
"configurations": [
{
// macOS only: copy this file to .vscode/launch.json after pointing
// the csolution's `debugger: model:` at .vscode/fvp.sh. On Windows
// and Linux the extension generates a working launch.json itself.
//
// Generated by the CMSIS Solution extension from its Arm-FVP adapter
// template, then switched to "manual" because two "target" fields
// differ from the generated ones and would be lost on regeneration:
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This example shows how to deploy and run an
[ExecuTorch](https://github.com/pytorch/executorch) model on an Arm Ethos-U NPU.
The pack [`PyTorch::ExecuTorch`](https://www.keil.arm.com/packs/executorch-pytorch/)
provides the source code components to build the ExecuTorch runtime, required operators, and Ethos-U backend.
The build process uses the [CMSIS-Toolbox 2.14.1](https://open-cmsis-pack.github.io/cmsis-toolbox/) or higher.
The build process uses the [CMSIS-Toolbox 2.15.0](https://open-cmsis-pack.github.io/cmsis-toolbox/) or higher.

This example application targets the Arm Corstone-320 reference platform with
an Ethos-U85 NPU. It demonstrates the same overall workflow used for other
Expand Down Expand Up @@ -59,11 +59,12 @@ The example can be built and run entirely in Keil Studio for VS Code.
changing the model or the target.
5. Use the CMSIS action buttons to build the application, then select **Run** or
**Debug**. Keil Studio starts the Corstone-320 FVP automatically. On macOS,
where Arm ships no FVP build, `.vscode/fvp.sh` runs the model in Docker:
Docker Desktop must be running, and the first Run or Debug builds the
container image (about 100 MB download). On Windows, set `model:` in the
csolution's target-set back to `FVP_Corstone_SSE-320` (the shim is a bash
script).
where Arm ships no FVP build, run the model in Docker instead: set `model:`
in the csolution's target-set to `${workspaceFolder}/.vscode/fvp.sh` and
copy `.vscode/launch.json.mac` to `.vscode/launch.json` (its debug
configuration waits for the model to come up in the container). Docker
Desktop must be running, and the first Run or Debug builds the container
image (about 100 MB download).

A successful run prints the Ethos-U configuration, output logits, and a pass
result:
Expand Down Expand Up @@ -152,14 +153,13 @@ out/cmsis-executorch/SSE-320-U85/Debug/cmsis-executorch.axf
#### 4. Run on the FVP

```bash
.vscode/fvp.sh \
FVP_Corstone_SSE-320 \
-f board/Corstone-320/fvp_config.txt --simlimit 60 \
-a out/cmsis-executorch/SSE-320-U85/Debug/cmsis-executorch.axf
```

`.vscode/fvp.sh` is the model command the Run and Debug buttons use too; on
Linux and Windows `FVP_Corstone_SSE-320` can be called directly with the same
arguments.
This is the model command the Run and Debug buttons use too. On macOS, call
`.vscode/fvp.sh` with the same arguments; it runs the model in Docker.

## How model generation works

Expand Down Expand Up @@ -238,7 +238,7 @@ together. More information is available in
| `ai_layer/` | Generated: component selection and the embedded model data |
| `setup_venv.py` (`.sh` / `.bat`) | Creates the Python environment for the export |
| `.vscode.d/tasks.json` | The VS Code tasks (venv setup, Create AI layer) merged by the CMSIS Solution extension |
| `.vscode/fvp.sh`, `.vscode/fvp.Dockerfile` | The FVP model command used by Run and Debug; runs the model in Docker on macOS |
| `.vscode/fvp.sh`, `.vscode/fvp.Dockerfile`, `.vscode/launch.json.mac` | macOS only: runs the FVP in Docker, and the debug configuration that waits for it |
| `board/Corstone-320/` | Corstone-320 platform support and FVP configuration |
| `src/app_main.cpp` | Loads the model, runs inference, and prints the result; pool sizes overridable with `APP_METHOD_POOL_SIZE`, `APP_TEMP_POOL_SIZE`, `APP_POOL_SECTION` |
| `src/arm_embedded_module.*` | `EmbeddedModule`: ExecuTorch's `Module` class without the POSIX file loading (BSD-3-Clause, `src/LICENSE-ExecuTorch`) |
Expand Down
24 changes: 6 additions & 18 deletions cmsis-executorch.csolution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# create_ai_layer.py reads the NPU and Vela settings from it, exports the model
# from PyTorch in the project's venv and writes the AI layer.
solution:
created-for: CMSIS-Toolbox@2.14.1
created-for: CMSIS-Toolbox@2.15.0
cdefault:
compiler: AC6

Expand Down Expand Up @@ -41,26 +41,14 @@ solution:
debugger:
name: Arm-FVP
# The model is its own GDB server (plugins/GDBServer.so, MDK FVP
# models 11.32.23+). fvp.sh resolves that plugin when VS Code was
# not started from a `vcpkg activate` shell, line-buffers the
# model's stdout so the debug adapter sees the "Listening" banner,
# and on macOS runs the model in Docker (Arm ships no macOS build).
# On Windows point this straight at FVP_Corstone_SSE-320.exe.
model: ${workspaceFolder}/.vscode/fvp.sh
# models 11.32.23+). On Windows and Linux the FVP from vcpkg runs
# as it is. On macOS, where Arm ships no FVP build, set this to
# ${workspaceFolder}/.vscode/fvp.sh, which runs the model in
# Docker, and copy .vscode/launch.json.mac to .vscode/launch.json.
model: FVP_Corstone_SSE-320
config-file: board/Corstone-320/fvp_config.txt
args: "--simlimit 60"

misc:
# CMSIS-Toolbox 2.14.1 passes -mfpu=fpv5-sp-d16 to Clang for the Cortex-M85,
# a single-precision FPU on a core with a double-precision one and MVE;
# LLVM crashes on some kernels with that combination. The later option
# wins, so name the M85's FPU explicitly (newer toolboxes leave it to -mcpu).
- for-compiler: CLANG
C-CPP:
- -mfpu=fp-armv8-fullfp16-d16
ASM:
- -mfpu=fp-armv8-fullfp16-d16

build-types:
- type: Debug
debug: on
Expand Down
2 changes: 1 addition & 1 deletion documentation/mlops-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ cbuild-mlops:
output:
- file: out/cmsis-executorch/SSE-320-U85/Debug/cmsis-executorch.axf
type: elf
model: ${workspaceFolder}/.vscode/fvp.sh
model: FVP_Corstone_SSE-320
config-file: board/Corstone-320/fvp_config.txt
```

Expand Down
2 changes: 1 addition & 1 deletion vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"requires": {
"arm:tools/open-cmsis-pack/cmsis-toolbox": "2.14.1",
"arm:tools/open-cmsis-pack/cmsis-toolbox": "2.15.0",
"arm:compilers/arm/arm-none-eabi-gcc": "14.3.1",
"arm:compilers/arm/llvm-embedded": "22.1.0",
"arm:tools/kitware/cmake": "4.2.1",
Expand Down
Loading