Run MNIST on an Alif E8 Ensemble DevKit using ExecuTorch and Ethos-U85
Introduction
Learn about MNIST and the Alif Ensemble E8 DevKit
Set up the Alif Ensemble E8 DevKit
(Optional) Set up a Docker development environment
(Optional) Export PyTorch model to ExecuTorch format
Prepare the ExecuTorch model and static libraries for the Alif E8 CMSIS project
Create the Alif E8 CMSIS project
Process and copy a sample image into the Alif E8 CMSIS project
Flash and run the project on the Alif Ensemble E8 DevKit
Next Steps
Run MNIST on an Alif E8 Ensemble DevKit using ExecuTorch and Ethos-U85
Introduction
Learn about MNIST and the Alif Ensemble E8 DevKit
Set up the Alif Ensemble E8 DevKit
(Optional) Set up a Docker development environment
(Optional) Export PyTorch model to ExecuTorch format
Prepare the ExecuTorch model and static libraries for the Alif E8 CMSIS project
Create the Alif E8 CMSIS project
Process and copy a sample image into the Alif E8 CMSIS project
Flash and run the project on the Alif Ensemble E8 DevKit
Next Steps
Build the project using the VS Code CMSIS extension
First, clear any cached build files present from previous runs:
cd ~/mnist_alif/alif_vscode-template
rm -rf tmp/ out/
cd "$HOME\mnist_alif\alif_vscode-template"
Remove-Item -Recurse -Force .\tmp, .\out -ErrorAction SilentlyContinue
CMSIS Toolbox caches aggressively and won’t pick up YAML configuration changes unless you clean first.
Next, to build the project in VS Code:
- Select the CMSIS icon in the left sidebar.
- Select the gear icon.
- Set Active Target to E8-HP.
- Set Active Project to mnist_executorch.
- Select the Build hammer icon.
A successful build prints a memory report similar to:
Memory region Used Size Region Size %age Used
ITCM: 149232 B 256 KB 56.93%
DTCM: 256 KB 256 KB 100.00%
SRAM0: 2576 KB 4 MB 62.89%
SRAM1: 2 MB 4 MB 50.00%
MRAM: 291008 B 2 MB 13.88%
Flash the application
To flash the application, follow these steps:
- Open the Command Palette (
Ctrl+Shift+Pon Windows and Linux orCmd+Shift+Pon macOS). - Select Tasks: Run Task.
- Select Program with Security Toolkit (select COM port).
- Choose the DevKit’s port when prompted.
Flashing takes about 30 seconds.
Start the J-Link RTT server
Open a new terminal and start J-Link Commander:
JLinkExe -device AE822FA0E5597LS0_M55_HP -if SWD -speed 4000
& "C:\Program Files\SEGGER\JLink_V954\JLink.exe" -device AE822FA0E5597LS0_M55_HP -if SWD -speed 4000
At the J-Link> prompt, run:
connect
r
g
Leave this terminal open. It acts as the RTT server.
Start the RTT client
Open a second terminal and start the RTT client:
JLinkRTTClient
& "C:\Program Files\SEGGER\JLink_V954\JLinkRTTClient.exe"
The output is similar to:
ExecuTorch MNIST NPU Demo
Alif Ensemble E8 - Cortex-M55 HP
Initializing SRAM0 power...
SRAM0 enabled successfully
Loading model ...
Running inference...
Inference completed!
Predicted digit: ...
The predicted digit depends on the image you converted in the previous section.
What you’ve accomplished
You’ve now built and flashed a CMSIS-based firmware application that embeds an ExecuTorch .pte model, runs MNIST inference on the Ethos-U85 NPU, and reports the result through SEGGER RTT.
You can extend this project by trying different MNIST images, retraining the model, or replacing MNIST with a different model, such as one trained to classify handwritten letters instead of digits.