Skip to content

Zig libraries for embedded development — HAL, SAL, ESP-IDF bindings, desktop simulation

License

Notifications You must be signed in to change notification settings

haivivi/embed-zig

Repository files navigation

embed-zig

中文 | English

Zig libraries for embedded development.

From bare metal to application layer, from ESP32 to desktop simulation, one language, one abstraction, everywhere.

🌐 https://embed.giztoy.com

Documentation · API Reference · Examples


Overview

embed-zig provides a unified development experience for embedded systems. Write your application logic once — run it on ESP32 hardware today, simulate it on your desktop tomorrow.

Key Features

  • HAL — Board-agnostic hardware abstraction (buttons, LEDs, sensors)
  • Trait — Interface contracts for cross-platform abstractions
  • ESP — Idiomatic Zig bindings for ESP-IDF
  • Raysim — Desktop simulation with Raylib GUI
  • Pre-built Zig — Compiler with Xtensa support for ESP32

Quick Start

# Download Zig with Xtensa support
curl -LO https://github.com/haivivi/embed-zig/releases/download/zig-0.14.0-xtensa/zig-aarch64-macos-none-baseline.tar.xz
tar -xJf zig-aarch64-macos-none-baseline.tar.xz && export PATH=$PWD/zig-aarch64-macos-none-baseline:$PATH

# Set up ESP-IDF and build an example
cd ~/esp/esp-idf && source export.sh
bazel run //examples/apps/led_strip_flash:flash --//bazel/esp:port=/dev/ttyUSB0

Or run in simulation (no hardware needed):

cd examples/raysim/gpio_button && zig build run

Documentation

Document Description
Introduction Project vision, philosophy, and design goals
Getting Started Setup guide, compilation, troubleshooting
Examples Example catalog with run commands
Architecture SAL / HAL / ESP / Raysim design

Supported Platforms

Platform Status Notes
ESP32-S3-DevKit GPIO button, single LED
ESP32-S3-Korvo-2 ADC buttons, RGB LED strip
Raylib Simulator Desktop GUI simulation
ESP32-C3/C6 (RISC-V) 🚧 Standard Zig works

Project Structure

embed-zig/
├── lib/
│   ├── hal/          # Hardware Abstraction Layer
│   ├── trait/        # Interface contracts (log, time, socket, tls, i2c)
│   ├── esp/          # ESP-IDF bindings + trait impl
│   └── raysim/       # Raylib simulation + trait impl
├── examples/
│   ├── apps/         # Platform-independent app logic
│   ├── esp/          # ESP32 entry points
│   └── raysim/       # Desktop simulation entry points
└── bootstrap/        # Zig compiler build scripts

License

Apache License 2.0. See LICENSE.

This project includes patches for Zig and LLVM (Espressif fork). Please refer to the respective upstream projects for their licenses.


Acknowledgments


"The universe is built on layers of abstraction. So is good software."

About

Zig libraries for embedded development — HAL, SAL, ESP-IDF bindings, desktop simulation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •