{"id":15394917,"url":"https://github.com/kassane/zig-esp-idf-sample","last_synced_at":"2025-04-05T22:04:05.323Z","repository":{"id":225344262,"uuid":"765729469","full_name":"kassane/zig-esp-idf-sample","owner":"kassane","description":"Run Zig on esp-idf (Xtensa/RISC-V)","archived":false,"fork":false,"pushed_at":"2025-02-12T17:41:20.000Z","size":393,"stargazers_count":120,"open_issues_count":7,"forks_count":12,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T21:02:51.491Z","etag":null,"topics":["clang","embedded","embedded-systems","esp-idf","esp-idf-framework","esp-idf-sample","esp-idf-sys","esp32-idf","espressif","freertos","libcxx","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kassane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-01T13:59:37.000Z","updated_at":"2025-03-28T14:14:49.000Z","dependencies_parsed_at":"2024-03-18T21:29:35.098Z","dependency_job_id":"9861dd7b-45b0-4b8d-8d5e-2d07aab6385b","html_url":"https://github.com/kassane/zig-esp-idf-sample","commit_stats":{"total_commits":79,"total_committers":3,"mean_commits":"26.333333333333332","dds":"0.025316455696202556","last_synced_commit":"5b4a55f95c971a1ff491eb8f1ce28ee0303e42b4"},"previous_names":["kassane/zig-esp-idf-sample"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kassane%2Fzig-esp-idf-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kassane%2Fzig-esp-idf-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kassane%2Fzig-esp-idf-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kassane%2Fzig-esp-idf-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kassane","download_url":"https://codeload.github.com/kassane/zig-esp-idf-sample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406084,"owners_count":20933803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","embedded","embedded-systems","esp-idf","esp-idf-framework","esp-idf-sample","esp-idf-sys","esp32-idf","espressif","freertos","libcxx","zig"],"created_at":"2024-10-01T15:24:54.400Z","updated_at":"2025-04-05T22:04:05.291Z","avatar_url":"https://github.com/kassane.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using Zig Language \u0026 Toolchain with ESP-IDF\n\n| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |\n| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |\n\n## STATUS: Experimental\n\n## Description\n\nThis project aims to integrate Zig language and toolchain with the [Espressif IoT Development Framework](https://github.com/espressif/esp-idf) for enhanced development capabilities on ESP32 and its variants.\n\nMore information about building and using Zig with ESP-IDF can be found in the [documentation](docs/build-internals.md).\n\n## Prerequisites\n\n- [Zig](https://ziglang.org/download) toolchain - v0.13.0 or master\n- [ESP-IDF](https://github.com/espressif/esp-idf) - v4.4.x or v5.x or master\n\n### Targets Allowed\n\n| target | commands |\n| ------ | -------- |\n| esp32 | `-Dtarget=xtensa-freestanding-none -Dcpu=esp32` |\n| esp32-s2 | `-Dtarget=xtensa-freestanding-none -Dcpu=esp32s2` |\n| esp32-s3 | `-Dtarget=xtensa-freestanding-none -Dcpu=esp32s3` |\n| esp32-c2/c3 | `-Dtarget=riscv32-freestanding-none -Dcpu=generic_rv32+c+m+zicsr+zifencei` |\n| esp32-h2/c5/c6 | `-Dtarget=riscv32-freestanding-none -Dcpu=generic_rv32+a+c+m+zicsr+zifencei` |\n| esp32-p4 | `-Dtarget=riscv32-freestanding-eabihf -Dcpu=esp32p4` |\n\n\u003cbr\u003e\n\u003csub\u003e\n  \n\u003e [!WARNING]\n\u003e [Zig](https://ziglang.org/download) upstream (LLVM-Codegen) does not have xtensa support. Like [esp-rs](https://github.com/esp-rs), it is necessary to use the [zig-xtensa](https://github.com/kassane/zig-espressif-bootstrap/releases) - **toolchain forked**.\n\n\u003c/sub\u003e\n\u003c/br\u003e\n\n\n### Key Features:\n\n- **Zig Language Integration**: Use the Zig programming language to write firmware code. It provides modern language features such as comptime, meta-programming, and error handling.\n\n- **Zig Toolchain Integration**: The Zig toolchain can be used to build zig libraries and executables, and can also be integrated with the ESP-IDF build system. Also, system compiler and linker can be replaced to `zig cc`/`zig c++`.\n  - **Note:** For C++ support, zig toolchain uses `llvm-libc++` ABI by default.\n\n- **ESP-IDF Compatibility**: Seamlessly integrate Zig with the ESP-IDF framework, allowing developers to leverage the rich set of APIs and functionalities provided by ESP-IDF for IoT development.\n\n- **Build System Configuration**: Using CMake to build Zig libraries allows easy integration with existing ESP-IDF projects while providing efficient dependency management and build configuration.\n\n- **Cross-Platform Development**: Facilitate development across various ESP32 variants including ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-H2, ESP32-P4, ESP32-S2, and ESP32-S3, ensuring broad compatibility and versatility.\n\n\n### About Allocators\n\n\u003e [!NOTE]\n\u003e\n\u003e Asserts allocations are within `@alignOf(std.c.max_align_t)` and directly calls\n\u003e `malloc`/`free`. Does not attempt to utilize `malloc_usable_size`.\n\u003e\n\u003e - `std.heap.raw_c_allocator` allocator is safe to use as the backing allocator with `std.heap.ArenaAllocator` for example and is more optimal in such a case than `std.heap.c_allocator`. - ref.: [std-doc](https://ziglang.org/documentation/master/std/#std.heap.raw_c_allocator)\n\u003e\n\u003e - `std.heap.ArenaAllocator` takes an existing allocator, wraps it, and provides an interface where you can allocate without freeing, and then free it all together. - ref.: [std-doc](https://ziglang.org/documentation/master/std/#std.heap.ArenaAllocator)\n\u003e\n\u003e **Custom Allocators** (based on `std.heap.raw_c_allocator`)\n\u003e\n\u003e - `idf.heap.HeapCapsAllocator` - ref.: [espressif-doc](https://docs.espressif.com/projects/esp-idf/en/v5.2.1/esp32c3/api-reference/system/mem_alloc.html)\n\u003e - `idf.heap.MultiHeapAllocator` - ref.: [espressif-doc](https://docs.espressif.com/projects/esp-idf/en/v5.2.1/esp32c3/api-reference/system/mem_alloc.html)\n\u003e - `idf.heap.vPortAllocator` - ref.: [FreeRTOS-doc](https://www.freertos.org/a00111.html)\n\n\n### License\n\nThis project is licensed twice:\n- [Apache](LICENSE-APACHE)\n- [MIT-0](LICENSE-MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkassane%2Fzig-esp-idf-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkassane%2Fzig-esp-idf-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkassane%2Fzig-esp-idf-sample/lists"}