Skip to content

Commit b1de8a7

Browse files
committed
empty template from esp-generate
0 parents  commit b1de8a7

File tree

8 files changed

+234
-0
lines changed

8 files changed

+234
-0
lines changed

.cargo/config.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[target.xtensa-esp32-none-elf]
2+
runner = "espflash flash --monitor --chip esp32 --log-format defmt"
3+
4+
[env]
5+
DEFMT_LOG="info"
6+
7+
[build]
8+
rustflags = [
9+
"-C", "link-arg=-nostartfiles",
10+
]
11+
12+
target = "xtensa-esp32-none-elf"
13+
14+
[unstable]
15+
build-std = ["alloc", "core"]

.github/workflows/rust_ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- "**/README.md"
7+
pull_request:
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
14+
jobs:
15+
rust-checks:
16+
name: Rust Checks
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
action:
22+
- command: build
23+
args: --release
24+
- command: fmt
25+
args: --all -- --check
26+
- command: clippy
27+
args: --all-features --workspace -- -D warnings
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
- name: Setup Rust
32+
uses: esp-rs/xtensa-toolchain@v1.5
33+
with:
34+
default: true
35+
buildtargets: esp32
36+
ldproxy: false
37+
- name: Enable caching
38+
uses: Swatinem/rust-cache@v2
39+
- name: Run command
40+
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }}

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# These are backup files generated by rustfmt
7+
**/*.rs.bk
8+
9+
# MSVC Windows builds of rustc generate these, which store debugging information
10+
*.pdb
11+
12+
# RustRover
13+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
14+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
15+
# and can be added to the global gitignore or merged into this file. For a more nuclear
16+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
17+
#.idea/

Cargo.toml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[package]
2+
edition = "2021"
3+
name = "esp32-cam-test"
4+
version = "0.1.0"
5+
6+
[[bin]]
7+
name = "esp32-cam-test"
8+
path = "./src/bin/main.rs"
9+
10+
[dependencies]
11+
defmt = "0.3.10"
12+
embassy-net = { version = "0.6.0", features = [
13+
"dhcpv4",
14+
"medium-ethernet",
15+
"tcp",
16+
"udp",
17+
] }
18+
embedded-io = "0.6.1"
19+
embedded-io-async = "0.6.1"
20+
esp-alloc = "0.7.0"
21+
esp-hal = { version = "1.0.0-beta.0", features = [
22+
"defmt",
23+
"esp32",
24+
"unstable",
25+
] }
26+
esp-println = { version = "0.13.0", features = ["defmt-espflash", "esp32"] }
27+
smoltcp = { version = "0.12.0", default-features = false, features = [
28+
"medium-ethernet",
29+
"multicast",
30+
"proto-dhcpv4",
31+
"proto-dns",
32+
"proto-ipv4",
33+
"socket-dns",
34+
"socket-icmp",
35+
"socket-raw",
36+
"socket-tcp",
37+
"socket-udp",
38+
] }
39+
# for more networking protocol support see https://crates.io/crates/edge-net
40+
critical-section = "1.2.0"
41+
embassy-executor = { version = "0.7.0", features = [
42+
"defmt",
43+
"task-arena-size-20480",
44+
] }
45+
embassy-time = { version = "0.4.0", features = ["generic-queue-8"] }
46+
esp-hal-embassy = { version = "0.7.0", features = ["esp32"] }
47+
esp-wifi = { version = "0.13.0", features = [
48+
"builtin-scheduler",
49+
"defmt",
50+
"esp-alloc",
51+
"esp32",
52+
"wifi",
53+
] }
54+
heapless = { version = "0.8.0", default-features = false }
55+
static_cell = { version = "2.1.0", features = ["nightly"] }
56+
57+
[profile.dev]
58+
# Rust debug is too slow.
59+
# For debug builds always builds with some optimization
60+
opt-level = "s"
61+
62+
[profile.release]
63+
codegen-units = 1 # LLVM can perform better optimizations using a single thread
64+
debug = 2
65+
debug-assertions = false
66+
incremental = false
67+
lto = 'fat'
68+
opt-level = 's'
69+
overflow-checks = false

build.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
fn main() {
2+
linker_be_nice();
3+
println!("cargo:rustc-link-arg=-Tdefmt.x");
4+
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
5+
println!("cargo:rustc-link-arg=-Tlinkall.x");
6+
}
7+
8+
fn linker_be_nice() {
9+
let args: Vec<String> = std::env::args().collect();
10+
if args.len() > 1 {
11+
let kind = &args[1];
12+
let what = &args[2];
13+
14+
match kind.as_str() {
15+
"undefined-symbol" => match what.as_str() {
16+
"_defmt_timestamp" => {
17+
eprintln!();
18+
eprintln!("💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`");
19+
eprintln!();
20+
}
21+
"_stack_start" => {
22+
eprintln!();
23+
eprintln!("💡 Is the linker script `linkall.x` missing?");
24+
eprintln!();
25+
}
26+
_ => (),
27+
},
28+
// we don't have anything helpful for "missing-lib" yet
29+
_ => {
30+
std::process::exit(1);
31+
}
32+
}
33+
34+
std::process::exit(0);
35+
}
36+
37+
println!(
38+
"cargo:rustc-link-arg=-Wl,--error-handling-script={}",
39+
std::env::current_exe().unwrap().display()
40+
);
41+
}

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "esp"

src/bin/main.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#![no_std]
2+
#![no_main]
3+
4+
use defmt::info;
5+
use embassy_executor::Spawner;
6+
use embassy_time::{Duration, Timer};
7+
use esp_hal::clock::CpuClock;
8+
use esp_hal::timer::timg::TimerGroup;
9+
use esp_println as _;
10+
11+
#[panic_handler]
12+
fn panic(_: &core::panic::PanicInfo) -> ! {
13+
loop {}
14+
}
15+
16+
extern crate alloc;
17+
18+
#[esp_hal_embassy::main]
19+
async fn main(spawner: Spawner) {
20+
// generator version: 0.3.0
21+
22+
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
23+
let peripherals = esp_hal::init(config);
24+
25+
esp_alloc::heap_allocator!(size: 72 * 1024);
26+
27+
let timer0 = TimerGroup::new(peripherals.TIMG1);
28+
esp_hal_embassy::init(timer0.timer0);
29+
30+
info!("Embassy initialized!");
31+
32+
let timer1 = TimerGroup::new(peripherals.TIMG0);
33+
let _init = esp_wifi::init(
34+
timer1.timer0,
35+
esp_hal::rng::Rng::new(peripherals.RNG),
36+
peripherals.RADIO_CLK,
37+
)
38+
.unwrap();
39+
40+
// TODO: Spawn some tasks
41+
let _ = spawner;
42+
43+
loop {
44+
info!("Hello world!");
45+
Timer::after(Duration::from_secs(1)).await;
46+
}
47+
48+
// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0-beta.0/examples/src/bin
49+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#![no_std]

0 commit comments

Comments
 (0)