# Astra MCU SDK Examples - Overview This repository contains example applications for the Synaptics SDK (Astra MCU SDK), demonstrating features and capabilities across Astra MCU platforms. Throughout this guide, `` refers to the directory where you extracted or cloned the SDK. Scope - This README explains examples organization and out‑of‑tree application builds. - For setup and tool installation, see: - [Setup and Install SDK using CLI](../docs/Astra_MCU_SDK_Setup_and_Install_CLI.md) - [Setup and Install SDK using VS Code](../docs/Astra_MCU_SDK_Setup_and_Install_VsCode.md) - For SDK structure, build system, image generation, flashing, and troubleshooting, see the [Astra MCU SDK User Guide](../docs/Astra_MCU_SDK_User_Guide.md). --- ## πŸ“‹ Table of Contents 1. [Overview](#overview) 2. [Example Organization](#example-organization) 3. [Prerequisites](#prerequisites) 4. [Directory Structure](#directory-structure) 5. [Build System Architecture](#build-system-architecture) 6. [Building Examples](#building-examples) --- ## Overview The **Synaptics SDK (Astra MCU SDK)** provides core libraries, drivers, and build tools for Astra MCU development. This examples repository demonstrates how to build applications using the SDK in an **out-of-tree** configuration. **Out-of-tree** means your application code lives in a separate directory from the SDK, keeping the SDK read-only and version-controlled independently. **Key Principles:** - **Out-of-tree examples** β†’ Applications are maintained separately from the SDK core - **Read-only SDK** β†’ SDK acts as a versioned dependency, not modified directly - **Reproducible builds** β†’ Configuration files (defconfigs) drive consistent builds - **Self-contained examples** β†’ Each example can be built independently --- ## Example Organization Examples are organized by board and category: ``` SR110_RDK/ β”œβ”€β”€ configs/ # Application defconfig files β”‚ β”œβ”€β”€ cm55_demo_sample_app_defconfig β”‚ β”œβ”€β”€ cm55_audio_example_defconfig β”‚ └── ... β”œβ”€β”€ audio_examples/ # Audio processing examples β”‚ β”œβ”€β”€ audio_capture/ β”‚ β”œβ”€β”€ audio_playback/ β”‚ └── ... β”œβ”€β”€ drivers_examples/ # Driver usage examples β”‚ β”œβ”€β”€ gpio_example/ β”‚ β”œβ”€β”€ i2c_example/ β”‚ β”œβ”€β”€ spi_example/ β”‚ └── ... β”œβ”€β”€ inference_examples/ # AI/ML inference examples β”‚ β”œβ”€β”€ tflite_inference/ β”‚ └── ... β”œβ”€β”€ vision_examples/ # Image processing examples β”‚ β”œβ”€β”€ uc_person_classification/ β”‚ β”œβ”€β”€ object_detection/ β”‚ └── ... β”œβ”€β”€ usb_examples/ # USB examples └── unity_test/ # Unit tests SL2610_RDK/ β”œβ”€β”€ configs/ # Application defconfig files β”‚ β”œβ”€β”€ cm52_system_manager_rdk_defconfig β”‚ β”œβ”€β”€ cm52_dma_sample_app_defconfig β”‚ └── ... β”œβ”€β”€ drivers_examples/ # Driver usage examples β”‚ β”œβ”€β”€ dma_example/ β”‚ β”œβ”€β”€ i2c_exp_example/ β”‚ β”œβ”€β”€ spwm_example/ β”‚ └── ... β”œβ”€β”€ system_manager/ # System Manager for SL2610_RDK ``` ### Example Structure Each example typically contains: - **Source files** (`.c`, `.cc`, `.h`) - **CMakeLists.txt** - Build configuration - **kconfig** - Configuration options - **README.md** - Example-specific documentation - **Assets** - Models, test data, etc. ### Configuration Files (defconfigs) Defconfigs define: - **Board selection** (e.g., `CONFIG_BOARD="sr110_rdk"` or `CONFIG_BOARD="sl2610_rdk"`) - **Compiler choice** (GCC or AC6) - **Build type** (Release, Debug) - **Enabled SDK modules** (drivers, utilities, etc.) - **Application-specific settings** Example defconfig: `SR110_RDK/configs/cm55_demo_sample_app_defconfig` --- ## Prerequisites For full setup steps, see: - [Setup and Install SDK using CLI](../docs/Astra_MCU_SDK_Setup_and_Install_CLI.md) - [Setup and Install SDK using VS Code](../docs/Astra_MCU_SDK_Setup_and_Install_VsCode.md) ### Required Tools - **CMake** 4.1.2 - **Ninja** 1.13.1 or later - **Python** 3.13.x (for SDK image generation and tooling) - **Toolchain**: GCC 13.2.1, Arm Compiler 6.19 (AC6), or LLVM Clang 21.x (SR110 only; requires GCC sysroot) ### Environment Variables Set these environment variables before building: ```bash # Required: SDK source directory export SRSDK_DIR= # Required: Toolchain paths (choose one based on your compiler) export GCC_TOOLCHAIN_13_2_1=/path/to/gcc-arm-none-eabi/bin # OR export AC6_TOOLCHAIN_6_19_0=/path/to/armclang/bin # OR (SR110 + LLVM Clang) export LLVM_TOOLCHAIN_ROOT=/path/to/llvm/bin export GCC_TOOLCHAIN_ROOT=/path/to/gcc-arm-none-eabi ``` Use only **one** toolchain per build. LLVM builds require `GCC_TOOLCHAIN_ROOT` for the GCC sysroot and libstdc++. **Windows (PowerShell):** ```powershell $env:SRSDK_DIR="C:\path\to\ $env:GCC_TOOLCHAIN_13_2_1="C:\path\to\gcc-arm-none-eabi\bin" ``` **VS Code:** Add to `.vscode/settings.json`: ```json { "terminal.integrated.env.windows": { "SRSDK_DIR": "C:\\path\\to\\, "GCC_TOOLCHAIN_13_2_1": "C:\\path\\to\\gcc-arm-none-eabi\\bin" } } ``` --- ## Directory Structure ``` examples/ β”œβ”€β”€ build/ # CMake build artifacts β”‚ └── / β”‚ └── / # Build files per target/compiler β”œβ”€β”€ install/ # Installed Astra MCU SDK Package β”‚ └── SR110_RDK/ β”‚ β”œβ”€β”€ include/ # SDK headers β”‚ β”œβ”€β”€ lib/ # SDK libraries (.a/.lib) β”‚ β”œβ”€β”€ prebuilt/ # prebuilt libraries (.a/.lib) β”‚ β”œβ”€β”€ config/ β”‚ β”‚ β”œβ”€β”€ config.h # SDK configuration β”‚ β”‚ └── *.ld/*.sct # Linker scripts β”‚ └── tools/ β”‚ └── cmake/ # Toolchain files β”œβ”€β”€ out/ # Final binaries β”‚ └── / β”‚ β”œβ”€β”€ release/ # Release builds (.elf/.axf) β”‚ └── debug/ # Debug builds β”œβ”€β”€ SR110_RDK/ # Board-specific examples β”‚ β”œβ”€β”€ configs/ # Application defconfigs β”‚ β”œβ”€β”€ audio_examples/ β”‚ β”œβ”€β”€ drivers_examples/ β”‚ β”œβ”€β”€ inference_examples/ β”‚ β”œβ”€β”€ vision_examples/ β”‚ └── ... β”œβ”€β”€ CMakeLists.txt # Main build configuration β”œβ”€β”€ Makefile # Build orchestration └── kconfig # Example-level configuration ``` --- ## Build System Architecture For build and flash workflows, see: - [SR110 Build and Flash with CLI](../docs/SR110/SR110_Build_and_Flash_with_CLI.md) - [SR110 Build and Flash with VS Code](../docs/SR110/SR110_Build_and_Flash_with_VSCode.md) - [SL2610 Build and Flash with CLI](../docs/SL2610/SL2610_Build_and_Flash_with_CLI.md) - [SL2610 Build and Flash with VS Code](../docs/SL2610/SL2610_Build_and_Flash_with_VSCode.md) --- ### Two-Stage Build Process **Stage 1: SDK Build** (`BUILD=SRSDK`, combined SDK + app) - Compiles SDK modules (drivers, os, soc, utilities, etc.) - Each module produces a static library (e.g., `libdrivers.a`) - Installs headers, libraries, and toolchain files to `install/${BOARD}/` **Stage 2: Application Build** (`BUILD=EXAMPLE`) - Compiles application source files - Links against pre-built SDK libraries - Produces final executable (`.elf` or `.axf`) ### Build Modes - **BUILD=SRSDK** β†’ Builds SDK libraries and the app (combined flow) - **BUILD=EXAMPLE** β†’ Builds application using pre-built SDK (default) - **SDK-only** β†’ Use `make astrasdk BOARD=` to build/install the SDK package without building an app ### Key Features **Application Cache System:** - Per-application cache of SDK headers and libraries - Hash-based change detection (libs, config.h, toolchain) - Automatic refresh when SDK changes - Location: `build///srsdk_build/.cache/` **Embedded SDK Build:** - Automatically builds SDK if prebuilts are missing - Controlled via `EMBED_SDK_BUILD` CMake option **Configuration Management:** - Kconfig-based configuration system - Defconfigs for reproducible builds - Interactive menuconfig editor --- ## Building Examples **Important:** `SRSDK_DIR` must be set to `` in any shell where you build from `/examples/`, even for app‑only builds. ```bash export SRSDK_DIR= ``` For step‑by‑step workflows, use the Build and Flash guides: - [SR110 Build and Flash with CLI](../docs/SR110/SR110_Build_and_Flash_with_CLI.md) - [SL2610 Build and Flash with CLI](../docs/SL2610/SL2610_Build_and_Flash_with_CLI.md) ### Understanding Build Modes - **BUILD=SRSDK**: Builds the SDK package from source, then builds your app using that fresh SDK. - Use when: first build, SDK source changed, or switching toolchains. - Slower, but ensures SDK and app are consistent. - **BUILD=EXAMPLE** (default): Builds only your app using the previously installed SDK package. - Use when: SDK already built and only app code changed. - Faster for iterative development. Quick commands ```bash # One-time per shell: point examples to your SDK root (required for combined builds and installing SDK into examples) cd /examples export SRSDK_DIR= # Build SDK + application (combined; requires SRSDK_DIR) make BOARD=SR110_RDK BUILD=SRSDK # Rebuild application only (uses installed SDK) make build BOARD=SR110_RDK ```