---
title: "Quick Start"
description: "Build and run the gpio-button-led example end-to-end. By the end you'll have a working native_sim simulation and a path to real silicon."
source: https://docs.alplab.ai/sdk/quick-start
---

# Quick Start

Build and run the `gpio-button-led` example end-to-end. By the end you'll have a working `native_sim` simulation and a path to real silicon.

## What you need

- The Alp SDK [installed](https://docs.alplab.ai/sdk/installation)
- The `tan` CLI (**0.7.0**, which needs alp-sdk **v0.17.0** or newer) — the SDK's sole user-facing command. It ships from its own repo ([`alplabai/tan-cli`](https://github.com/alplabai/tan-cli)) on its own version line, and it is a **Python** program released as a self-contained PyInstaller freeze: no Rust toolchain, no rustup, no host Python interpreter.

  ```bash
  curl -fsSL https://raw.githubusercontent.com/alplabai/tan-cli/main/install.sh | sh
  # Windows PowerShell: irm https://raw.githubusercontent.com/alplabai/tan-cli/main/install.ps1 | iex
  ```
- A `ZEPHYR_BASE` environment variable pointing at the Zephyr checkout (set by `bootstrap.sh` on Linux/macOS/WSL2, `bootstrap.ps1` on native Windows)

Hardware is **not** required for `native_sim`. To target real silicon, jump to [step 4](#step-4--target-real-silicon).

## Step 1 — Look at the example

Open [`alp-sdk/examples/peripheral-io/gpio-button-led`](https://github.com/alplabai/alp-sdk/tree/main/examples/peripheral-io/gpio-button-led). Every example carries:

```
gpio-button-led/
├── board.yaml           # declarative project config
├── prj.conf             # empty (tan build generates alp.conf)
├── CMakeLists.txt       # plain Zephyr: find_package(Zephyr) + target_sources
├── src/main.c           # the application
└── boards/              # native_sim_native_64.overlay (GPIO emulator for native_sim)
```

The minimum-viable `board.yaml`:

```yaml
som:
  sku: E1M-AEN801          # your MPN — the SDK ships a preset
                            # at metadata/e1m_modules/<MPN>.yaml

preset: e1m-evk            # stock board preset, or write the board out inline

cores:
  m55_hp:
    # os: omitted → SoM topology default (Cortex-M → zephyr).
    app: ./src
    peripherals: [gpio]

diagnostics:
  log_level: info
```

That's the whole config. The orchestrator resolves `som.sku` to the right silicon, picks up the board preset, and generates the per-slice native config (Zephyr Kconfig fragment, CMake `-D` flags, or Yocto `local.conf`) per core declared under `cores:`. Cores omitted inherit the SoM preset's `topology:` defaults — see the [`board.yaml` reference](https://docs.alplab.ai/sdk/board-yaml) for the full schema and the [heterogeneous builds walkthrough](https://docs.alplab.ai/sdk/heterogeneous-builds) for dual-OS projects.

See the [`board.yaml` reference](https://docs.alplab.ai/sdk/board-yaml) for the full schema.

## Step 2 — Build under `native_sim`

```bash
cd alp-workspace/alp-sdk/examples/peripheral-io/gpio-button-led
tan run
```

`tan run` is the quick single-image loop: it resolves the project from the current directory (walking up to the nearest `board.yaml`), builds it, and — for a `native_sim` target — executes the produced binary. The target comes from `board.yaml`, not a flag; on a hardware target add `--flash --confirm` to program the board after the build.

Expected output:

```
*** Booting Zephyr OS build v4.4.1 ***
[gpio] init button=BOARD_PIN_ENCODER_SW, led=BOARD_PIN_LED_RED
[gpio] led=0 status=0
[gpio] led=1 status=0
...
[gpio] is_pressed -> status=0 pressed=1
[gpio] done
```

`status=0` means `ALP_OK`. `pressed=1` is Zephyr's `gpio_emul` default "input is low" report.

### What `tan run` did — and the commands around it

`tan` is the SDK's **sole user-facing CLI**. ADR-0020 Phase 4 (alp-sdk v0.12.0) retired the SDK-side build executor: no `alp` binary is installed anywhere any more, and the `west alp-build` / `alp-image` / `alp-flash` / `alp-clean` / `alp-size` / `alp-renode` extensions went with it. alp-sdk is **plans-only** for this surface — `tan` consumes `alp_orchestrate --emit build-plan` and `--emit system-manifest`, then runs `west` / `bitbake` / `cmake` per slice itself.

`tan run` is the quick single-image loop. The full multi-slice pipeline — every core `board.yaml` declares, in one command — is `tan build`:

| Command      | What it does                                                                        |
|--------------|-------------------------------------------------------------------------------------|
| `tan build`  | Validates `board.yaml`, fans out into per-core slices, seeds `system-manifest.yaml`. |
| `tan image`  | Consumes the manifest, assembles a flashable bundle (`build/image-bundle/`).         |
| `tan flash`  | Walks the manifest's `boot_order:` and programs each piece with the right backend.   |
| `tan clean`  | Removes build outputs.                                                               |
| `tan size`   | Reports per-slice flash/RAM footprint against the SoM budget (`--fail-over-budget`). |
| `tan generate` | Writes the board-derived config files, no build. Nine targets are in the default (`--all`) set — `zephyr-conf`, `dts-overlay`, `native-sim-overlay`, `cmake-args`, `yocto-conf`, `carrier-netlist`, `west-libraries`, `hw-info-h`, `os-topology` — and three are explicit-only: `zephyr-board` (requires `--core`), `composed-route-table`, `ipc-contract-h`. |

There is **no `tan emit` verb**. Reach for `tan generate --target <target>` when you want one artefact.

The scaffold / validate / inspect / host-tool verbs (`tan init`, `tan new-som`, `tan validate`, `tan doctor`, `tan monitor`, `tan model`, `tan explain`, `tan faultdecode`, and — new in `tan` 0.7.0 — the J-Link verbs `tan probe` (read-only inspection) and `tan reset` (one nRESET pulse)) ride the same program. `tan` does **not** forward any verb to `python -m alp_cli` — `tan` is itself Python, `model` / `monitor` / `faultdecode` / `new-som` are native Python inside it, and as of 0.7.0 `validate` runs in-process too. alp-sdk v0.17.0 retired the `python -m alp_cli` front door altogether. See the [`tan` CLI reference](https://docs.alplab.ai/sdk/tools/cli).

Four `west alp-*` commands survive the move. These resolve only when alp-sdk is the workspace's manifest repo — see [Installation](https://docs.alplab.ai/sdk/installation):

| Command            | What it does                                                                       |
|--------------------|------------------------------------------------------------------------------------|
| `west alp-migrate` | Versions and migrates a project's `board.yaml`.                                     |
| `west alp-lock`    | Writes `alp.lock`, the dependency lock (generated on demand, no longer committed); `--check` self-checks the generator. |
| `west alp-quality` | Runs the quality-task registry for a profile (JSON / JUnit / SARIF).                |
| `west alp-emit`    | Prints one generated artefact from `board.yaml`, no build — the orchestrator subset of the catalogue (`system-manifest`, `ipc-contract-h`, `dts-reservations`, `dts-partitions`, `storage-mounts-c`, `tfm-sysbuild-conf`, `build-plan`, `kconfig`). |

Under the hood `tan build` runs four steps:

1. **Validates** the app's `board.yaml` (JSON Schema + SoM SKU preset + board preset + `hw_rev` / SDK-version compatibility + per-slice `peripherals:` vs SoC caps + `cores:` keys against the SoM preset's `topology:` + cross-field validator rules).
2. **Fans out** into per-core slice build directories (`build/<core>-zephyr/`, `build/<core>-yocto/`, etc.) and materialises per-slice Kconfig fragments + Yocto `local.conf` snippets.
3. **Emits cross-slice artefacts** — `build/system-manifest.yaml`, `build/generated/alp/system_ipc.h`, `build/generated/dts-reservations.dtsi` — byte-stable across rebuilds.
4. **Delegates** to `west` / `bitbake` / `cmake` per slice, whichever backend that slice needs.

## Step 3 — Read the source

Open `examples/peripheral-io/gpio-button-led/src/main.c`. Every example is annotated as teaching material:

```c
#include <stdio.h>

#include "alp/peripheral.h"
#include "alp/blocks/button_led.h"
#include "alp/board.h"

int main(void) {
    (void)alp_init();

    alp_button_led_t bl;
    alp_status_t s = alp_button_led_init(&bl, &(alp_button_led_config_t){
        .button_pin_id     = BOARD_PIN_ENCODER_SW,
        .led_pin_id        = BOARD_PIN_LED_RED,
        .active_low_button = true,
    });
    if (s != ALP_OK) {
        printf("[gpio] failed: init status=%d\n", (int)s);
        return 1;
    }

    for (int i = 0; i < 4; i++) {
        alp_button_led_set(&bl, (i & 1));
        alp_delay_ms(50);
    }

    bool pressed = false;
    alp_button_led_is_pressed(&bl, &pressed);
    printf("[gpio] is_pressed pressed=%d\n", (int)pressed);

    alp_button_led_deinit(&bl);
    return 0;
}
```

(Abbreviated: the real source checks the status of every call.)

Key points:

- The example drives the `button_led` block, which sits on the `<alp/peripheral.h>` GPIO calls. Used directly, those are `alp_gpio_open(pin_id)`, then `alp_gpio_configure(pin, ALP_GPIO_OUTPUT, ALP_GPIO_PULL_NONE)`, `alp_gpio_write()` / `alp_gpio_read()` and `alp_gpio_close()`.
- Calls return an `alp_status_t`; when an `alp_*_open()` returns `NULL`, `alp_last_error()` (thread-local) says why.
- `BOARD_PIN_*` IDs come from `<alp/board.h>` and are the same on both EVKs, so this code builds unchanged for either.
- `alp_*_close()` / `*_deinit()` release the handle — observe it for clean shutdown.

See the [`<alp/peripheral.h>` reference](https://docs.alplab.ai/sdk/api/peripheral).

## Step 4 — Target real silicon

There is no `-b` / `--board` selector: the target comes from the project's own `board.yaml` (`som.sku` + `preset`), which `tan build` resolves to the qualified Zephyr board string for you.

For the E1M EVK populated with an AEN SoM (single-OS, Zephyr):

```bash
cd alp-workspace/alp-sdk/examples/peripheral-io/gpio-button-led
tan build
tan flash --confirm     # an AEN Flow D (MRAM) slice also needs --atoc-unqueryable
```

`--confirm` arms the write on the backends that gate it. On AEN, a Flow D (`alif_mram_jlink`) write **replaces the module's whole ATOC**, and `tan` 0.7.0 refuses it until you acknowledge that with `--atoc-unqueryable` — see [`tan flash`](https://docs.alplab.ai/sdk/tools/cli#tan-flash--program-the-built-project). `tan flash --dry-run` previews every backend without touching the board.

These AEN flash paths program the module with a J-Link on the E1M EVK's debug header `J2`. The J-Link is optional hardware: the 2641-R3 E1M EVK's on-board RP2040 (`U55`, USB on `J5`) is its debugger, which flashes and debugs the E1M-AEN, and its USB-to-UART console.

For the E1M-X EVK populated with a V2N SoM (heterogeneous, A55 Yocto + M33 Zephyr):

```bash
cd alp-workspace/alp-sdk/examples/multicore/rpmsg-v2n
tan build     # fans out per-core
tan image     # assemble the bundle
tan flash --confirm     # boot_order-aware programming
```

`tan flash` walks `system-manifest.yaml`'s `boot_order:` and dispatches each artefact to the right backend for that core — no developer-side tool-selection. The on-module helper MCUs (the GD32 bridge on V2N / V2M, the CC3501E on AEN) are **not** part of a normal flash: Alp Lab programs them in production, `tan flash` skips them (`flash_policy: recovery_only`), and they take field updates over their own update channels.

The example's `CMakeLists.txt` is plain Zephyr and does not invoke the orchestrator: `tan build` plans `alp.conf` from `board.yaml` and passes it in as `EXTRA_CONF_FILE`. Its `boards/` directory holds only `native_sim_native_64.overlay`. EVK pins come from the `BOARD_PIN_*` aliases in `<alp/board.h>` (for example `BOARD_PIN_ENCODER_SW` and `BOARD_PIN_LED_RED`), which resolve for the board you build for.

For SoMs without a published EVK board file yet, write your own board file under [`alplabai/alp-zephyr-modules`](https://github.com/alplabai/alp-zephyr-modules) or a private board layer. See [`docs/porting-new-som.md`](https://github.com/alplabai/alp-sdk/blob/main/docs/porting-new-som.md).

## Step 5 — Explore more examples

Every wrapped peripheral has a corresponding minimal example:

```bash
cd alp-workspace
for ex in peripheral-io/pwm-led-fade peripheral-io/adc-voltmeter \
          peripheral-io/i2c-scanner peripheral-io/spi-loopback \
          peripheral-io/uart-echo peripheral-io/uart-rx-ringbuf \
          peripheral-io/can-loopback peripheral-io/qenc-readout \
          power-timing/counter-alarm power-timing/rtc-clock \
          power-timing/wdt-feed audio/i2s-tone; do
    (cd alp-sdk/examples/$ex && tan run)
done
```

On `native_sim` most peripherals don't have emul controllers (only I²C / SPI / GPIO / UART do). Examples that target unwrapped peripherals exit after printing the `alp_last_error()` diagnostic — that's expected and proves the wrapper plumbing compiles and links cleanly.

End-to-end reference apps:

- [`examples/aen/edgeai-vision-aen/`](https://github.com/alplabai/alp-sdk/tree/main/examples/aen/edgeai-vision-aen) — camera → Ethos-U inference → display overlay
- [`examples/connectivity/iot-connected-camera/`](https://github.com/alplabai/alp-sdk/tree/main/examples/connectivity/iot-connected-camera) — camera → DRP-AI → MQTT publish

Heterogeneous flagships (one `board.yaml` drives both halves):

- [`examples/multicore/rpmsg-v2n/`](https://docs.alplab.ai/sdk/examples/rpmsg-v2n) — V2N101 A55 (Yocto) ↔ M33-SM (Zephyr) over RPMsg.
- [`examples/multicore/rpmsg-aen/`](https://docs.alplab.ai/sdk/examples/rpmsg-aen) — AEN801 A32 (Yocto) ↔ M55-HP (Zephyr).
- [`examples/multicore/heterogeneous-offload/`](https://docs.alplab.ai/sdk/examples/heterogeneous-offload) — A-cluster delegates FFT to the M peer over RPMsg.

## Troubleshooting

| Symptom                                          | Cause / fix                                                            |
|--------------------------------------------------|------------------------------------------------------------------------|
| `tan: command not found`                         | `tan` ships separately from the SDK; install it with `curl -fsSL https://raw.githubusercontent.com/alplabai/tan-cli/main/install.sh \| sh` (Windows PowerShell: `irm https://raw.githubusercontent.com/alplabai/tan-cli/main/install.ps1 \| iex`). No Rust toolchain and no host Python interpreter are involved. |
| `alp: command not found`, or `west: unknown command "alp-build"` | Retired in alp-sdk v0.12.0 (ADR-0020 Phase 4). The `alp` binary and the `west alp-{build,image,flash,clean,size,renode}` extensions are gone — use `tan` instead. `west alp-migrate` / `alp-lock` / `alp-quality` / `alp-emit` still need a bootstrapped workspace (`west init -m https://github.com/alplabai/alp-sdk`). |
| `tan validate` reports `validate.missing-preset` or `validate.schema-violation` | `som.sku` doesn't match any preset under `metadata/e1m_modules/`, or a schema / cross-field validator rule failed. Check spelling and the rule hint. `E1M-NX9101` is no longer a supported SKU as of alp-sdk v0.17.0. |
| `tan validate` reports `validate.hardware-revision`, `-unknown` or `-not-buildable` | `hw_rev` is incompatible with this SDK version, does not exist, or is not buildable. Update the SDK or pick a compatible, buildable rev. |
| `tan build` fails with `Aborting due to Kconfig warnings` naming `ALP_SDK_SOM_HW_REV` | `tan` 0.7.0 against an alp-sdk older than v0.17.0. Upgrade the SDK checkout (or pin `tan` 0.6.0 for alp-sdk v0.16.0). |
| `tan doctor`'s `toolchain` check fails                 | The cross toolchain is missing, or does not match the SDK's `metadata/toolchains.json` pin. Run `tan bootstrap`. |
| `flash.atoc-replacement-unacknowledged`          | A confirmed AEN Flow D write needs `--atoc-unqueryable` as well as `--confirm` (`tan` 0.7.0). |
| `tan: no such command 'renode'`                  | Retired in alp-sdk v0.16.0 / `tan` v0.6.0 ([ADR 0022](https://github.com/alplabai/alp-sdk/blob/main/docs/adr/0022-python-executor-renode-retirement.md) Amendment 2). Renode left alp-sdk, `tan-cli` and the VS Code extension completely — verb, CI, platform models, fixtures, and the `aen-sim-vision` example. Build and flash real hardware (`tan build` + `tan flash`), or run a single cross-core-free image with `tan run`. All 26 `renode.*` issue codes are unpublished, so a JSON-envelope consumer will never see one again. |
| Handle is `NULL` and `alp_last_error() == ALP_ERR_NOSUPPORT` | Peripheral wrapper not implemented for this OS/SoM yet. Check the [test plan](https://github.com/alplabai/alp-sdk/blob/main/docs/test-plan.md). |
| Handle is `NULL` and `alp_last_error() == ALP_ERR_OUT_OF_RANGE` | Requested config exceeds the SoC's documented caps (e.g. 16-bit ADC on a 12-bit SoC). |

Full troubleshooting index: [`docs/troubleshooting.md`](https://github.com/alplabai/alp-sdk/blob/main/docs/troubleshooting.md).

## What next?

- [`board.yaml` reference](https://docs.alplab.ai/sdk/board-yaml) — flat schema + the declarative blocks
- [Heterogeneous builds](https://docs.alplab.ai/sdk/heterogeneous-builds) — dual-OS project walkthrough
- [Firmware quickstart](https://docs.alplab.ai/sdk/firmware-quickstart) — per-SoM patterns
- [API reference](https://docs.alplab.ai/sdk/api/overview) — including [`<alp/rpc.h>`](https://docs.alplab.ai/sdk/api/rpc) for cross-core RPC
- [Examples catalogue](https://docs.alplab.ai/sdk/examples/overview)
