# zephyrproject-rtos/sdk-ng architecture

> Architecture diagram of the GitHub repository zephyrproject-rtos/sdk-ng, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zephyrproject-rtos/sdk-ng
- Repository: https://github.com/zephyrproject-rtos/sdk-ng

## Overview

##### Main Components
- Zephyr SDK Build Infrastructure: Represent the overall build process which kicks off via GitHub Actions (.github/workflows). This includes CI/CD pipelines that build and test the SDK, generate binaries for multiple host platforms (Linux, macOS, Windows), and trigger subsequent release processes.
- Configuration & Meta Modules: Include directories such as “cmake,” “configs,” and “meta-zephyr-sdk” – these contain the build scripts, project configuration files, and meta-information on how the SDK is orchestrated.
- Toolchains and Submodules: Show each major toolchain component, for example:
– binutils (for linking and object file management)
– gcc (the compiler for various target architectures)
– gdb (the debugger)
– newlib and picolibc (for C library support)
– Other submodules (such as crosskit, crosstool-ng) that support cross-compilation.
- Overlays and Vendor-specific Variants: The “overlays” directory contains vendor-specific configurations and patches for targets (for instance, various Xtensa variants). Clearly list these as extensions or variant flows that customize the main toolchain functionality for specific hardware targets.
- Supporting Scripts & Release Process: Include the “scripts” and “contrib” directories that hold helper scripts for building toolchains, templating setup for different OSs, and the release process (the VERSION file, release-notes, etc.).

##### Relationships & Interactions
- That the “cmake” configuration and “configs” feed into the build process, specifying build options for each target architecture.
- Integration between the SDK and host tools – for instance, after building the toolchains, testing is performed using QEMU or OpenOCD, which then feedback into the CI.

##### Architectural Patterns & Design Principles
- Modularity: Emphasize that the SDK is built from a collection of nearly independent submodules and overlays. Each toolchain component is updated independently and then integrated.
- Extensibility: The overlays and configuration directories illustrate the design’s focus on supporting multiple architectures with tailored settings.
- CI/CD Integration: The clear separation between source (submodules, build scripts) and automation (GitHub workflows) reinforces reproducible builds.
- Separation of Concerns: The build system (cmake, configs, meta-zephyr-sdk) handles build orchestration while the toolchain components provide core functionality.

##### Technologies, Frameworks, and Libraries
- CMake is used as the build configuration system.
- Git submodules manage many modules (binutils, gcc, gdb, newlib, picolibc, etc.).
- The CI/CD workflows are managed via GitHub Actions.
- Various host tools (QEMU, OpenOCD, BOSSA, Xilinx QEMU) are integrated within the release and testing process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Layer
    CI["CI/CD (GitHub Workflows)"]:::cd

    %% Build System Layer: Configuration & Meta Modules
    subgraph "Build System (Configuration & Meta Modules)"
        CMake["CMake"]:::build
        Configs["Configs"]:::build
        MetaConfig["Meta (Config)"]:::build
    end

    %% Toolchain Submodules Layer
    subgraph "Toolchain Submodules"
        Binutils["Binutils"]:::toolchains
        GCC["GCC"]:::toolchains
        GDB["GDB"]:::toolchains
        Newlib["Newlib"]:::toolchains
        Picolibc["Picolibc"]:::toolchains
        Crosskit["Crosskit"]:::toolchains
        CTool_ng["Crosstool-ng"]:::toolchains
    end

    %% Overlays and Vendor-specific Variants
    subgraph "Vendor Overlays"
        Overlays["Overlays (Vendor Specific)"]:::overlays
    end

    %% Host Tools Layer
    subgraph "Host Tools"
        BOSSA["BOSSA"]:::host
        OpenOCD["OpenOCD"]:::host
        QEMU["QEMU"]:::host
    end

    %% Supporting Scripts & Release Process
    subgraph "Supporting Scripts & Release"
        Scripts["Scripts"]:::release
        Contrib["Contrib"]:::release
        Version["VERSION File"]:::release
        ReleaseNotes["Release Notes"]:::release
    end

    %% Relationships
    CI -->|"triggers"| CMake
    CI -->|"triggers"| Configs
    CI -->|"triggers"| MetaConfig

    CMake -->|"configures"| Binutils
    CMake -->|"configures"| GCC
    Configs -->|"defines"| GDB
    MetaConfig -->|"orchestrates"| Newlib
    MetaConfig -->|"orchestrates"| Picolibc
    MetaConfig -->|"orchestrates"| Crosskit
    MetaConfig -->|"orchestrates"| CTool_ng

    %% Overlays apply custom configurations to toolchains
    MetaConfig ---|"customizes"| Overlays
    Overlays ---|"modifies"| GCC

    %% Toolchain outputs feed into Host Tools testing
    Binutils -->|"built binary"| BOSSA
    GCC -->|"built binary"| OpenOCD
    GDB -->|"debug symbols"| QEMU
    Newlib -->|"library support"| BOSSA
    Picolibc -->|"library support"| OpenOCD
    Crosskit -->|"cross-compilation"| QEMU
    CTool_ng -->|"cross-compilation"| QEMU

    %% Overlays influence Host Tools
    Overlays -->|"adjusts"| BOSSA
    Overlays -->|"adjusts"| OpenOCD
    Overlays -->|"adjusts"| QEMU

    %% Host Tools provide feedback to CI/CD
    BOSSA -->|"test results"| CI
    OpenOCD -->|"test results"| CI
    QEMU -->|"test results"| CI

    %% CI/CD also triggers Supporting Scripts & Release Process
    CI -->|"initiates release"| Scripts
    CI -->|"initiates release"| Contrib
    CI -->|"tags version"| Version
    CI -->|"publishes notes"| ReleaseNotes

    %% Click Events
    click CI "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/.github/workflows"
    click CMake "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/cmake"
    click Configs "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/configs"
    click MetaConfig "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/meta-zephyr-sdk"
    click Binutils "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/binutils"
    click GCC "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/gcc"
    click GDB "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/gdb"
    click Newlib "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/newlib"
    click Picolibc "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/picolibc"
    click Crosskit "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/crosskit"
    click CTool_ng "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/crosstool-ng"
    click Overlays "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/overlays"
    click BOSSA "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/meta-zephyr-sdk/recipes-hosttools"
    click OpenOCD "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/meta-zephyr-sdk/recipes-hosttools"
    click QEMU "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/meta-zephyr-sdk/recipes-devtools/qemu"
    click Scripts "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/scripts"
    click Contrib "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/contrib"
    click Version "https://github.com/zephyrproject-rtos/sdk-ng/tree/main/VERSION"
    click ReleaseNotes "https://github.com/zephyrproject-rtos/sdk-ng/blob/main/release-notes.md"

    %% Class Definitions
    classDef cd fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef build fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef toolchains fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef overlays fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef host fill:#ccffff,stroke:#333,stroke-width:2px;
    classDef release fill:#ffffcc,stroke:#333,stroke-width:2px;
```
