This commit is contained in:
2026-04-14 20:02:23 +02:00
parent b36d2602d4
commit ec97b915ed
39 changed files with 34391 additions and 167324 deletions
+15
View File
@@ -0,0 +1,15 @@
[target.xtensa-esp32-none-elf]
runner = "espflash flash --monitor --chip esp32 --log-format defmt"
[env]
DEFMT_LOG="info"
[build]
rustflags = [
"-C", "link-arg=-nostartfiles",
]
target = "xtensa-esp32-none-elf"
[unstable]
build-std = ["core"]
+1
View File
@@ -0,0 +1 @@
stack-size-threshold = 1024
+26
View File
@@ -0,0 +1,26 @@
# will have compiled files and executables
debug/
target/
# Editor configuration
.vscode/
.zed/
.helix/
.nvim.lua
# 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/
# Ignore .DS_Store file in mac
**/.DS_Store
+1207
View File
File diff suppressed because it is too large Load Diff
+34
View File
@@ -0,0 +1,34 @@
[package]
edition = "2024"
name = "test"
rust-version = "1.88"
version = "0.1.0"
[[bin]]
name = "test"
path = "./src/bin/main.rs"
[dependencies]
esp-hal = { version = "~1.0", features = ["defmt", "esp32"] }
#defmt = "1.0.1"
esp-bootloader-esp-idf = { version = "0.4.0", features = ["defmt", "esp32"] }
critical-section = "1.2.0"
esp-println = { version = "0.16.1", features = ["defmt-espflash", "esp32"] }
[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
+71
View File
@@ -0,0 +1,71 @@
fn main() {
linker_be_nice();
println!("cargo:rustc-link-arg=-Tdefmt.x");
// 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() {
what if what.starts_with("_defmt_") => {
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!();
}
what if what.starts_with("esp_rtos_") => {
eprintln!();
eprintln!(
"💡 `esp-radio` has no scheduler enabled. Make sure you have initialized `esp-rtos` or provided 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!();
}
"free"
| "malloc"
| "calloc"
| "get_free_internal_heap_size"
| "malloc_internal"
| "realloc_internal"
| "calloc_internal"
| "free_internal" => {
eprintln!();
eprintln!(
"💡 Did you forget the `esp-alloc` dependency or didn't enable the `compat` feature on it?"
);
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()
);
}
+2
View File
@@ -0,0 +1,2 @@
[toolchain]
channel = "stable"
+1
View File
@@ -0,0 +1 @@
#![no_std]
+15
View File
@@ -0,0 +1,15 @@
[target.xtensa-esp32-none-elf]
runner = "espflash flash --monitor --chip esp32"
[env]
ESP_LOG="info"
[build]
rustflags = [
"-C", "link-arg=-nostartfiles",
]
target = "xtensa-esp32-none-elf"
[unstable]
build-std = ["alloc", "core"]
+1
View File
@@ -0,0 +1 @@
stack-size-threshold = 1024
+26
View File
@@ -0,0 +1,26 @@
# will have compiled files and executables
debug/
target/
# Editor configuration
.vscode/
.zed/
.helix/
.nvim.lua
# 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/
# Ignore .DS_Store file in mac
**/.DS_Store
+1292
View File
File diff suppressed because it is too large Load Diff
+35
View File
@@ -0,0 +1,35 @@
[package]
edition = "2024"
name = "test2"
rust-version = "1.88"
version = "0.1.0"
[[bin]]
name = "test2"
path = "./src/main.rs"
[dependencies]
esp-hal = { version = "~1.0", features = ["esp32", "log-04", "unstable"] }
esp-bootloader-esp-idf = { version = "0.4.0", features = ["esp32", "log-04"] }
log = "0.4.27"
critical-section = "1.2.0"
esp-alloc = "0.9.0"
esp-println = { version = "0.16.1", features = ["esp32", "log-04"] }
[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
+70
View File
@@ -0,0 +1,70 @@
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() {
what if what.starts_with("_defmt_") => {
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!();
}
what if what.starts_with("esp_rtos_") => {
eprintln!();
eprintln!(
"💡 `esp-radio` has no scheduler enabled. Make sure you have initialized `esp-rtos` or provided 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!();
}
"free"
| "malloc"
| "calloc"
| "get_free_internal_heap_size"
| "malloc_internal"
| "realloc_internal"
| "calloc_internal"
| "free_internal" => {
eprintln!();
eprintln!(
"💡 Did you forget the `esp-alloc` dependency or didn't enable the `compat` feature on it?"
);
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()
);
}
+2
View File
@@ -0,0 +1,2 @@
[toolchain]
channel = "esp"
+76
View File
@@ -0,0 +1,76 @@
#![no_std]
#![no_main]
use esp_hal::{
clock::CpuClock,
delay::Delay,
gpio::{Level, Output, OutputConfig},
main,
time::{Duration, Instant},
};
use esp_println::dbg;
esp_bootloader_esp_idf::esp_app_desc!();
// You need a panic handler. Usually, you would use esp_backtrace, panic-probe, or
// something similar, but you can also bring your own like this:
#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
esp_hal::system::software_reset()
}
static DELAY: Delay = Delay::new();
fn send_high(led: &mut Output) {
dbg!("high");
led.set_high();
DELAY.delay_nanos(900);
led.set_low();
DELAY.delay_nanos(300);
}
fn send_low(led: &mut Output) {
dbg!("low");
led.set_high();
DELAY.delay_nanos(300);
led.set_low();
DELAY.delay_nanos(900);
}
fn send_reset(led: &mut Output) {
dbg!("reset");
led.set_low();
DELAY.delay_micros(250);
}
fn send(led: &mut Output, rgb: [u8; 3]) {
for val in rgb {
for i in 0..8 {
let bit = val >> i & 1;
if bit == 1 {
send_high(led);
} else {
send_low(led);
}
}
}
send_reset(led);
}
#[main]
fn main() -> ! {
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);
// Set GPIO2 as an output, and set its state high initially.
let mut status_led = Output::new(peripherals.GPIO2, Level::High, OutputConfig::default());
let mut led = Output::new(peripherals.GPIO4, Level::High, OutputConfig::default());
let mut r: u8 = 250;
let mut g: u8 = 250;
let mut b: u8 = 250;
loop {
status_led.toggle();
send(&mut led, [r, g, b]);
DELAY.delay_millis(500);
r = r.wrapping_sub(5);
g = g.wrapping_sub(7);
b = b.wrapping_sub(13);
}
}