Flashing works.

This commit is contained in:
Shaun Reed 2025-09-27 20:12:13 -04:00
parent 08639679fb
commit c087c2446a
4 changed files with 47 additions and 35 deletions

View File

@ -1,16 +1,16 @@
[build] [target.xtensa-esp32-none-elf]
target = "xtensa-esp32-espidf" runner = "espflash flash --monitor --chip esp32"
[target.xtensa-esp32-espidf]
linker = "ldproxy"
runner = "espflash flash --monitor"
rustflags = [ "--cfg", "espidf_time64"]
[unstable]
build-std = ["std", "panic_abort"]
[env] [env]
MCU="esp32" ESP_LOG = "info"
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
ESP_IDF_VERSION = "v5.3.3"
[build]
rustflags = [
"-C", "link-arg=-Wl,-Tlinkall.x",
"-C", "link-arg=-nostartfiles",
]
target = "xtensa-esp32-none-elf"
[unstable]
build-std = ["core"]

View File

@ -1,10 +1,12 @@
[package] [package]
name = "aht20" name = "aht20"
version = "0.1.0" version = "0.1.0"
authors = ["shaun"] authors = ["Shaun Reed <shaunrd0@gmail.com>"]
edition = "2021" edition = "2021"
resolver = "2" resolver = "2"
rust-version = "1.77" rust-version = "1.77"
description = "test"
publish = false
[[bin]] [[bin]]
name = "aht20" name = "aht20"
@ -19,17 +21,27 @@ opt-level = "z"
[features] [features]
default = [] default = []
esp32 = [
"esp-backtrace/esp32",
"esp-hal/esp32",
"esp-bootloader-esp-idf/esp32",
]
experimental = ["esp-idf-svc/experimental"] #experimental = ["esp-idf-svc/experimental"]
[dependencies] [dependencies]
log = "0.4" log = "0.4"
esp-idf-svc = "0.51"
embedded-hal = "1.0.0" embedded-hal = "1.0.0"
esp-backtrace = "0.17.0" esp-backtrace = { version = "0.17.0", features = ["esp32", "println", "panic-handler"] }
esp-hal = { version = "1.0.0-rc.0", features = ["unstable"] } esp-hal = { version = "1.0.0-rc.0", features = ["esp32", "unstable"] }
fugit = "0.3.7" esp-println = { version = "0.15.0", features = ["auto", "log-04"] }
esp-println = { version = "0.15.0", features = ["log-04"] } esp-bootloader-esp-idf = { version = "0.2.0", default-features = false, features = ["esp-rom-sys", "log-04", "esp32"] }
#esp-rom-sys = { version = "0.1.1", features = ["esp32"] }
#esp-idf-svc = { version = "0.51", features = [""], default-features = false}
#esp-idf-hal = "0.45.2"
#anyhow = "1.0.98"
#fugit = "0.3.7"
#esp-rom-sys = { version = "0.1.1", features = ["esp32"] }
# --- Optional Embassy Integration --- # --- Optional Embassy Integration ---
# esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync"] } # esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync"] }

View File

@ -1,3 +0,0 @@
fn main() {
embuild::espidf::sysenv::output();
}

View File

@ -1,6 +1,13 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
use embedded_hal::{delay::DelayNs, i2c::I2c as I2cEmbedded};
use esp_backtrace as _;
use esp_hal::{
delay::Delay,
xtensa_lx_rt::entry,
};
/// Represents a reading from the sensor. /// Represents a reading from the sensor.
pub struct SensorReading<T> { pub struct SensorReading<T> {
pub humidity: T, pub humidity: T,
@ -111,19 +118,15 @@ impl<I: I2cEmbedded, D: DelayNs> Dht20<I, D> {
} }
} }
use embedded_hal::{delay::DelayNs, i2c::I2c as I2cEmbedded}; // #[panic_handler]
use esp_backtrace as _; // fn panic(_: &core::panic::PanicInfo) -> ! {
use esp_hal::{ // loop {}
clock::CpuClock, // }
delay::Delay,
gpio::{Level, Pull},
i2c::master::I2c,
xtensa_lx_rt::entry,
};
use fugit::{ExtU64, HertzU32};
esp_bootloader_esp_idf::esp_app_desc!();
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
let peripherals = esp_hal::init(esp_hal::Config::default()); let peripherals = esp_hal::init(esp_hal::Config::default());
esp_println::logger::init_logger_from_env(); esp_println::logger::init_logger_from_env();
let mut delay = Delay::new(); let mut delay = Delay::new();
@ -132,8 +135,8 @@ fn main() -> ! {
let i2c_for_dht20 = let i2c_for_dht20 =
esp_hal::i2c::master::I2c::new(peripherals.I2C0, esp_hal::i2c::master::Config::default()) esp_hal::i2c::master::I2c::new(peripherals.I2C0, esp_hal::i2c::master::Config::default())
.unwrap() .unwrap()
.with_sda(peripherals.pins.gpio21) .with_sda(peripherals.GPIO21)
.with_scl(peripherals.pins.gpio22); .with_scl(peripherals.GPIO22);
let mut dht20 = Dht20::new(i2c_for_dht20, delay); let mut dht20 = Dht20::new(i2c_for_dht20, delay);
loop { loop {