Compare commits
No commits in common. "c3768283d38ef9f569a6124b97672233631a727e" and "bfdfdc01c5eb1684e66cf1f8a5d234a8808023ea" have entirely different histories.
c3768283d3
...
bfdfdc01c5
9 changed files with 163 additions and 94 deletions
|
|
@ -4,13 +4,24 @@ target = "xtensa-esp32-espidf"
|
||||||
[target.xtensa-esp32-espidf]
|
[target.xtensa-esp32-espidf]
|
||||||
linker = "ldproxy"
|
linker = "ldproxy"
|
||||||
runner = "espflash flash --monitor"
|
runner = "espflash flash --monitor"
|
||||||
|
# Future - necessary for the experimental "native build" of esp-idf-sys with ESP32C3
|
||||||
|
# See also https://github.com/ivmarkov/embuild/issues/16
|
||||||
rustflags = ["--cfg", "espidf_time64"]
|
rustflags = ["--cfg", "espidf_time64"]
|
||||||
|
|
||||||
[unstable]
|
[unstable]
|
||||||
build-std = ["std", "panic_abort"]
|
build-std = ["std", "panic_abort"]
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
MCU="esp32"
|
# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF (v5.3.2)
|
||||||
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
|
ESP_IDF_VERSION = { value = "tag:v5.3.2" }
|
||||||
ESP_IDF_VERSION = "v5.2.3"
|
|
||||||
|
|
||||||
|
# These configurations will pick up your custom "sdkconfig.release", "sdkconfig.debug" or "sdkconfig.defaults[.*]" files
|
||||||
|
# that you might put in the root of the project
|
||||||
|
# The easiest way to generate a full "sdkconfig[.release|debug]" configuration (as opposed to manually enabling only the necessary flags via "sdkconfig.defaults[.*]"
|
||||||
|
# is by running "cargo pio espidf menuconfig" (that is, if using the pio builder)
|
||||||
|
#ESP_IDF_SDKCONFIG = { value = "./sdkconfig.release", relative = true }
|
||||||
|
#ESP_IDF_SDKCONFIG = { value = "./sdkconfig.debug", relative = true }
|
||||||
|
ESP_IDF_SDKCONFIG_DEFAULTS = { value = "./sdkconfig.defaults", relative = true }
|
||||||
|
# ESP-IDF will be installed in ~/.espressif so it can be reused across the different examples.
|
||||||
|
# See also https://github.com/esp-rs/esp-idf-sys/blob/master/BUILD-OPTIONS.md#esp_idf_tools_install_dir-esp_idf_tools_install_dir
|
||||||
|
ESP_IDF_TOOLS_INSTALL_DIR = { value = "fromenv" }
|
||||||
|
|
|
||||||
25
firmware/.gitignore
vendored
25
firmware/.gitignore
vendored
|
|
@ -1,4 +1,21 @@
|
||||||
/.vscode
|
# Generated by Cargo
|
||||||
/.embuild
|
# will have compiled files and executables
|
||||||
/target
|
debug/
|
||||||
/Cargo.lock
|
target/
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# RustRover
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
||||||
|
|
||||||
|
# esp-idf
|
||||||
|
.embuild/
|
||||||
55
firmware/Cargo.lock
generated
55
firmware/Cargo.lock
generated
|
|
@ -1,6 +1,6 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
|
|
@ -163,9 +163,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.29"
|
version = "1.2.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362"
|
checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
|
@ -621,9 +621,11 @@ dependencies = [
|
||||||
name = "firmware"
|
name = "firmware"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"embuild",
|
"embuild",
|
||||||
"esp-idf-svc",
|
"esp-idf-svc",
|
||||||
"log",
|
"log",
|
||||||
|
"toml-cfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1208,6 +1210,15 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_spanned"
|
||||||
|
version = "0.6.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shlex"
|
name = "shlex"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
|
|
@ -1339,11 +1350,40 @@ dependencies = [
|
||||||
"syn 2.0.104",
|
"syn 2.0.104",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml"
|
||||||
|
version = "0.8.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_spanned",
|
||||||
|
"toml_datetime",
|
||||||
|
"toml_edit",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml-cfg"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68c587298ddd135c156e92e8c3eae69614d6eecea8e2d8a09daab011e5e6a21d"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"syn 2.0.104",
|
||||||
|
"toml",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_datetime"
|
name = "toml_datetime"
|
||||||
version = "0.6.11"
|
version = "0.6.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
|
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_edit"
|
name = "toml_edit"
|
||||||
|
|
@ -1352,10 +1392,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
|
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
"serde",
|
||||||
|
"serde_spanned",
|
||||||
"toml_datetime",
|
"toml_datetime",
|
||||||
|
"toml_write",
|
||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_write"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uncased"
|
name = "uncased"
|
||||||
version = "0.9.10"
|
version = "0.9.10"
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
[package]
|
[package]
|
||||||
name = "firmware"
|
name = "firmware"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Clara Dautermann <git@cdaut.de>"]
|
edition = "2024"
|
||||||
edition = "2021"
|
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
rust-version = "1.77"
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "firmware"
|
name = "firmware"
|
||||||
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
|
harness = false # We can't use the default rust libtest harness for a crosscompile target
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = "s"
|
opt-level = "s"
|
||||||
|
|
@ -17,31 +15,12 @@ opt-level = "s"
|
||||||
debug = true # Symbols are nice and they don't increase the size on Flash
|
debug = true # Symbols are nice and they don't increase the size on Flash
|
||||||
opt-level = "z"
|
opt-level = "z"
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
|
|
||||||
experimental = ["esp-idf-svc/experimental"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
anyhow = "1.0.98"
|
||||||
esp-idf-svc = "0.51"
|
esp-idf-svc = "0.51.0"
|
||||||
|
log = "=0.4.27"
|
||||||
# --- Optional Embassy Integration ---
|
toml-cfg = "=0.2.0"
|
||||||
# esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync"] }
|
|
||||||
|
|
||||||
# If you enable embassy-time-driver, you MUST also add one of:
|
|
||||||
|
|
||||||
# a) Standalone Embassy libs ( embassy-time, embassy-sync etc) with a foreign async runtime:
|
|
||||||
# embassy-time = { version = "0.4.0", features = ["generic-queue-8"] } # NOTE: any generic-queue variant will work
|
|
||||||
|
|
||||||
# b) With embassy-executor:
|
|
||||||
# embassy-executor = { version = "0.7", features = ["executor-thread", "arch-std"] }
|
|
||||||
|
|
||||||
# NOTE: if you use embassy-time with embassy-executor you don't need the generic-queue-8 feature
|
|
||||||
|
|
||||||
# --- Temporary workaround for embassy-executor < 0.8 ---
|
|
||||||
# esp-idf-svc = { version = "0.51", features = ["embassy-time-driver", "embassy-sync"] }
|
|
||||||
# critical-section = { version = "1.1", features = ["std"], default-features = false }
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
embuild = "0.33"
|
embuild = "=0.33.0"
|
||||||
|
toml-cfg = "=0.2.0"
|
||||||
|
|
@ -1,3 +1,52 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
embuild::espidf::sysenv::output();
|
linker_be_nice();
|
||||||
|
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
|
||||||
|
println!("cargo:rustc-link-arg=-Tlinkall.x");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn linker_be_nice() {
|
||||||
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
if args.len() > 1 {
|
||||||
|
let kind = &args[1];
|
||||||
|
let what = &args[2];
|
||||||
|
|
||||||
|
match kind.as_str() {
|
||||||
|
"undefined-symbol" => match what.as_str() {
|
||||||
|
"_defmt_timestamp" => {
|
||||||
|
eprintln!();
|
||||||
|
eprintln!("💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`");
|
||||||
|
eprintln!();
|
||||||
|
}
|
||||||
|
"_stack_start" => {
|
||||||
|
eprintln!();
|
||||||
|
eprintln!("💡 Is the linker script `linkall.x` missing?");
|
||||||
|
eprintln!();
|
||||||
|
}
|
||||||
|
"esp_wifi_preempt_enable"
|
||||||
|
| "esp_wifi_preempt_yield_task"
|
||||||
|
| "esp_wifi_preempt_task_create" => {
|
||||||
|
eprintln!();
|
||||||
|
eprintln!("💡 `esp-wifi` has no scheduler enabled. Make sure you have the `builtin-scheduler` feature enabled, or that you provide an external scheduler.");
|
||||||
|
eprintln!();
|
||||||
|
}
|
||||||
|
"embedded_test_linker_file_not_added_to_rustflags" => {
|
||||||
|
eprintln!();
|
||||||
|
eprintln!("💡 `embedded-test` not found - make sure `embedded-test.x` is added as a linker script for tests");
|
||||||
|
eprintln!();
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
},
|
||||||
|
// we don't have anything helpful for "missing-lib" yet
|
||||||
|
_ => {
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-link-arg=-Wl,--error-handling-script={}",
|
||||||
|
std::env::current_exe().unwrap().display()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "esp"
|
channel = "esp" #nightly-2025-01-01
|
||||||
|
components = ["rust-src"]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
|
|
||||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8000
|
|
||||||
|
|
||||||
# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default).
|
|
||||||
# This allows to use 1 ms granularity for thread sleeps (10 ms by default).
|
|
||||||
#CONFIG_FREERTOS_HZ=1000
|
|
||||||
|
|
||||||
# Workaround for https://github.com/espressif/esp-idf/issues/7631
|
|
||||||
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
|
|
||||||
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
fn main() {
|
use anyhow::{bail, Result};
|
||||||
// It is necessary to call this function once. Otherwise some patches to the runtime
|
use esp_idf_svc::eventloop::EspSystemEventLoop;
|
||||||
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
|
use esp_idf_svc::hal::prelude::Peripherals;
|
||||||
esp_idf_svc::sys::link_patches();
|
use log::info;
|
||||||
|
|
||||||
// Bind the log crate to the ESP Logging facilities
|
fn main() -> Result<()> {
|
||||||
|
esp_idf_svc::sys::link_patches();
|
||||||
esp_idf_svc::log::EspLogger::initialize_default();
|
esp_idf_svc::log::EspLogger::initialize_default();
|
||||||
|
|
||||||
log::info!("Hello, world!");
|
let peripherals = Peripherals::take().unwrap();
|
||||||
|
let sysloop = EspSystemEventLoop::take()?;
|
||||||
|
|
||||||
|
info!("Hello, world!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
flake.nix
35
flake.nix
|
|
@ -13,28 +13,13 @@
|
||||||
# Optionally pin to a specific commit of `nixpkgs-esp-dev`.
|
# Optionally pin to a specific commit of `nixpkgs-esp-dev`.
|
||||||
rev = "f37890edc9b327fcbc6d48c4cf174e65e4c0d148";
|
rev = "f37890edc9b327fcbc6d48c4cf174e65e4c0d148";
|
||||||
};
|
};
|
||||||
|
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
|
||||||
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system:
|
|
||||||
let
|
|
||||||
pkgs = import nixpkgs { inherit system; overlays = [ (import "${nixpkgs-esp-dev}/overlay.nix") ]; };
|
pkgs = import nixpkgs { inherit system; overlays = [ (import "${nixpkgs-esp-dev}/overlay.nix") ]; };
|
||||||
|
|
||||||
libxml2Shared = pkgs.libxml2.overrideAttrs (old: {
|
|
||||||
configureFlags = (old.configureFlags or [ ]) ++ [ "--enable-shared" ];
|
|
||||||
|
|
||||||
# cursed patch necessary to fix linking errors
|
|
||||||
postInstall = ''
|
|
||||||
ln -sf libxml2.so $out/lib/libxml2.so.2
|
|
||||||
${old.postInstall or ""}
|
|
||||||
'';
|
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
f { inherit pkgs libxml2Shared; }
|
|
||||||
);
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
devShells = forEachSupportedSystem
|
devShells = forEachSupportedSystem
|
||||||
({ pkgs, libxml2Shared }: {
|
({ pkgs }: {
|
||||||
default = pkgs.mkShell
|
default = pkgs.mkShell
|
||||||
{
|
{
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
|
|
@ -42,23 +27,7 @@
|
||||||
espflash
|
espflash
|
||||||
cargo-espflash
|
cargo-espflash
|
||||||
espup
|
espup
|
||||||
|
|
||||||
llvmPackages_16.libclang # Explicitly add libclang
|
|
||||||
llvmPackages_16.clang # Include clang/headers
|
|
||||||
pkg-config # Often needed for bindgen to find clang
|
|
||||||
glibc.dev # Needed for C headers
|
|
||||||
libxml2Shared.out
|
|
||||||
ldproxy
|
|
||||||
];
|
];
|
||||||
|
|
||||||
env = {
|
|
||||||
# Set LD_LIBRARY_PATH so libstdc++.so.6 zlib and libxml2 can be found
|
|
||||||
LD_LIBRARY_PATH = with pkgs; pkgs.lib.makeLibraryPath [
|
|
||||||
gcc.cc.lib
|
|
||||||
zlib
|
|
||||||
libxml2Shared.out
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue