opinionated bare-metal async Rust template for the ESP32-C3/C6, or about 550 lines of code I was going to write anyway.
this template can be built for both the C3 and C6:
- use
just r3
to flash on C3, andjust r6
to flash on C6. - use
just b3
to build for C3, andjust b6
to build for C6. - use
just c3
to run Clippy for C3, andjust c6
to run Clippy for C6.
the Justfile recipes automatically set the required build target, crate
features, and the ESP_HAL_CONFIG_FLIP_LINK
environment variable. (see below)
besides target support, this template has a few more options:
Cargo.toml
features:
net
: enables networking support throughembassy-net
(implieswifi
).wifi
: enables Wi-Fi support (requiresbuild-std = "alloc"
).
.cargo/config.toml
options:
build-std
: building thealloc
crate is optional, but is required for certain crate features; disabling this makes cold builds slightly faster.build-std-features
: thepanic_immediate_abort
standard library feature is optional, and saves some flash space without much downside, if you usedefmt::panic!
and co. for panicking.env
:- the
ESP_HAL_CONFIG_FLIP_LINK
environment variable enables zero-cost stack overflow protection on ESP32-C6. - the
ESP_WIFI_CONFIG_COUNTRY_CODE
environment variable sets your Wi-Fi country code.
- the
the Nix flake exports 4 outputs: a dev shell, some checks, and 2 packages, one for each chip.
the dev shell contains common utilities for development: the Rust toolchain,
cargo-binutils
, cargo-bloat
, espflash
, and just
.
building the package generates an ELF binary, which can be converted into a
flat firmware image using espflash
and flashed onto a module.
due to an issue with
espflash
, the package doesn't generate this flat firmware image automatically.
this will be done in the future, once the issue is resolved.
to use the version of esp-hal
currently published on crates.io
, use the
main
branch of this template.
esp-hal
is going to hit 1.0.0-rc.1
Soon™. in the meantime, if you want to
use esp-hal
straight from git
, use the esp-hal-git
branch of this
template; it will be kept mostly up-to-date with the main
branch of esp-hal
.