From 280caad3786bf3bb7c2de49d4aef8389b7be62db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 10 Nov 2023 12:51:47 +0100 Subject: [PATCH] RISC-V: Make atomic emulation opt-in (#904) * RISC-V: Make atomic emulation opt-in * Update embassy-executor, embassy-sync * Don't automatically enable portable-atomic * Update changelog * Fix warnings --- .github/workflows/ci.yml | 15 +- CHANGELOG.md | 2 + esp-hal-common/Cargo.toml | 21 ++- esp-hal-common/build.rs | 22 +++ esp-hal-common/src/analog/adc/riscv.rs | 10 +- esp-hal-common/src/dma/mod.rs | 6 + .../src/embassy/executor/xtensa/interrupt.rs | 14 +- .../src/embassy/executor/xtensa/thread.rs | 11 +- .../src/embassy/time_driver_timg.rs | 6 +- esp-hal-common/src/interrupt/riscv.rs | 159 +++++++++--------- esp-hal-common/src/lib.rs | 13 +- esp32-hal/Cargo.toml | 6 +- esp32-hal/examples/embassy_i2c.rs | 2 +- esp32-hal/examples/spi_eh1_device_loopback.rs | 2 +- esp32-hal/examples/spi_eh1_loopback.rs | 5 +- .../spi_halfduplex_read_manufacturer_id.rs | 2 +- esp32-hal/examples/spi_loopback.rs | 5 +- esp32c2-hal/.cargo/config.toml | 16 -- esp32c2-hal/Cargo.toml | 11 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32c2-hal/examples/spi_eh1_loopback.rs | 5 +- .../spi_halfduplex_read_manufacturer_id.rs | 2 +- esp32c2-hal/examples/spi_loopback.rs | 5 +- esp32c3-hal/.cargo/config.toml | 16 -- esp32c3-hal/Cargo.toml | 11 +- esp32c3-hal/examples/embassy_hello_world.rs | 1 - .../examples/spi_eh1_device_loopback.rs | 2 +- esp32c3-hal/examples/spi_eh1_loopback.rs | 5 +- .../spi_halfduplex_read_manufacturer_id.rs | 2 +- esp32c3-hal/examples/spi_loopback.rs | 5 +- esp32c6-hal/Cargo.toml | 6 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32c6-hal/examples/spi_eh1_loopback.rs | 5 +- .../spi_halfduplex_read_manufacturer_id.rs | 2 +- esp32c6-hal/examples/spi_loopback.rs | 5 +- esp32h2-hal/Cargo.toml | 6 +- .../examples/spi_eh1_device_loopback.rs | 2 +- esp32h2-hal/examples/spi_eh1_loopback.rs | 5 +- .../spi_halfduplex_read_manufacturer_id.rs | 2 +- esp32h2-hal/examples/spi_loopback.rs | 5 +- esp32s2-hal/Cargo.toml | 8 +- esp32s2-hal/examples/clock_monitor.rs | 1 - esp32s2-hal/examples/embassy_hello_world.rs | 1 - esp32s2-hal/examples/embassy_rmt_rx.rs | 1 - esp32s2-hal/examples/embassy_rmt_tx.rs | 1 - esp32s2-hal/examples/i2c_display.rs | 1 - esp32s2-hal/examples/ledc.rs | 1 - esp32s2-hal/src/lib.rs | 2 - esp32s3-hal/Cargo.toml | 6 +- 49 files changed, 218 insertions(+), 228 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fba36820e..8ae2289de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -628,25 +628,26 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@v1 with: + target: riscv32imc-unknown-none-elf, riscv32imac-unknown-none-elf toolchain: stable components: clippy - uses: Swatinem/rust-cache@v2 # Run clippy on all packages targeting RISC-V. - name: clippy (esp-riscv-rt) - run: cargo +stable clippy --manifest-path=esp-riscv-rt/Cargo.toml -- -D warnings + run: cd esp-riscv-rt && cargo +stable clippy -- -D warnings - name: clippy (esp32c2-hal) - run: cargo +stable clippy --manifest-path=esp32c2-hal/Cargo.toml -- -D warnings + run: cd esp32c2-hal && cargo +stable clippy -- -D warnings - name: clippy (esp32c3-hal) - run: cargo +stable clippy --manifest-path=esp32c3-hal/Cargo.toml -- -D warnings + run: cd esp32c3-hal && cargo +stable clippy -- -D warnings - name: clippy (esp32c6-hal) - run: cargo +stable clippy --manifest-path=esp32c6-hal/Cargo.toml -- -D warnings + run: cd esp32c6-hal && cargo +stable clippy -- -D warnings - name: clippy (esp32c6-lp-hal) - run: cargo +stable clippy --manifest-path=esp32c6-lp-hal/Cargo.toml -- -D warnings -A asm-sub-register + run: cd esp32c6-lp-hal && cargo +stable clippy -- -D warnings -A asm-sub-register - name: clippy (esp32h2-hal) - run: cargo +stable clippy --manifest-path=esp32h2-hal/Cargo.toml -- -D warnings + run: cd esp32h2-hal && cargo +stable clippy -- -D warnings - name: clippy (esp-ulp-riscv-hal) - run: cargo +stable clippy --manifest-path=esp-ulp-riscv-hal/Cargo.toml --features=esp32s3 -- -D warnings -A asm-sub-register + run: cd esp-ulp-riscv-hal && cargo +stable clippy --features=esp32s3 -- -D warnings -A asm-sub-register clippy-xtensa: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index d8fef39a0..cca13b749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- C2, C3: atomic emulation trap is now opt-in (#904) + ### Fixed - ESP32-C2/C3 examples: fix build error (#899) diff --git a/esp-hal-common/Cargo.toml b/esp-hal-common/Cargo.toml index 67a076e84..71ef1b8a4 100644 --- a/esp-hal-common/Cargo.toml +++ b/esp-hal-common/Cargo.toml @@ -33,17 +33,20 @@ strum = { version = "0.25.0", default-features = false, features void = { version = "1.0.2", default-features = false } usb-device = { version = "0.2.9", optional = true } +# atomic polyfill options +portable-atomic = { version = "1.5.1", default-features = false, optional = true } +riscv-atomic-emulation-trap = { version = "0.4.1", optional = true } + # async embedded-hal-async = { version = "=1.0.0-rc.1", optional = true } embedded-io-async = { version = "0.6.0", optional = true } -embassy-executor = { version = "0.3.0", optional = true, features = ["integrated-timers"] } +embassy-executor = { version = "0.3.2", optional = true, features = ["integrated-timers"] } embassy-futures = { version = "0.1.0", optional = true } -embassy-sync = { version = "0.3.0", optional = true } +embassy-sync = { version = "0.4.0", optional = true } embassy-time = { version = "0.1.5", optional = true, features = ["nightly"] } # RISC-V esp-riscv-rt = { version = "0.5.0", optional = true, path = "../esp-riscv-rt" } -riscv-atomic-emulation-trap = { version = "0.4.1", optional = true } # Xtensa xtensa-lx = { version = "0.8.0", optional = true } @@ -69,11 +72,11 @@ serde = { version = "1.0.190", features = ["derive"] } [features] esp32 = ["xtensa", "esp32/rt", "procmacros/esp32", "xtensa-lx/esp32", "xtensa-lx-rt/esp32"] -esp32c2 = ["riscv", "esp32c2/rt", "procmacros/esp32c2"] -esp32c3 = ["riscv", "esp32c3/rt", "procmacros/esp32c3"] +esp32c2 = ["riscv", "esp32c2/rt", "procmacros/esp32c2", "portable-atomic?/unsafe-assume-single-core"] +esp32c3 = ["riscv", "esp32c3/rt", "procmacros/esp32c3", "portable-atomic?/unsafe-assume-single-core"] esp32c6 = ["riscv", "esp32c6/rt", "procmacros/esp32c6"] esp32h2 = ["riscv", "esp32h2/rt", "procmacros/esp32h2"] -esp32s2 = ["xtensa", "esp32s2/rt", "procmacros/esp32s2", "xtensa-lx/esp32s2", "xtensa-lx-rt/esp32s2", "usb-otg"] +esp32s2 = ["xtensa", "esp32s2/rt", "procmacros/esp32s2", "xtensa-lx/esp32s2", "xtensa-lx-rt/esp32s2", "usb-otg", "portable-atomic?/unsafe-assume-single-core"] esp32s3 = ["xtensa", "esp32s3/rt", "procmacros/esp32s3", "xtensa-lx/esp32s3", "xtensa-lx-rt/esp32s3", "usb-otg"] # Crystal frequency selection (ESP32 and ESP32-C2 only!) @@ -125,9 +128,13 @@ embassy-time-systick = [] embassy-time-timg0 = [] # Architecture-specific features (intended for internal use) -riscv = ["critical-section/restore-state-u8", "esp-riscv-rt", "esp-riscv-rt/zero-bss", "riscv-atomic-emulation-trap"] +riscv = ["critical-section/restore-state-u8", "esp-riscv-rt", "esp-riscv-rt/zero-bss"] xtensa = ["critical-section/restore-state-u32"] +portable-atomic = ["dep:portable-atomic"] +riscv-atomic-emulation = ["dep:riscv-atomic-emulation-trap", "atomic-emulation"] +atomic-emulation = [] + # Initialize / clear data sections and RTC memory rv-init-data = ["esp-riscv-rt/init-data", "esp-riscv-rt/init-rw-text"] rv-zero-rtc-bss = ["esp-riscv-rt/zero-rtc-fast-bss"] diff --git a/esp-hal-common/build.rs b/esp-hal-common/build.rs index c0e5afb83..095d30e81 100644 --- a/esp-hal-common/build.rs +++ b/esp-hal-common/build.rs @@ -136,6 +136,28 @@ fn main() -> Result<(), Box> { unreachable!() // We've confirmed exactly one known device was selected }; + // The C6 has an "atomic" peripheral but it's an exception, not the rule + // For S2, we just keep lying for now. The target has emulation support + // force-enabled. + let has_native_atomic_support = matches!( + device_name, + "esp32" | "esp32s2" | "esp32s3" | "esp32c6" | "esp32h2" + ); + + let atomic_emulation_enabled = cfg!(feature = "atomic-emulation"); + let portable_atomic_enabled = cfg!(feature = "portable-atomic"); + + if atomic_emulation_enabled && portable_atomic_enabled { + panic!("The `atomic-emulation` and `portable-atomic` features cannot be used together"); + } + + if has_native_atomic_support { + if atomic_emulation_enabled { + println!("cargo:warning={} has native atomic instructions, the `atomic-emulation` feature is not needed", device_name); + } + println!("cargo:rustc-cfg=has_native_atomic_support"); + } + // Load the configuration file for the configured device: let chip_toml_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("devices") diff --git a/esp-hal-common/src/analog/adc/riscv.rs b/esp-hal-common/src/analog/adc/riscv.rs index 130159c78..e3d1e491e 100644 --- a/esp-hal-common/src/analog/adc/riscv.rs +++ b/esp-hal-common/src/analog/adc/riscv.rs @@ -687,8 +687,6 @@ macro_rules! impl_adc_interface { } } -pub use implementation::*; - #[cfg(esp32c2)] mod implementation { //! # Analog to digital (ADC) conversion support. @@ -722,7 +720,7 @@ mod implementation { //! } //! ``` - pub use crate::analog::ADC1; + use crate::analog::ADC1; impl_adc_interface! { ADC1 [ @@ -769,7 +767,7 @@ mod implementation { //! } //! ``` - pub use crate::analog::{ADC1, ADC2}; + use crate::analog::{ADC1, ADC2}; impl_adc_interface! { ADC1 [ @@ -821,7 +819,7 @@ mod implementation { //! } //! ``` - pub use crate::analog::ADC1; + use crate::analog::ADC1; impl_adc_interface! { ADC1 [ @@ -869,7 +867,7 @@ mod implementation { //! } //! ``` - pub use crate::analog::ADC1; + use crate::analog::ADC1; impl_adc_interface! { ADC1 [ diff --git a/esp-hal-common/src/dma/mod.rs b/esp-hal-common/src/dma/mod.rs index b1cff8d38..f4ccda7a9 100644 --- a/esp-hal-common/src/dma/mod.rs +++ b/esp-hal-common/src/dma/mod.rs @@ -1153,11 +1153,13 @@ pub(crate) mod asynch { } } + #[cfg(any(i2s0, i2s1))] pub struct DmaTxDoneChFuture<'a, TX> { pub(crate) tx: &'a mut TX, _a: (), } + #[cfg(any(i2s0, i2s1))] impl<'a, TX> DmaTxDoneChFuture<'a, TX> where TX: Tx, @@ -1168,6 +1170,7 @@ pub(crate) mod asynch { } } + #[cfg(any(i2s0, i2s1))] impl<'a, TX> core::future::Future for DmaTxDoneChFuture<'a, TX> where TX: Tx, @@ -1187,11 +1190,13 @@ pub(crate) mod asynch { } } + #[cfg(any(i2s0, i2s1))] pub struct DmaRxDoneChFuture<'a, RX> { pub(crate) rx: &'a mut RX, _a: (), } + #[cfg(any(i2s0, i2s1))] impl<'a, RX> DmaRxDoneChFuture<'a, RX> where RX: Rx, @@ -1202,6 +1207,7 @@ pub(crate) mod asynch { } } + #[cfg(any(i2s0, i2s1))] impl<'a, RX> core::future::Future for DmaRxDoneChFuture<'a, RX> where RX: Rx, diff --git a/esp-hal-common/src/embassy/executor/xtensa/interrupt.rs b/esp-hal-common/src/embassy/executor/xtensa/interrupt.rs index 0c2db617c..2ddcf67a5 100644 --- a/esp-hal-common/src/embassy/executor/xtensa/interrupt.rs +++ b/esp-hal-common/src/embassy/executor/xtensa/interrupt.rs @@ -1,14 +1,14 @@ //! Multicore-aware interrupt-mode executor. -use core::{ - cell::UnsafeCell, - marker::PhantomData, - mem::MaybeUninit, - sync::atomic::{AtomicUsize, Ordering}, -}; +use core::{cell::UnsafeCell, marker::PhantomData, mem::MaybeUninit}; use embassy_executor::{raw, SendSpawner}; -use crate::{get_core, interrupt, peripherals, peripherals::SYSTEM}; +use crate::{ + atomic::{AtomicUsize, Ordering}, + get_core, + interrupt, + peripherals::{self, SYSTEM}, +}; static FROM_CPU_IRQ_USED: AtomicUsize = AtomicUsize::new(0); diff --git a/esp-hal-common/src/embassy/executor/xtensa/thread.rs b/esp-hal-common/src/embassy/executor/xtensa/thread.rs index 509c99a86..3defbee35 100644 --- a/esp-hal-common/src/embassy/executor/xtensa/thread.rs +++ b/esp-hal-common/src/embassy/executor/xtensa/thread.rs @@ -1,12 +1,13 @@ //! Multicore-aware thread-mode embassy executor. -use core::{ - marker::PhantomData, - sync::atomic::{AtomicBool, Ordering}, -}; +use core::marker::PhantomData; use embassy_executor::{raw, Spawner}; -use crate::{get_core, prelude::interrupt}; +use crate::{ + atomic::{AtomicBool, Ordering}, + get_core, + prelude::interrupt, +}; #[cfg(multi_core)] use crate::{ interrupt, diff --git a/esp-hal-common/src/embassy/time_driver_timg.rs b/esp-hal-common/src/embassy/time_driver_timg.rs index ea0002507..0f039a239 100644 --- a/esp-hal-common/src/embassy/time_driver_timg.rs +++ b/esp-hal-common/src/embassy/time_driver_timg.rs @@ -86,15 +86,15 @@ impl EmbassyTimer { pub(crate) fn set_alarm( &self, - alarm: embassy_time::driver::AlarmHandle, + _alarm: embassy_time::driver::AlarmHandle, timestamp: u64, ) -> bool { - critical_section::with(|cs| { + critical_section::with(|_cs| { // The hardware fires the alarm even if timestamp is lower than the current // time. In this case the interrupt handler will pend a wakeup when we exit the // critical section. #[cfg(any(esp32, esp32s2, esp32s3))] - if alarm.id() == 1 { + if _alarm.id() == 1 { let mut tg = unsafe { Timer1::::steal() }; Self::arm(&mut tg, timestamp); return; diff --git a/esp-hal-common/src/interrupt/riscv.rs b/esp-hal-common/src/interrupt/riscv.rs index c85ae0848..8568e53b1 100644 --- a/esp-hal-common/src/interrupt/riscv.rs +++ b/esp-hal-common/src/interrupt/riscv.rs @@ -461,87 +461,90 @@ pub unsafe extern "C" fn start_trap_rust_hal(trap_frame: *mut TrapFrame) { /// # Safety /// /// This function is called from an trap handler. -#[doc(hidden)] -unsafe fn handle_exception(pc: usize, trap_frame: *mut TrapFrame) { - let insn: usize = *(pc as *const _); - let needs_atomic_emulation = (insn & 0b1111111) == 0b0101111; - if !needs_atomic_emulation { - extern "C" { - fn ExceptionHandler(tf: *mut TrapFrame); - } - ExceptionHandler(trap_frame); +unsafe fn handle_exception(_pc: usize, trap_frame: *mut TrapFrame) { + #[cfg(feature = "atomic-emulation")] + { + let insn: usize = *(_pc as *const _); + let needs_atomic_emulation = (insn & 0b1111111) == 0b0101111; + if needs_atomic_emulation { + let mut frame = [ + 0, + (*trap_frame).ra, + (*trap_frame).sp, + (*trap_frame).gp, + (*trap_frame).tp, + (*trap_frame).t0, + (*trap_frame).t1, + (*trap_frame).t2, + (*trap_frame).s0, + (*trap_frame).s1, + (*trap_frame).a0, + (*trap_frame).a1, + (*trap_frame).a2, + (*trap_frame).a3, + (*trap_frame).a4, + (*trap_frame).a5, + (*trap_frame).a6, + (*trap_frame).a7, + (*trap_frame).s2, + (*trap_frame).s3, + (*trap_frame).s4, + (*trap_frame).s5, + (*trap_frame).s6, + (*trap_frame).s7, + (*trap_frame).s8, + (*trap_frame).s9, + (*trap_frame).s10, + (*trap_frame).s11, + (*trap_frame).t3, + (*trap_frame).t4, + (*trap_frame).t5, + (*trap_frame).t6, + ]; - return; + riscv_atomic_emulation_trap::atomic_emulation((*trap_frame).pc, &mut frame); + + (*trap_frame).ra = frame[1]; + (*trap_frame).sp = frame[2]; + (*trap_frame).gp = frame[3]; + (*trap_frame).tp = frame[4]; + (*trap_frame).t0 = frame[5]; + (*trap_frame).t1 = frame[6]; + (*trap_frame).t2 = frame[7]; + (*trap_frame).s0 = frame[8]; + (*trap_frame).s1 = frame[9]; + (*trap_frame).a0 = frame[10]; + (*trap_frame).a1 = frame[11]; + (*trap_frame).a2 = frame[12]; + (*trap_frame).a3 = frame[13]; + (*trap_frame).a4 = frame[14]; + (*trap_frame).a5 = frame[15]; + (*trap_frame).a6 = frame[16]; + (*trap_frame).a7 = frame[17]; + (*trap_frame).s2 = frame[18]; + (*trap_frame).s3 = frame[19]; + (*trap_frame).s4 = frame[20]; + (*trap_frame).s5 = frame[21]; + (*trap_frame).s6 = frame[22]; + (*trap_frame).s7 = frame[23]; + (*trap_frame).s8 = frame[24]; + (*trap_frame).s9 = frame[25]; + (*trap_frame).s10 = frame[26]; + (*trap_frame).s11 = frame[27]; + (*trap_frame).t3 = frame[28]; + (*trap_frame).t4 = frame[29]; + (*trap_frame).t5 = frame[30]; + (*trap_frame).t6 = frame[31]; + (*trap_frame).pc = pc + 4; + + return; + } } - let mut frame = [ - 0, - (*trap_frame).ra, - (*trap_frame).sp, - (*trap_frame).gp, - (*trap_frame).tp, - (*trap_frame).t0, - (*trap_frame).t1, - (*trap_frame).t2, - (*trap_frame).s0, - (*trap_frame).s1, - (*trap_frame).a0, - (*trap_frame).a1, - (*trap_frame).a2, - (*trap_frame).a3, - (*trap_frame).a4, - (*trap_frame).a5, - (*trap_frame).a6, - (*trap_frame).a7, - (*trap_frame).s2, - (*trap_frame).s3, - (*trap_frame).s4, - (*trap_frame).s5, - (*trap_frame).s6, - (*trap_frame).s7, - (*trap_frame).s8, - (*trap_frame).s9, - (*trap_frame).s10, - (*trap_frame).s11, - (*trap_frame).t3, - (*trap_frame).t4, - (*trap_frame).t5, - (*trap_frame).t6, - ]; - riscv_atomic_emulation_trap::atomic_emulation((*trap_frame).pc, &mut frame); - - (*trap_frame).ra = frame[1]; - (*trap_frame).sp = frame[2]; - (*trap_frame).gp = frame[3]; - (*trap_frame).tp = frame[4]; - (*trap_frame).t0 = frame[5]; - (*trap_frame).t1 = frame[6]; - (*trap_frame).t2 = frame[7]; - (*trap_frame).s0 = frame[8]; - (*trap_frame).s1 = frame[9]; - (*trap_frame).a0 = frame[10]; - (*trap_frame).a1 = frame[11]; - (*trap_frame).a2 = frame[12]; - (*trap_frame).a3 = frame[13]; - (*trap_frame).a4 = frame[14]; - (*trap_frame).a5 = frame[15]; - (*trap_frame).a6 = frame[16]; - (*trap_frame).a7 = frame[17]; - (*trap_frame).s2 = frame[18]; - (*trap_frame).s3 = frame[19]; - (*trap_frame).s4 = frame[20]; - (*trap_frame).s5 = frame[21]; - (*trap_frame).s6 = frame[22]; - (*trap_frame).s7 = frame[23]; - (*trap_frame).s8 = frame[24]; - (*trap_frame).s9 = frame[25]; - (*trap_frame).s10 = frame[26]; - (*trap_frame).s11 = frame[27]; - (*trap_frame).t3 = frame[28]; - (*trap_frame).t4 = frame[29]; - (*trap_frame).t5 = frame[30]; - (*trap_frame).t6 = frame[31]; - (*trap_frame).pc = pc + 4; + extern "C" { + fn ExceptionHandler(tf: *mut TrapFrame); + } + ExceptionHandler(trap_frame); } #[doc(hidden)] diff --git a/esp-hal-common/src/lib.rs b/esp-hal-common/src/lib.rs index dfcf35b68..7e6134687 100644 --- a/esp-hal-common/src/lib.rs +++ b/esp-hal-common/src/lib.rs @@ -26,7 +26,7 @@ #![cfg_attr(xtensa, feature(asm_experimental_arch))] #![cfg_attr( feature = "async", - allow(incomplete_features), + allow(incomplete_features, stable_features, unknown_lints, async_fn_in_trait), feature(async_fn_in_trait), feature(impl_trait_projections) )] @@ -161,6 +161,15 @@ pub mod trapframe { // be directly exposed. mod soc; +#[allow(unused_imports)] +mod atomic { + #[cfg(any(has_native_atomic_support, feature = "atomic-emulation"))] + pub use core::sync::atomic::*; + + #[cfg(feature = "portable-atomic")] + pub use portable_atomic::*; +} + #[no_mangle] extern "C" fn EspDefaultHandler(_level: u32, _interrupt: peripherals::Interrupt) { #[cfg(feature = "log")] @@ -317,7 +326,7 @@ mod critical_section_impl { #[cfg(multi_core)] mod multicore { - use core::sync::atomic::{AtomicUsize, Ordering}; + use crate::atomic::{AtomicUsize, Ordering}; // We're using a value that we know get_raw_core() will never return. This // avoids an unnecessary increment of the core ID. diff --git a/esp32-hal/Cargo.toml b/esp32-hal/Cargo.toml index 81d413ba7..f4e343647 100644 --- a/esp32-hal/Cargo.toml +++ b/esp32-hal/Cargo.toml @@ -32,8 +32,8 @@ embassy-time = { version = "0.1.5", features = ["nightly"], optional = true } aes = "0.8.3" critical-section = "1.1.2" crypto-bigint = { version = "0.5.3", default-features = false } -embassy-executor = { version = "0.3.0", features = ["nightly"] } -embassy-sync = "0.3.0" +embassy-executor = { version = "0.3.2", features = ["nightly"] } +embassy-sync = "0.4.0" embedded-graphics = "0.8.1" embedded-hal-1 = { version = "=1.0.0-rc.1", package = "embedded-hal" } embedded-hal-async = "=1.0.0-rc.1" @@ -47,7 +47,7 @@ lis3dh-async = "0.8.0" sha2 = { version = "0.10.8", default-features = false} smart-leds = "0.3.0" ssd1306 = "0.8.4" -static_cell = { version = "=1.2.0", features = ["nightly"] } +static_cell = { version = "2.0.0", features = ["nightly"] } [features] default = ["rt", "vectored", "xtal-40mhz"] diff --git a/esp32-hal/examples/embassy_i2c.rs b/esp32-hal/examples/embassy_i2c.rs index f13b1a6a7..ad2ef1ddd 100644 --- a/esp32-hal/examples/embassy_i2c.rs +++ b/esp32-hal/examples/embassy_i2c.rs @@ -21,7 +21,7 @@ use esp32_hal::{ embassy::{self}, i2c::I2C, interrupt, - peripherals::{Interrupt, Peripherals, I2C0}, + peripherals::{Interrupt, Peripherals}, prelude::*, timer::TimerGroup, IO, diff --git a/esp32-hal/examples/spi_eh1_device_loopback.rs b/esp32-hal/examples/spi_eh1_device_loopback.rs index fff1e5465..0c0d8e554 100644 --- a/esp32-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32-hal/examples/spi_eh1_device_loopback.rs @@ -25,7 +25,7 @@ use esp32_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Spi, SpiBusController}, + master::{Spi, SpiBusController}, SpiMode, }, Delay, diff --git a/esp32-hal/examples/spi_eh1_loopback.rs b/esp32-hal/examples/spi_eh1_loopback.rs index 64e9c6548..578c6eb50 100644 --- a/esp32-hal/examples/spi_eh1_loopback.rs +++ b/esp32-hal/examples/spi_eh1_loopback.rs @@ -22,10 +22,7 @@ use esp32_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32-hal/examples/spi_halfduplex_read_manufacturer_id.rs b/esp32-hal/examples/spi_halfduplex_read_manufacturer_id.rs index a3c9c5dd7..258f410d6 100644 --- a/esp32-hal/examples/spi_halfduplex_read_manufacturer_id.rs +++ b/esp32-hal/examples/spi_halfduplex_read_manufacturer_id.rs @@ -23,7 +23,7 @@ use esp32_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Address, Command, HalfDuplexReadWrite, Spi}, + master::{Address, Command, HalfDuplexReadWrite, Spi}, SpiDataMode, SpiMode, }, diff --git a/esp32-hal/examples/spi_loopback.rs b/esp32-hal/examples/spi_loopback.rs index 31d9dda6e..3720a2362 100644 --- a/esp32-hal/examples/spi_loopback.rs +++ b/esp32-hal/examples/spi_loopback.rs @@ -21,10 +21,7 @@ use esp32_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32c2-hal/.cargo/config.toml b/esp32c2-hal/.cargo/config.toml index 9b2287f08..c1bf8bdad 100644 --- a/esp32c2-hal/.cargo/config.toml +++ b/esp32c2-hal/.cargo/config.toml @@ -3,22 +3,6 @@ runner = "espflash flash --monitor" rustflags = [ "-C", "link-arg=-Tlinkall.x", "-C", "force-frame-pointers", - - # comment the cfgs below if you do _not_ wish to emulate atomics. - # enable the atomic codegen option for RISCV - "-C", "target-feature=+a", - # tell the core library have atomics even though it's not specified in the target definition - "--cfg", "target_has_atomic_load_store", - "--cfg", 'target_has_atomic_load_store="8"', - "--cfg", 'target_has_atomic_load_store="16"', - "--cfg", 'target_has_atomic_load_store="32"', - "--cfg", 'target_has_atomic_load_store="ptr"', - # enable cas - "--cfg", "target_has_atomic", - "--cfg", 'target_has_atomic="8"', - "--cfg", 'target_has_atomic="16"', - "--cfg", 'target_has_atomic="32"', - "--cfg", 'target_has_atomic="ptr"', ] [build] diff --git a/esp32c2-hal/Cargo.toml b/esp32c2-hal/Cargo.toml index 532f10964..405f9a550 100644 --- a/esp32c2-hal/Cargo.toml +++ b/esp32c2-hal/Cargo.toml @@ -30,7 +30,7 @@ embassy-time = { version = "0.1.5", features = ["nightly"], optional = true } [dev-dependencies] critical-section = "1.1.2" -embassy-executor = { version = "0.3.0", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } +embassy-executor = { version = "0.3.2", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } embedded-graphics = "0.8.1" embedded-hal-1 = { version = "=1.0.0-rc.1", package = "embedded-hal" } embedded-hal-async = "=1.0.0-rc.1" @@ -41,13 +41,15 @@ heapless = "0.7.16" lis3dh-async = "0.8.0" sha2 = { version = "0.10.8", default-features = false} ssd1306 = "0.8.4" -static_cell = { version = "=1.2.0", features = ["nightly"] } +portable-atomic = "1.5.1" +static_cell = { version = "2.0.0", features = ["nightly"] } +esp-hal-common = { features = ["portable-atomic"], path = "../esp-hal-common" } # enable portable-atomic by default for examples hex-literal = "0.4.1" crypto-bigint = {version = "0.5.3", default-features = false } elliptic-curve = {version = "0.13.6", default-features = false, features = ["sec1"] } p192 = {version = "0.13.0", default-features = false, features = ["arithmetic"] } p256 = {version = "0.13.2", default-features = false, features = ["arithmetic"] } -embassy-sync = "0.3.0" +embassy-sync = "0.4.0" [features] default = ["rt", "vectored", "xtal-40mhz"] @@ -69,6 +71,9 @@ embassy = ["esp-hal-common/embassy"] embassy-time-systick = ["esp-hal-common/embassy-time-systick", "embassy-time/tick-hz-16_000_000"] embassy-time-timg0 = ["esp-hal-common/embassy-time-timg0", "embassy-time/tick-hz-1_000_000"] +portable-atomic = ["esp-hal-common/portable-atomic"] +atomic-emulation = ["esp-hal-common/riscv-atomic-emulation"] + [profile.release] debug = true diff --git a/esp32c2-hal/examples/spi_eh1_device_loopback.rs b/esp32c2-hal/examples/spi_eh1_device_loopback.rs index 4d672607c..c2f22c164 100644 --- a/esp32c2-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32c2-hal/examples/spi_eh1_device_loopback.rs @@ -25,7 +25,7 @@ use esp32c2_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Spi, SpiBusController}, + master::{Spi, SpiBusController}, SpiMode, }, Delay, diff --git a/esp32c2-hal/examples/spi_eh1_loopback.rs b/esp32c2-hal/examples/spi_eh1_loopback.rs index 534ff2c8a..f7b3b97b3 100644 --- a/esp32c2-hal/examples/spi_eh1_loopback.rs +++ b/esp32c2-hal/examples/spi_eh1_loopback.rs @@ -22,10 +22,7 @@ use esp32c2_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32c2-hal/examples/spi_halfduplex_read_manufacturer_id.rs b/esp32c2-hal/examples/spi_halfduplex_read_manufacturer_id.rs index 83118bc6f..460ad8923 100644 --- a/esp32c2-hal/examples/spi_halfduplex_read_manufacturer_id.rs +++ b/esp32c2-hal/examples/spi_halfduplex_read_manufacturer_id.rs @@ -23,7 +23,7 @@ use esp32c2_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Address, Command, HalfDuplexReadWrite, Spi}, + master::{Address, Command, HalfDuplexReadWrite, Spi}, SpiDataMode, SpiMode, }, diff --git a/esp32c2-hal/examples/spi_loopback.rs b/esp32c2-hal/examples/spi_loopback.rs index 53534f224..cd13bd2d3 100644 --- a/esp32c2-hal/examples/spi_loopback.rs +++ b/esp32c2-hal/examples/spi_loopback.rs @@ -21,10 +21,7 @@ use esp32c2_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32c3-hal/.cargo/config.toml b/esp32c3-hal/.cargo/config.toml index 94569ce09..4f0290eac 100644 --- a/esp32c3-hal/.cargo/config.toml +++ b/esp32c3-hal/.cargo/config.toml @@ -3,22 +3,6 @@ runner = "espflash flash --monitor" rustflags = [ "-C", "link-arg=-Tlinkall.x", "-C", "force-frame-pointers", - - # comment the cfgs below if you do _not_ wish to emulate atomics. - # enable the atomic codegen option for RISCV - "-C", "target-feature=+a", - # tell the core library have atomics even though it's not specified in the target definition - "--cfg", "target_has_atomic_load_store", - "--cfg", 'target_has_atomic_load_store="8"', - "--cfg", 'target_has_atomic_load_store="16"', - "--cfg", 'target_has_atomic_load_store="32"', - "--cfg", 'target_has_atomic_load_store="ptr"', - # enable cas - "--cfg", "target_has_atomic", - "--cfg", 'target_has_atomic="8"', - "--cfg", 'target_has_atomic="16"', - "--cfg", 'target_has_atomic="32"', - "--cfg", 'target_has_atomic="ptr"', ] [build] diff --git a/esp32c3-hal/Cargo.toml b/esp32c3-hal/Cargo.toml index c2d07a431..774886d46 100644 --- a/esp32c3-hal/Cargo.toml +++ b/esp32c3-hal/Cargo.toml @@ -33,7 +33,7 @@ embassy-time = { version = "0.1.5", features = ["nightly"], optional = true } aes = "0.8.3" critical-section = "1.1.2" crypto-bigint = { version = "0.5.3", default-features = false } -embassy-executor = { version = "0.3.0", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } +embassy-executor = { version = "0.3.2", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } embedded-can = "0.4.1" embedded-graphics = "0.8.1" embedded-hal = { version = "0.2.7", features = ["unproven"] } @@ -49,8 +49,10 @@ lis3dh-async = "0.8.0" sha2 = { version = "0.10.8", default-features = false } smart-leds = "0.3.0" ssd1306 = "0.8.4" -static_cell = { version = "=1.2.0", features = ["nightly"] } -embassy-sync = "0.3.0" +portable-atomic = "1.5.1" +esp-hal-common = { features = ["portable-atomic"], path = "../esp-hal-common" } # enable portable-atomic by default for examples +static_cell = { version = "2.0.0", features = ["nightly"] } +embassy-sync = "0.4.0" [features] default = ["rt", "vectored", "esp-hal-common/rv-zero-rtc-bss"] @@ -71,6 +73,9 @@ embassy = ["esp-hal-common/embassy"] embassy-time-systick = ["esp-hal-common/embassy-time-systick", "embassy-time/tick-hz-16_000_000"] embassy-time-timg0 = ["esp-hal-common/embassy-time-timg0", "embassy-time/tick-hz-1_000_000"] +portable-atomic = ["esp-hal-common/portable-atomic"] +atomic-emulation = ["esp-hal-common/riscv-atomic-emulation"] + [profile.release] debug = true diff --git a/esp32c3-hal/examples/embassy_hello_world.rs b/esp32c3-hal/examples/embassy_hello_world.rs index b372af6cb..1ef712524 100644 --- a/esp32c3-hal/examples/embassy_hello_world.rs +++ b/esp32c3-hal/examples/embassy_hello_world.rs @@ -11,7 +11,6 @@ use embassy_executor::Spawner; use embassy_time::{Duration, Timer}; use esp32c3_hal::{clock::ClockControl, embassy, peripherals::Peripherals, prelude::*}; use esp_backtrace as _; -use static_cell::make_static; #[embassy_executor::task] async fn run() { diff --git a/esp32c3-hal/examples/spi_eh1_device_loopback.rs b/esp32c3-hal/examples/spi_eh1_device_loopback.rs index 5bf81008d..004502e7c 100644 --- a/esp32c3-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32c3-hal/examples/spi_eh1_device_loopback.rs @@ -25,7 +25,7 @@ use esp32c3_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Spi, SpiBusController}, + master::{Spi, SpiBusController}, SpiMode, }, Delay, diff --git a/esp32c3-hal/examples/spi_eh1_loopback.rs b/esp32c3-hal/examples/spi_eh1_loopback.rs index 00e0227ef..7531f7d65 100644 --- a/esp32c3-hal/examples/spi_eh1_loopback.rs +++ b/esp32c3-hal/examples/spi_eh1_loopback.rs @@ -22,10 +22,7 @@ use esp32c3_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32c3-hal/examples/spi_halfduplex_read_manufacturer_id.rs b/esp32c3-hal/examples/spi_halfduplex_read_manufacturer_id.rs index f8632e981..9a76c70f6 100644 --- a/esp32c3-hal/examples/spi_halfduplex_read_manufacturer_id.rs +++ b/esp32c3-hal/examples/spi_halfduplex_read_manufacturer_id.rs @@ -23,7 +23,7 @@ use esp32c3_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Address, Command, HalfDuplexReadWrite, Spi}, + master::{Address, Command, HalfDuplexReadWrite, Spi}, SpiDataMode, SpiMode, }, diff --git a/esp32c3-hal/examples/spi_loopback.rs b/esp32c3-hal/examples/spi_loopback.rs index 4eedbd583..811293cc1 100644 --- a/esp32c3-hal/examples/spi_loopback.rs +++ b/esp32c3-hal/examples/spi_loopback.rs @@ -21,10 +21,7 @@ use esp32c3_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32c6-hal/Cargo.toml b/esp32c6-hal/Cargo.toml index 450e49abe..0975c1164 100644 --- a/esp32c6-hal/Cargo.toml +++ b/esp32c6-hal/Cargo.toml @@ -33,7 +33,7 @@ embassy-time = { version = "0.1.5", features = ["nightly"], optional = true } aes = "0.8.3" critical-section = "1.1.2" crypto-bigint = { version = "0.5.3", default-features = false} -embassy-executor = { version = "0.3.0", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } +embassy-executor = { version = "0.3.2", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } embedded-graphics = "0.8.1" embedded-hal-1 = { version = "=1.0.0-rc.1", package = "embedded-hal" } embedded-hal-async = "=1.0.0-rc.1" @@ -48,12 +48,12 @@ lis3dh-async = "0.8.0" sha2 = { version = "0.10.8", default-features = false} smart-leds = "0.3.0" ssd1306 = "0.8.4" -static_cell = { version = "=1.2.0", features = ["nightly"] } +static_cell = { version = "2.0.0", features = ["nightly"] } hex-literal = "0.4.1" elliptic-curve = {version = "0.13.6", default-features = false, features = ["sec1"] } p192 = {version = "0.13.0", default-features = false, features = ["arithmetic"] } p256 = {version = "0.13.2", default-features = false, features = ["arithmetic"] } -embassy-sync = "0.3.0" +embassy-sync = "0.4.0" [features] default = ["rt", "vectored", "esp-hal-common/rv-zero-rtc-bss"] diff --git a/esp32c6-hal/examples/spi_eh1_device_loopback.rs b/esp32c6-hal/examples/spi_eh1_device_loopback.rs index cc3a78bd6..acd74b92c 100644 --- a/esp32c6-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32c6-hal/examples/spi_eh1_device_loopback.rs @@ -25,7 +25,7 @@ use esp32c6_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Spi, SpiBusController}, + master::{Spi, SpiBusController}, SpiMode, }, Delay, diff --git a/esp32c6-hal/examples/spi_eh1_loopback.rs b/esp32c6-hal/examples/spi_eh1_loopback.rs index 4e81b2de8..aab5dbfb0 100644 --- a/esp32c6-hal/examples/spi_eh1_loopback.rs +++ b/esp32c6-hal/examples/spi_eh1_loopback.rs @@ -22,10 +22,7 @@ use esp32c6_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32c6-hal/examples/spi_halfduplex_read_manufacturer_id.rs b/esp32c6-hal/examples/spi_halfduplex_read_manufacturer_id.rs index f4540ee56..d15d4ff21 100644 --- a/esp32c6-hal/examples/spi_halfduplex_read_manufacturer_id.rs +++ b/esp32c6-hal/examples/spi_halfduplex_read_manufacturer_id.rs @@ -23,7 +23,7 @@ use esp32c6_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Address, Command, HalfDuplexReadWrite, Spi}, + master::{Address, Command, HalfDuplexReadWrite, Spi}, SpiDataMode, SpiMode, }, diff --git a/esp32c6-hal/examples/spi_loopback.rs b/esp32c6-hal/examples/spi_loopback.rs index 4de297ecc..21102c493 100644 --- a/esp32c6-hal/examples/spi_loopback.rs +++ b/esp32c6-hal/examples/spi_loopback.rs @@ -21,10 +21,7 @@ use esp32c6_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32h2-hal/Cargo.toml b/esp32h2-hal/Cargo.toml index fb95121b2..deb1cde13 100644 --- a/esp32h2-hal/Cargo.toml +++ b/esp32h2-hal/Cargo.toml @@ -33,7 +33,7 @@ embassy-time = { version = "0.1.5", features = ["nightly"], optional = true } aes = "0.8.3" critical-section = "1.1.2" crypto-bigint = { version = "0.5.3", default-features = false } -embassy-executor = { version = "0.3.0", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } +embassy-executor = { version = "0.3.2", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] } embedded-graphics = "0.8.1" embedded-hal-1 = { version = "=1.0.0-rc.1", package = "embedded-hal" } embedded-hal-async = "=1.0.0-rc.1" @@ -48,12 +48,12 @@ lis3dh-async = "0.8.0" sha2 = { version = "0.10.8", default-features = false} smart-leds = "0.3.0" ssd1306 = "0.8.4" -static_cell = { version = "=1.2.0", features = ["nightly"] } +static_cell = { version = "2.0.0", features = ["nightly"] } hex-literal = "0.4.1" elliptic-curve = {version = "0.13.6", default-features = false, features = ["sec1"] } p192 = {version = "0.13.0", default-features = false, features = ["arithmetic"] } p256 = {version = "0.13.2", default-features = false, features = ["arithmetic"] } -embassy-sync = "0.3.0" +embassy-sync = "0.4.0" [features] default = ["rt", "vectored", "esp-hal-common/rv-zero-rtc-bss"] diff --git a/esp32h2-hal/examples/spi_eh1_device_loopback.rs b/esp32h2-hal/examples/spi_eh1_device_loopback.rs index afae70c97..ade3c0d4b 100644 --- a/esp32h2-hal/examples/spi_eh1_device_loopback.rs +++ b/esp32h2-hal/examples/spi_eh1_device_loopback.rs @@ -25,7 +25,7 @@ use esp32h2_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Spi, SpiBusController}, + master::{Spi, SpiBusController}, SpiMode, }, Delay, diff --git a/esp32h2-hal/examples/spi_eh1_loopback.rs b/esp32h2-hal/examples/spi_eh1_loopback.rs index 8252ae1d7..08a683713 100644 --- a/esp32h2-hal/examples/spi_eh1_loopback.rs +++ b/esp32h2-hal/examples/spi_eh1_loopback.rs @@ -22,10 +22,7 @@ use esp32h2_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32h2-hal/examples/spi_halfduplex_read_manufacturer_id.rs b/esp32h2-hal/examples/spi_halfduplex_read_manufacturer_id.rs index f1b3a9c61..8f820cd9c 100644 --- a/esp32h2-hal/examples/spi_halfduplex_read_manufacturer_id.rs +++ b/esp32h2-hal/examples/spi_halfduplex_read_manufacturer_id.rs @@ -23,7 +23,7 @@ use esp32h2_hal::{ peripherals::Peripherals, prelude::*, spi::{ - master::{prelude::*, Address, Command, HalfDuplexReadWrite, Spi}, + master::{Address, Command, HalfDuplexReadWrite, Spi}, SpiDataMode, SpiMode, }, diff --git a/esp32h2-hal/examples/spi_loopback.rs b/esp32h2-hal/examples/spi_loopback.rs index b0e1d0f70..18f34e72c 100644 --- a/esp32h2-hal/examples/spi_loopback.rs +++ b/esp32h2-hal/examples/spi_loopback.rs @@ -21,10 +21,7 @@ use esp32h2_hal::{ gpio::IO, peripherals::Peripherals, prelude::*, - spi::{ - master::{prelude::*, Spi}, - SpiMode, - }, + spi::{master::Spi, SpiMode}, Delay, }; use esp_backtrace as _; diff --git a/esp32s2-hal/Cargo.toml b/esp32s2-hal/Cargo.toml index 990510abe..d3de90429 100644 --- a/esp32s2-hal/Cargo.toml +++ b/esp32s2-hal/Cargo.toml @@ -33,8 +33,8 @@ xtensa-atomic-emulation-trap = "0.4.0" aes = "0.8.3" critical-section = "1.1.2" crypto-bigint = { version = "0.5.3", default-features = false } -embassy-executor = { version = "0.3.0", features = ["nightly"] } -embassy-sync = "0.3.0" +embassy-executor = { version = "0.3.2", features = ["nightly"] } +embassy-sync = "0.4.0" embedded-graphics = "0.8.1" embedded-hal-1 = { version = "=1.0.0-rc.1", package = "embedded-hal" } embedded-hal-async = "=1.0.0-rc.1" @@ -49,7 +49,7 @@ lis3dh-async = "0.8.0" sha2 = { version = "0.10.8", default-features = false } smart-leds = "0.3.0" ssd1306 = "0.8.4" -static_cell = { version = "=1.2.0", features = ["nightly"] } +static_cell = { version = "2.0.0", features = ["nightly"] } usb-device = "0.2.9" usbd-serial = "0.1.1" @@ -64,6 +64,8 @@ rt = [] ufmt = ["esp-hal-common/ufmt"] vectored = ["esp-hal-common/vectored"] +portable-atomic = ["esp-hal-common/portable-atomic"] + # Embassy support embassy = ["esp-hal-common/embassy"] embassy-time-systick = ["esp-hal-common/embassy-time-systick", "embassy-time/tick-hz-80_000_000"] diff --git a/esp32s2-hal/examples/clock_monitor.rs b/esp32s2-hal/examples/clock_monitor.rs index aff43e7c4..e2135d4dc 100644 --- a/esp32s2-hal/examples/clock_monitor.rs +++ b/esp32s2-hal/examples/clock_monitor.rs @@ -17,7 +17,6 @@ use esp32s2_hal::{ }; use esp_backtrace as _; use esp_println::println; -use xtensa_atomic_emulation_trap as _; static RTC: Mutex>> = Mutex::new(RefCell::new(None)); diff --git a/esp32s2-hal/examples/embassy_hello_world.rs b/esp32s2-hal/examples/embassy_hello_world.rs index 2b1a0a926..80463666e 100644 --- a/esp32s2-hal/examples/embassy_hello_world.rs +++ b/esp32s2-hal/examples/embassy_hello_world.rs @@ -16,7 +16,6 @@ use esp32s2_hal::{ prelude::*, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; #[embassy_executor::task] async fn run() { diff --git a/esp32s2-hal/examples/embassy_rmt_rx.rs b/esp32s2-hal/examples/embassy_rmt_rx.rs index ab63a0f42..43e17233e 100644 --- a/esp32s2-hal/examples/embassy_rmt_rx.rs +++ b/esp32s2-hal/examples/embassy_rmt_rx.rs @@ -19,7 +19,6 @@ use esp32s2_hal::{ use esp_backtrace as _; use esp_hal_common::gpio::{Gpio15, Output, PushPull}; use esp_println::{print, println}; -use xtensa_atomic_emulation_trap as _; const WIDTH: usize = 80; diff --git a/esp32s2-hal/examples/embassy_rmt_tx.rs b/esp32s2-hal/examples/embassy_rmt_tx.rs index bf468d4ad..0ff96d3f1 100644 --- a/esp32s2-hal/examples/embassy_rmt_tx.rs +++ b/esp32s2-hal/examples/embassy_rmt_tx.rs @@ -18,7 +18,6 @@ use esp32s2_hal::{ }; use esp_backtrace as _; use esp_println::println; -use xtensa_atomic_emulation_trap as _; #[main] async fn main(_spawner: Spawner) -> ! { diff --git a/esp32s2-hal/examples/i2c_display.rs b/esp32s2-hal/examples/i2c_display.rs index 44d51657c..dd801b621 100644 --- a/esp32s2-hal/examples/i2c_display.rs +++ b/esp32s2-hal/examples/i2c_display.rs @@ -30,7 +30,6 @@ use esp32s2_hal::{ use esp_backtrace as _; use nb::block; use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306}; -use xtensa_atomic_emulation_trap as _; #[entry] fn main() -> ! { diff --git a/esp32s2-hal/examples/ledc.rs b/esp32s2-hal/examples/ledc.rs index 0a269b18d..c3bcc5ba5 100644 --- a/esp32s2-hal/examples/ledc.rs +++ b/esp32s2-hal/examples/ledc.rs @@ -20,7 +20,6 @@ use esp32s2_hal::{ prelude::*, }; use esp_backtrace as _; -use xtensa_atomic_emulation_trap as _; #[entry] fn main() -> ! { diff --git a/esp32s2-hal/src/lib.rs b/esp32s2-hal/src/lib.rs index 9701569ec..fcb24db1f 100644 --- a/esp32s2-hal/src/lib.rs +++ b/esp32s2-hal/src/lib.rs @@ -48,8 +48,6 @@ use esp_hal_common::xtensa_lx_rt::exception::ExceptionCause; pub use esp_hal_common::*; -// Always enable atomic emulation on ESP32-S2 -use xtensa_atomic_emulation_trap as _; /// Function initializes ESP32 specific memories (RTC slow and fast) and /// then calls original Reset function diff --git a/esp32s3-hal/Cargo.toml b/esp32s3-hal/Cargo.toml index f9b0282d3..b7d2265e9 100644 --- a/esp32s3-hal/Cargo.toml +++ b/esp32s3-hal/Cargo.toml @@ -33,8 +33,8 @@ r0 = { version = "1.0.0", optional = true } aes = "0.8.3" critical-section = "1.1.2" crypto-bigint = { version = "0.5.3", default-features = false } -embassy-executor = { version = "0.3.0", features = ["nightly"] } -embassy-sync = "0.3.0" +embassy-executor = { version = "0.3.2", features = ["nightly"] } +embassy-sync = "0.4.0" embedded-graphics = "0.8.1" embedded-hal = { version = "0.2.7", features = ["unproven"] } embedded-hal-1 = { version = "=1.0.0-rc.1", package = "embedded-hal" } @@ -51,7 +51,7 @@ lis3dh-async = "0.8.0" sha2 = { version = "0.10.8", default-features = false } smart-leds = "0.3.0" ssd1306 = "0.8.4" -static_cell = { version = "=1.2.0", features = ["nightly"] } +static_cell = { version = "2.0.0", features = ["nightly"] } usb-device = "0.2.9" usbd-serial = "0.1.1"