first commit
This commit is contained in:
commit
7b177ee372
24
.cargo/config.toml
Normal file
24
.cargo/config.toml
Normal file
@ -0,0 +1,24 @@
|
||||
[target.'cfg(any(target_arch = "riscv32", target_arch = "xtensa"))']
|
||||
runner = "espflash flash --chip esp32s3 --monitor"
|
||||
|
||||
[env]
|
||||
DEFMT_LOG="debug"
|
||||
|
||||
[build]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-nostartfiles",
|
||||
#"-C", "link-arg=-Tlink.x",
|
||||
#"-C", "link-arg=--nmagic",
|
||||
"-C", "link-arg=-Tdefmt.x",
|
||||
# make sure linkall.x is the last linker script
|
||||
"-C", "link-arg=-Tlinkall.x"
|
||||
]
|
||||
|
||||
target = "xtensa-esp32s3-none-elf"
|
||||
|
||||
[unstable]
|
||||
build-std = ["core"]
|
||||
|
||||
[alias]
|
||||
esp = "espflash flash --chip esp32s3 --monitor --release --bin"
|
||||
main = "build --release --bin main"
|
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# 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/
|
8
.vscode/extensions.json
vendored
Normal file
8
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"rust-lang.rust-analyzer",
|
||||
"tamasfe.even-better-toml",
|
||||
"probe-rs.probe-rs-debugger",
|
||||
"fill-labs.dependi"
|
||||
]
|
||||
}
|
53
.vscode/launch.json
vendored
Normal file
53
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "probe-rs-debug",
|
||||
"request": "launch",
|
||||
"name": "Launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"preLaunchTask": "build-debug",
|
||||
"chip": "esp32s3",
|
||||
"flashingConfig": {
|
||||
"flashingEnabled": true,
|
||||
"haltAfterReset": true,
|
||||
"formatOptions": {
|
||||
"binaryFormat": "idf"
|
||||
}
|
||||
},
|
||||
"coreConfigs": [
|
||||
{
|
||||
"coreIndex": 0,
|
||||
"programBinary": "target/xtensa-esp32s3-none-elf/debug/${workspaceFolderBasename}",
|
||||
"rttEnabled": true,
|
||||
"rttChannelFormats": [
|
||||
{
|
||||
"channelNumber": 0,
|
||||
"dataFormat": "Defmt",
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "probe-rs-debug",
|
||||
"request": "attach",
|
||||
"name": "Attach",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"chip": "esp32s3",
|
||||
"coreConfigs": [
|
||||
{
|
||||
"coreIndex": 0,
|
||||
"programBinary": "target/xtensa-esp32s3-none-elf/debug/${workspaceFolderBasename}",
|
||||
"rttEnabled": true,
|
||||
"rttChannelFormats": [
|
||||
{
|
||||
"channelNumber": 0,
|
||||
"dataFormat": "Defmt",
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
13
.vscode/settings.json
vendored
Normal file
13
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"rust-analyzer.cargo.allTargets": false,
|
||||
"rust-analyzer.cargo.target": "xtensa-esp32s3-none-elf",
|
||||
"rust-analyzer.server.extraEnv": {
|
||||
"RUSTUP_TOOLCHAIN": "stable"
|
||||
},
|
||||
"rust-analyzer.check.extraEnv": {
|
||||
"RUSTUP_TOOLCHAIN": "esp"
|
||||
},
|
||||
"rust-analyzer.cargo.extraEnv": {
|
||||
"RUSTUP_TOOLCHAIN": "esp"
|
||||
},
|
||||
}
|
10
.vscode/tasks.json
vendored
Normal file
10
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build-debug",
|
||||
"command": "cargo build",
|
||||
"type": "shell",
|
||||
}
|
||||
]
|
||||
}
|
1553
Cargo.lock
generated
Normal file
1553
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
107
Cargo.toml
Normal file
107
Cargo.toml
Normal file
@ -0,0 +1,107 @@
|
||||
[package]
|
||||
edition = "2021"
|
||||
name = "espgenerate"
|
||||
version = "0.1.0"
|
||||
|
||||
#[[bin]]
|
||||
#name = "espgenerate"
|
||||
#path = "./src/bin/main.rs"
|
||||
#test = false
|
||||
|
||||
[dependencies]
|
||||
defmt = "1.0.1"
|
||||
panic-abort = "0.3.2"
|
||||
#panic-rtt-target = { version = "0.2.0", features = [ "defmt"] }
|
||||
#rtt-target = { version = "0.6.1", features = [ "defmt"] }
|
||||
esp-bootloader-esp-idf = "0.1.0"
|
||||
esp-hal = { version = "=1.0.0-beta.1", features = [
|
||||
#"defmt",
|
||||
"esp32s3",
|
||||
"unstable",
|
||||
] }
|
||||
esp-println = { version = "0.14.0", features = [
|
||||
"esp32s3",
|
||||
"log-04",
|
||||
#"defmt-espflash",
|
||||
] }
|
||||
esp-backtrace = { version = "0.16.0", features = [
|
||||
#"defmt",
|
||||
"println",
|
||||
"esp32s3",
|
||||
] }
|
||||
#esp32s3-hal = { version = "0.15.1", features = [
|
||||
# "async",
|
||||
# "embassy",
|
||||
# "embassy-time-timg0"
|
||||
#] }
|
||||
|
||||
#embassy-net = { version = "0.7.0", features = [
|
||||
# "defmt",
|
||||
# "dhcpv4",
|
||||
# "medium-ethernet",
|
||||
# "tcp",
|
||||
# "udp",
|
||||
#] }
|
||||
#embedded-io = { version = "0.6.1", features = ["defmt-03"] }
|
||||
#embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
|
||||
#esp-alloc = { version = "0.8.0", features = ["defmt"] }
|
||||
# for more networking protocol support see https://crates.io/crates/edge-net
|
||||
#bt-hci = { version = "0.2.1", features = [] }
|
||||
critical-section = "1.2.0"
|
||||
embassy-executor = { version = "0.7.0", features = [
|
||||
#"defmt",
|
||||
"task-arena-size-20480",
|
||||
] }
|
||||
embassy-time = { version = "0.4.0", features = [ #"defmt"
|
||||
] }
|
||||
esp-hal-embassy = { version = "0.8.1", features = [ #"defmt",
|
||||
"esp32s3",
|
||||
] }
|
||||
|
||||
#esp-wifi = { version = "0.14.1", features = [
|
||||
# "ble",
|
||||
# "builtin-scheduler",
|
||||
# "coex",
|
||||
# "defmt",
|
||||
# "esp-alloc",
|
||||
# "esp32s3",
|
||||
# "smoltcp",
|
||||
# "wifi",
|
||||
#] }
|
||||
#smoltcp = { version = "0.12.0", default-features = false, features = [
|
||||
# "defmt",
|
||||
# "medium-ethernet",
|
||||
# "multicast",
|
||||
# "proto-dhcpv4",
|
||||
# "proto-dns",
|
||||
# "proto-ipv4",
|
||||
# "socket-dns",
|
||||
# "socket-icmp",
|
||||
# "socket-raw",
|
||||
# "socket-tcp",
|
||||
# "socket-udp",
|
||||
#] }
|
||||
#static_cell = { version = "2.1.0", features = ["nightly"] }
|
||||
#trouble-host = { version = "0.1.0", features = ["gatt"] }
|
||||
|
||||
#[dev-dependencies]
|
||||
#embedded-test = { version = "0.6.0", features = [
|
||||
# "defmt",
|
||||
# "embassy",
|
||||
# "external-executor",
|
||||
# "xtensa-semihosting",
|
||||
#] }
|
||||
|
||||
[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
|
43
README.md
Normal file
43
README.md
Normal file
@ -0,0 +1,43 @@
|
||||
# Rust Embassy ESP32
|
||||
|
||||
|
||||
## 🔧 Binghe 2.13″ E-Ink LoRa with ESP‑32‑S3 - Specs
|
||||
|
||||
| Feature | Specification |
|
||||
| -------------------- | ----------------------------------------------------------- |
|
||||
| MCU | ESP32‑S3 FN8 (dual-core Xtensa LX7 @240 MHz, BT 5, USB‑OTG) |
|
||||
| SRAM / Flash | 512 KiB SRAM (+ external PSRAM support), \~8 MiB Flash |
|
||||
| LoRa Chip | SX1262 (433/470–510/863–928 MHz) |
|
||||
| Display | 2.13″ B/W E‑Ink, 250 × 122 px, partial/full refresh |
|
||||
| Power Inputs | USB‑C, LiPo battery (3–5 V) |
|
||||
| Battery Charging | TP4054 Li‑ion Li‑Po charger |
|
||||
| Sleep Current | \~20 µA deep sleep |
|
||||
| Display Retention | 180+ days when unpowered |
|
||||
| Area & Weight | \~88 × 30 × 25 mm, \~60 g |
|
||||
| Operating Conditions | 0–50 °C, 35–70 % RH |
|
||||
| Connectivity | Wi‑Fi 2.4 GHz, BT 5 (LE), LoRa |
|
||||
| UART Bridge | CP2102 (USB‑UART) |
|
||||
| Antenna | On-board LoRa antenna, IPEX + SMA |
|
||||
|
||||
# Software
|
||||
```
|
||||
sudo apt-get install -y gcc build-essential curl pkg-config
|
||||
# https://github.com/esp-rs/espup
|
||||
cargo install espup --locked
|
||||
espup install
|
||||
source $HOME/export-esp.sh
|
||||
. /home/robert/export-esp.sh
|
||||
espup completions zsh > ~/.zfunc/_espup
|
||||
|
||||
# https://github.com/esp-rs/espflash
|
||||
cargo install cargo-espflash --locked
|
||||
cargo install espflash --locked
|
||||
|
||||
# build & flash
|
||||
cargo build --release
|
||||
cargo espflash board-info
|
||||
cargo espflash flash --chip esp32s3 --monitor --release --bin main
|
||||
```
|
||||
|
||||
when starting the project remember to source your espconfig:
|
||||
`. $HOME/export-esp.sh`
|
52
build.rs
Normal file
52
build.rs
Normal file
@ -0,0 +1,52 @@
|
||||
fn main() {
|
||||
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()
|
||||
);
|
||||
}
|
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "esp"
|
37
src/bin/main.rs
Normal file
37
src/bin/main.rs
Normal file
@ -0,0 +1,37 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![deny(
|
||||
clippy::mem_forget,
|
||||
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
|
||||
holding buffers for the duration of a data transfer."
|
||||
)]
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::{clock::CpuClock, timer::systimer::SystemTimer};
|
||||
use esp_println::println;
|
||||
use panic_abort as _;
|
||||
|
||||
//extern crate alloc;
|
||||
|
||||
esp_bootloader_esp_idf::esp_app_desc!();
|
||||
|
||||
#[esp_hal_embassy::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
println!("Embassy starting!");
|
||||
|
||||
let config: esp_hal::Config = esp_hal::Config::default()
|
||||
.with_cpu_clock(CpuClock::_240MHz);
|
||||
let peripherals: esp_hal::peripherals::Peripherals = esp_hal::init(config);
|
||||
|
||||
let timer0: SystemTimer<'_> = SystemTimer::new(peripherals.SYSTIMER);
|
||||
esp_hal_embassy::init(timer0.alarm0);
|
||||
|
||||
println!("Embassy initialized!");
|
||||
|
||||
loop {
|
||||
println!("Hello world!");
|
||||
Timer::after(Duration::from_millis(500)).await;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user