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
1 change: 1 addition & 0 deletions assets/contributors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ John O'Hara,Arm,JohnOhara-Arm,johnaohara,JohnnyDoItAll,
Usamah Zaheer,Arm,usamahz,,,
Roy Jamil,Ac6,RoyAc6,royjamil,,https://www.ac6.fr/en/
Elad Gross,Arm,eladgr,,,
Ash Naik,Arm,,,,
Manu Nicholas Jacob,Independent Researcher,manunicholasjacob,manu-nicholas-jacob,,https://manunicholasjacob.com
Ajeet Singh Raina,,,,,
Alexandre Romana,,,,,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
title: Generate human faces with a diffusion model on an Alif Ensemble E8

draft: true
cascade:
draft: true

description: Export the pico-faces diffusion model with ExecuTorch, run it on the Alif Ensemble E8 Ethos-U85 NPU, and display generated faces on the DevKit LCD.

minutes_to_complete: 120

who_is_this_for: This topic is for embedded and machine learning developers who want to deploy a Generative AI model on a microcontroller with Arm Ethos-U85 acceleration.

learning_objectives:
- Explain how ExecuTorch divides pico-faces generation between the Cortex-M55 and Ethos-U85 NPU
- Export and fully delegate the pico-faces diffusion transformer and decoder to the Ethos-U85 NPU
- Configure the Alif Ensemble E8 DevKit for loading and debugging the generated application
- Generate human faces on the DevKit and validate NPU execution through the LCD and UART output

prerequisites:
- Familiarity with Python, machine learning models, and embedded development
- An [Alif Ensemble E8 DevKit](https://alifsemi.com/support/kits/ensemble-e8devkit/) with its display and a USB-C data cable
- A development computer running Linux, macOS, or Windows, with internet access and several GB of free storage
- An Arm account for the Keil MDK Community license and an Alif account for downloading SETOOLS

# START generated_summary_faq
generated_summary_faq:
template_version: summary-faq-v3
generated_at: '2026-10-08T13:45:37Z'
generator: ai
ai_assisted: true
ai_review_required: true
model: gpt-5
prompt_template: summary-faq-v3
source_hash: c8f269fe31381f71921333cb60d33cf0f9406de630dfac4f424b045428870094
summary_generated_at: '2026-10-08T13:45:37Z'
summary_source_hash: c8f269fe31381f71921333cb60d33cf0f9406de630dfac4f424b045428870094
faq_generated_at: '2026-10-08T13:45:37Z'
faq_source_hash: c8f269fe31381f71921333cb60d33cf0f9406de630dfac4f424b045428870094
summary: >-
You'll export the pico-faces diffusion model with ExecuTorch and deploy it to the Alif Ensemble
E8 DevKit. First, you'll configure Keil Studio and the CMSIS toolchain, then delegate the diffusion
transformer and decoder to the Arm Ethos-U85 NPU. Next, you'll provision the Cortex-M55 boot and
debug flow, build the application, and generate human faces. Finally, you'll verify NPU execution
through the DevKit LCD, UART output, and performance counters.
faqs:
- question: What should I check on the DevKit before connecting it to my computer?
answer: >-
Before you connect the DevKit, unplug all USB cables before changing any jumpers. Verify
that the jumpers match the factory defaults documented in the DK-E8 User Guide. This helps
you avoid power or boot issues during setup.
- question: Which USB port do I use for programming, and how do I confirm the board is powered?
answer: >-
Connect a USB-C cable to the PRG USB port on the bottom edge of the DevKit. You can confirm
that the board has power when a green LED illuminates near the E1 device.
- question: Which repository branch do I need for this example?
answer: >-
Clone the CMSIS-ExecuTorch repository using the `hackathon-pico-faces` branch. Use the
`--branch hackathon-pico-faces --single-branch` options, then open the workspace in VS Code.
- question: Which serial settings and switch position should I use to view application output?
answer: >-
Set **SW4** to **UART4** and open **Serial Monitor** on the **PRG USB** port at `115200` baud,
eight data bits, no parity, and one stop bit. If the port was open before changing **SW4**,
close and reopen it.
- question: What result should I expect when I start a debug session and run the firmware?
answer: >-
From the **CMSIS** view, select **Build**, then **Debug**. Keil Studio starts the J-Link GDB
server over SWD and loads the application into MRAM, stopping at `main`. Press **F5** to
continue. The DevKit displays a 128 x 128 RGB face, and UART output confirms Arm Ethos-U85
execution.
# END generated_summary_faq

author: Ash Naik

# New Learning Paths are opted in for the next manual generated summary/FAQ run.
# The generator resets this to false after a successful write.
generate_summary_faq: false

# Optional one-shot controls: set either field to true to regenerate just that
# generated section the next time the summary/FAQ tool runs. The tool resets
# them to false after a successful write.
rerun_summary: false
rerun_faqs: false

### Tags
skilllevels: Advanced
subjects: ML
armips:
- Cortex-M55
- Ethos-U85
tools_software_languages:
- Alif SETOOLS
- CMSIS-Toolbox
- ExecuTorch
- Generative AI
- Keil Studio
- Python
- PyTorch
- SEGGER JLink
operatingsystems:
- Baremetal
- Linux
- macOS
- Windows

further_reading:
- resource:
title: CMSIS-ExecuTorch pico-faces example
link: https://github.com/Arm-Examples/CMSIS-Executorch/tree/hackathon-pico-faces
type: website
- resource:
title: pico-faces project
link: https://github.com/cpldcpu/pico-faces
type: website
- resource:
title: ExecuTorch Arm Ethos-U backend
link: https://docs.pytorch.org/executorch/main/backends-arm-ethos-u.html
type: documentation
- resource:
title: PyTorch ExecuTorch CMSIS Pack
link: https://www.keil.arm.com/packs/executorch-pytorch/
type: documentation
- resource:
title: CMSIS-Toolbox MLOps information
link: https://open-cmsis-pack.github.io/cmsis-toolbox/build-overview/#mlops-information
type: documentation
- resource:
title: Alif Ensemble E8 DevKit support
link: https://alifsemi.com/support/kits/ensemble-e8devkit/
type: website

### FIXED, DO NOT MODIFY
# ================================================================================
weight: 1 # _index.md always has weight of 1 to order correctly
layout: "learningpathall" # All files under learning paths have this same wrapper
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
---

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# ================================================================================
# FIXED, DO NOT MODIFY THIS FILE
# ================================================================================
weight: 21 # The weight controls the order of the pages. _index.md always has weight 1.
title: "Next Steps" # Always the same, html page title.
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Export the model for Ethos-U85
description: Clone the pico-faces example, select the Alif Ensemble E8 target, and generate an Ethos-U85-delegated ExecuTorch AI layer.
weight: 4

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Clone the example branch

Clone the branch that contains the pico-faces application:

```bash
git clone --branch hackathon-pico-faces --single-branch https://github.com/Arm-Examples/CMSIS-Executorch.git
cd CMSIS-Executorch
code .
```

When VS Code opens the workspace:

1. Accept the Arm Tools Environment Manager prompt to activate the tools pinned in `vcpkg-configuration.json`.
2. Accept the prompt to install the required CMSIS packs.
3. Open the **CMSIS** view and select **Manage Solution**.
4. Select the `DevKit-E8` target type, then select **Apply**.

The managed environment supplies CMSIS-Toolbox, Arm Compiler for Embedded, GCC, CMake, and Ninja. The CMSIS packs provide the Alif device support and the ExecuTorch runtime components.

## Set up the Python environment

Open the VS Code Command Palette and select **Tasks: Run Task > Setup Python virtual environment**.

The task creates `.venv`, installs the pinned export packages, and downloads about 60 MB of pico-faces checkpoints into `model/pico_faces/`. The Python packages include several GB of PyTorch dependencies, so the first setup can take some time.

The exporter supports Python 3.10 through 3.13. If your system Python isn't in that range, select the **Setup Python virtual environment (uv)** task. The `uv` variant can download a compatible Python interpreter.

## Create the AI layer

Select **Tasks: Run Task > Create AI layer**.

If the task reports that `cmsis-executorch.cbuild-mlops.yml` is missing, select **Build** once in the **CMSIS** view. The extension generates the target description, and you can then run **Create AI layer** again.

The export performs these operations:

- Calibrates `dit_step` with 16-bit activations and 8-bit weights
- Calibrates `decode` with 8-bit activations and weights
- Delegates each method as one Ethos-U85 segment
- Generates the CMSIS component selection and embedded model data

The task takes a few minutes. When it completes, confirm that `ai_layer/` contains these generated artifacts:

| File | Purpose |
| --- | --- |
| `model.pte` | ExecuTorch program containing both methods |
| `model_pte.c` | Program embedded as a C array for the firmware build |
| `model_params.h` | Sampling schedule, image shapes, and conditioning data |
| `ai_layer.clayer.yml` | CMSIS components selected for the exported program |

Review the task log. It should report one Ethos-U delegate for each model method. Only the quantize and dequantize boundaries remain on the CPU; the diffusion transformer and decoder run on the NPU.

{{% notice Note %}}
Run **Create AI layer** again after changing `model/model.py` or selecting a target with a different NPU configuration. The generated model data isn't committed to the repository.
{{% /notice %}}

## What you've accomplished and what's next

You've exported the diffusion transformer and decoder as one ExecuTorch program for the DevKit's Ethos-U85. Next, you'll install the boot configuration and debug stub needed to load that program on the high-performance Cortex-M55 core.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Prepare the DevKit for debugging
description: Use Alif SETOOLS to install the table of contents and Cortex-M55 high-performance core debug stub needed by the example.
weight: 5

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Understand the one-time provisioning step

The Alif Secure Enclave boots processor images from a table of contents in magnetoresistive random-access memory (MRAM). Before the first debug session, install the configuration that points the high-performance Cortex-M55 core to the project's debug stub.

You normally perform this step once. Repeat it if another project replaces the table of contents.

## Install the debug stub

Confirm that the board is connected through **PRG USB** and that **SW4** is set to **SEUART**. Close any serial monitor that has the DevKit port open.

In VS Code, select:

**Terminal > Run Task > Alif: Install M55_HP debug stubs (DevKit-E8, single core configuration)**

Choose automatic COM port discovery with `-d` the first time. SETOOLS remembers the selected port for later runs.

The task performs these operations:

1. Selects the DevKit-E8 part `AE822FA0E5597LS0` with revision `A0`.
2. Copies the supplied device configuration and debug stub into the SETOOLS workspace.
3. Generates the application table of contents.
4. Writes the table and debug stub to MRAM.

If `app-write-mram` reports a different board revision and asks whether to continue, answer `y`. The part number determines whether the table can boot.

## Switch the UART to the application

After the task completes, set **SW4** to **UART4**. This routes the DevKit's application console to the USB-to-UART bridge.

{{% notice Important %}}
Keep the debug interface set to SWD. A JTAG configuration can leave the generated load task waiting for a J-Link chain response while the device remains in SWD mode.
{{% /notice %}}

## What you've accomplished and what's next

You've installed the boot table and debug stub for the Cortex-M55 high-performance core, then routed the console to UART4. Next, you'll build the application, generate a face, and validate that both ExecuTorch methods ran on the Ethos-U85 NPU.
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: Generate and validate faces on the DevKit
description: Build and debug the application, display generated faces on the LCD, and confirm Ethos-U85 execution from the UART performance output.
weight: 6

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Open the application console

Keep **SW4** set to **UART4**. In VS Code, open **Serial Monitor** on the serial port exposed through **PRG USB** and use these settings:

- Baud rate: `115200`
- Data bits: `8`
- Parity: `None`
- Stop bits: `1`

If the port was open before you changed **SW4**, close and reopen it.

## Build and debug the application

In the **CMSIS** view, confirm that `DevKit-E8` is active. Select **Build**, then select **Debug**. Keil Studio starts the J-Link GDB server over SWD and loads the application into MRAM.

The debugger stops at `main`. Press **F5** to continue.

The firmware initializes the display and NPU, loads the two ExecuTorch methods, and generates a repeatable boot image. The output is similar to:

```output
Ethos-U version info:
Arch: v2.0.0
MACs/cc: 256
ExecuTorch pico-faces (m3_long_cfg, a16w8/a8w8)
Methods:
dit_step 2 input(s), 1 output(s)
decode 1 input(s), 1 output(s)
Generating: seed 3, 4 steps, class 1, w 4.0
Image: 128x128x3, CRC32 <export-dependent-value>
Test_result: PASS
```

The LCD displays the 128 x 128 result scaled to 384 x 384 pixels in the center of the screen. The CRC depends on the host-side export, so use `Test_result: PASS` and the displayed image as the functional checks.

## Confirm NPU execution

Inspect the two performance lines printed after generation. They report NPU cycles, NPU active time, multiply-accumulate array activity, and AXI reads for `dit_step` and `decode`. These counters come from the Ethos-U performance monitoring unit and confirm that both methods executed on the NPU.

The source project's reference DevKit run uses these conditions:

| Setting | Reference value |
| --- | --- |
| Processor | Cortex-M55 high-performance core at 400 MHz |
| NPU | Ethos-U85 with 256 MACs per cycle |
| Model | `m3_long_cfg`, `a16w8` DiT and `a8w8` decoder |
| Sample | Seed 3, four steps, class 1, guidance 4.0 |
| Execution model | Bare-metal, single core; thread count and CPU affinity don't apply |
| Observed time | About 78 ms total: about 68 ms for eight `dit_step` calls and 3 ms for `decode` |

Treat the timing as a reference measurement rather than a pass threshold. Tool versions, the exported program, and board conditions can change the result.

## Generate more faces

Use the **SW2** joystick after the boot image appears:

- Press toward the left to generate one face with the next seed.
- Press toward the right to start continuous generation. Press in the same direction again to stop.

Each completed generation updates the LCD and prints its seed, class, guidance, timing, and CRC to the console.

## View an example result

The following image shows a generated face displayed on the DevKit LCD:

![Photograph of the Alif Ensemble E8 DevKit with its attached LCD displaying a generated smiling face. The display confirms that the pico-faces application completed inference and rendered the 128 x 128 result on the board.#center](generated-face-on-devkit.jpg "Generated face displayed on the Alif Ensemble E8 DevKit")

## Troubleshoot common problems

Use these checks if the application doesn't reach the pass marker:

| Symptom | Check |
| --- | --- |
| J-Link connects but execution doesn't stop at `main` | Set **SW4** to **SEUART** and repeat the debug-stub task from the previous section. |
| Debug remains at **Connecting** | Confirm that the target uses SWD, not JTAG, then power-cycle the board. |
| UART has no application output | Set **SW4** to **UART4**, then close and reopen Serial Monitor. |
| `app-write-mram` receives no response | Set **SW4** to **SEUART**, close programs using the port, and press reset while the tool waits. |
| The build can't find `ai_layer/model_pte.c` | Run **Setup Python virtual environment**, followed by **Create AI layer**. |

## Optional: use the Corstone-320 FVP

The same CMSIS solution also includes the `SSE-320-U85` target for the Corstone-320 Fixed Virtual Platform (FVP). Select that target in **Manage Solution**, recreate the AI layer, and select **Run** or **Debug**. The FVP produces the same seed-based image and writes its raw result to `out/fvp_image.bin`, but the physical DevKit workflow is the primary target for this Learning Path.

## What you've accomplished

You've exported a generative model through ExecuTorch, loaded it on the Alif Ensemble E8 DevKit, and generated faces with both neural-network methods delegated to Ethos-U85. You also validated the run through the LCD, pass marker, and hardware performance counters.
Loading
Loading