basic project setup

This commit is contained in:
Clara Dautermann 2025-07-02 16:43:01 +02:00
parent 5507d11fe8
commit dac87a1696
Signed by: clara
GPG key ID: 223391B52FAD4463
10 changed files with 1887 additions and 10 deletions

View file

@ -0,0 +1,14 @@
[target.xtensa-esp32-none-elf]
runner = "espflash flash --monitor --chip esp32"
[env]
[build]
rustflags = [
"-C", "link-arg=-nostartfiles",
]
target = "xtensa-esp32-none-elf"
[unstable]
build-std = ["alloc", "core"]

18
firmware/.gitignore vendored Normal file
View file

@ -0,0 +1,18 @@
# Generated by Cargo
# will have compiled files and executables
debug/
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/

1640
firmware/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

56
firmware/Cargo.toml Normal file
View file

@ -0,0 +1,56 @@
[package]
edition = "2021"
name = "firmware"
version = "0.1.0"
[[bin]]
name = "firmware"
path = "./src/bin/main.rs"
[dependencies]
esp-bootloader-esp-idf = "0.1.0"
esp-hal = { version = "=1.0.0-beta.1", features = ["esp32", "unstable"] }
bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "a5148d8ae679e021b78f53fd33afb8bb35d0b62e", features = [
"async",
"macros",
] }
critical-section = "1.2.0"
embedded-io = "0.6.1"
esp-alloc = "0.8.0"
esp-wifi = { version = "0.14.1", features = [
"ble",
"builtin-scheduler",
"coex",
"esp-alloc",
"esp32",
"smoltcp",
"wifi",
] }
smoltcp = { version = "0.12.0", default-features = false, features = [
"medium-ethernet",
"multicast",
"proto-dhcpv4",
"proto-dns",
"proto-ipv4",
"socket-dns",
"socket-icmp",
"socket-raw",
"socket-tcp",
"socket-udp",
] }
[profile.dev]
# Rust debug is too slow.
# For debug builds always builds with some optimization
opt-level = "s"
[profile.release]
codegen-units = 1 # LLVM can perform better optimizations using a single thread
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 's'
overflow-checks = false

52
firmware/build.rs Normal file
View file

@ -0,0 +1,52 @@
fn main() {
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()
);
}

View file

@ -0,0 +1,2 @@
[toolchain]
channel = "esp"

1
firmware/src/lib.rs Normal file
View file

@ -0,0 +1 @@
#![no_std]

View file

@ -0,0 +1,22 @@
//! Demo test suite using embedded-test
//!
//! You can run this using `cargo test` as usual.
#![no_std]
#![no_main]
#[cfg(test)]
#[embedded_test::tests]
mod tests {
use esp_hal as _;
#[init]
fn init() {
let _ = esp_hal::init(esp_hal::Config::default());
}
#[test]
fn hello_test() {
assert_eq!(1 + 1, 2);
}
}