Skip to content

Commit be48a68

Browse files
authored
feat(demo): add esp32-no-std demo example (#158)
1 parent cf8156b commit be48a68

File tree

16 files changed

+976
-12
lines changed

16 files changed

+976
-12
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ env:
1818
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1919

2020
jobs:
21-
2221
typos:
2322
name: Check for typos
2423
runs-on: ubuntu-latest
@@ -33,8 +32,8 @@ jobs:
3332
- uses: actions/checkout@v6
3433
- uses: DavidAnson/markdownlint-cli2-action@v22
3534
with:
36-
globs: '**/*.md,#CHANGELOG.md'
37-
separator: ','
35+
globs: "**/*.md,#CHANGELOG.md"
36+
separator: ","
3837

3938
fmt:
4039
name: Run fmt
@@ -70,6 +69,11 @@ jobs:
7069
dir: examples/esp32-std-demo
7170
target: xtensa-esp32-espidf
7271
setup_xtensa: true
72+
# no-std demo
73+
- name: esp32-no-std-demo
74+
dir: examples/esp32-no-std-demo
75+
target: ""
76+
setup_xtensa: true
7377
# EPD Waveshare demo
7478
- name: epd-waveshare-demo
7579
dir: examples/epd-waveshare-demo

Cargo.lock

Lines changed: 109 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[target.xtensa-esp32-none-elf]
2+
runner = "espflash flash --monitor --chip esp32"
3+
4+
[env]
5+
ESP_LOG = "trace"
6+
7+
[build]
8+
target = "xtensa-esp32-none-elf"
9+
rustflags = ["-C", "link-arg=-nostartfiles"]
10+
11+
[unstable]
12+
build-std = ["alloc", "core"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stack-size-threshold = 8192
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[package]
2+
name = "esp32-no-std-demo"
3+
version = "0.1.0"
4+
edition = "2024"
5+
publish = false
6+
7+
[[bin]]
8+
name = "esp32-no-std-demo"
9+
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
10+
11+
# Commented out due to workspace profiles being used
12+
# Feel free to uncomment and adjust if you have copied this outside of a workspace
13+
#
14+
# [profile.release]
15+
# opt-level = 3
16+
#
17+
# [profile.dev]
18+
# Symbols are nice and they don't increase the size on Flash
19+
# debug = true
20+
# opt-level = 3
21+
22+
[dependencies]
23+
esp-hal = { version = "~1.0", features = ["esp32", "log-04", "unstable"] }
24+
esp-bootloader-esp-idf = { version = "0.4.0", features = ["esp32", "log-04"] }
25+
esp-alloc = "0.9.0"
26+
esp-println = { version = "0.16.1", features = ["esp32", "log-04"] }
27+
embedded-hal-bus = "0.3.0"
28+
mipidsi = "0.9.0"
29+
critical-section = "1.2.0"
30+
mousefood = { path = "../../mousefood/" }
31+
ratatui = { workspace = true, default-features = false, features = ["all-widgets"] }
32+
log = "0.4.27"
33+
time = { version = "0.3.45", default-features = false }
34+
libm = "0.2.16"
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
fn main() {
2+
linker_be_nice();
3+
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
4+
println!("cargo:rustc-link-arg=-Tlinkall.x");
5+
}
6+
7+
fn linker_be_nice() {
8+
let args: Vec<String> = std::env::args().collect();
9+
if args.len() > 1 {
10+
let kind = &args[1];
11+
let what = &args[2];
12+
13+
match kind.as_str() {
14+
"undefined-symbol" => match what.as_str() {
15+
what if what.starts_with("_defmt_") => {
16+
eprintln!();
17+
eprintln!(
18+
"💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`"
19+
);
20+
eprintln!();
21+
}
22+
"_stack_start" => {
23+
eprintln!();
24+
eprintln!("💡 Is the linker script `linkall.x` missing?");
25+
eprintln!();
26+
}
27+
what if what.starts_with("esp_rtos_") => {
28+
eprintln!();
29+
eprintln!(
30+
"💡 `esp-radio` has no scheduler enabled. Make sure you have initialized `esp-rtos` or provided an external scheduler."
31+
);
32+
eprintln!();
33+
}
34+
"embedded_test_linker_file_not_added_to_rustflags" => {
35+
eprintln!();
36+
eprintln!(
37+
"💡 `embedded-test` not found - make sure `embedded-test.x` is added as a linker script for tests"
38+
);
39+
eprintln!();
40+
}
41+
"free"
42+
| "malloc"
43+
| "calloc"
44+
| "get_free_internal_heap_size"
45+
| "malloc_internal"
46+
| "realloc_internal"
47+
| "calloc_internal"
48+
| "free_internal" => {
49+
eprintln!();
50+
eprintln!(
51+
"💡 Did you forget the `esp-alloc` dependency or didn't enable the `compat` feature on it?"
52+
);
53+
eprintln!();
54+
}
55+
_ => (),
56+
},
57+
// we don't have anything helpful for "missing-lib" yet
58+
_ => {
59+
std::process::exit(1);
60+
}
61+
}
62+
63+
std::process::exit(0);
64+
}
65+
66+
println!(
67+
"cargo:rustc-link-arg=-Wl,--error-handling-script={}",
68+
std::env::current_exe().unwrap().display()
69+
);
70+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "esp"

0 commit comments

Comments
 (0)