diff --git a/.cargo/config.toml b/.cargo/config.toml index de0842a..52d7e13 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -47,7 +47,12 @@ xtask = "run --manifest-path ./xtask/Cargo.toml --" # Alias' for quickly building for different chips or running examples # By default we enable # - `default` HAL features to set up basic chip specific settings -esp32 = "run --features esp32 --target xtensa-esp32-none-elf --features esp32-hal/default" -esp32s2 = "run --features esp32s2 --target xtensa-esp32s2-none-elf --features esp32s2-hal/default" -esp32s3 = "run --features esp32s3 --target xtensa-esp32s3-none-elf --features esp32s3-hal/default" -esp32c3 = "run --features esp32c3 --target riscv32imc-unknown-none-elf --features esp32c3-hal/default" +esp32 = "run --features esp32 --target xtensa-esp32-none-elf --features esp-hal/default,esp-hal/embassy-time-timg0,esp-hal/embassy-executor-thread" +esp32s2 = "run --features esp32s2 --target xtensa-esp32s2-none-elf --features esp-hal/default,esp-hal/embassy-time-timg0,esp-hal/embassy-executor-thread" +esp32s3 = "run --features esp32s3 --target xtensa-esp32s3-none-elf --features esp-hal/default,esp-hal/embassy-time-timg0,esp-hal/embassy-executor-thread" +esp32c3 = "run --features esp32c3 --target riscv32imc-unknown-none-elf --features esp-hal/default,esp-hal/embassy-time-timg0,esp-hal/embassy-executor-thread" + +besp32 = "build --features esp32 --target xtensa-esp32-none-elf --features esp-hal/default,esp-hal/embassy-time-timg0,esp-hal/embassy-executor-thread" +besp32s2 = "build --features esp32s2 --target xtensa-esp32s2-none-elf --features esp-hal/default,esp-hal/embassy-time-timg0,esp-hal/embassy-executor-thread" +besp32s3 = "build --features esp32s3 --target xtensa-esp32s3-none-elf --features esp-hal/default,esp-hal/embassy-time-timg0,esp-hal/embassy-executor-thread" +besp32c3 = "build --features esp32c3 --target riscv32imc-unknown-none-elf --features esp-hal/default,esp-hal/embassy-time-timg0,esp-hal/embassy-executor-thread" diff --git a/Cargo.toml b/Cargo.toml index 438b76d..f810412 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,10 +20,7 @@ lto = false opt-level = 3 [dependencies] -esp32-hal = { version = "0.18.0", optional = true } -esp32c3-hal = { version = "0.15.0", optional = true } -esp32s2-hal = { version = "0.15.0", optional = true } -esp32s3-hal = { version = "0.15.0", optional = true } +esp-hal = { version = "0.16.1" } esp-backtrace = { version = "0.11.0", features = [ "panic-handler", "println", @@ -34,6 +31,7 @@ esp-println = { version = "0.9.0", features = ["log"] } embassy-time = { version = "0.3.0", optional = true } embassy-executor = { version = "0.5.0", package = "embassy-executor", features = [ "nightly", + "integrated-timers" ], optional = true } embassy-net = { version = "0.4.0", features = [ "tcp", @@ -46,7 +44,7 @@ esp-wifi = { git = "https://github.com/esp-rs/esp-wifi.git", features = [ "phy-enable-usb", "embedded-svc", "wifi-default", -], rev = "e6c58b67569c290f27e38846fcf628d893e562c1" } +], version = "0.4.0" } smoltcp = { version = "0.11.0", default-features = false, features = [ "proto-igmp", "proto-ipv4", @@ -90,28 +88,28 @@ required-features = ["async"] [features] esp32 = [ - "esp32-hal/embassy-time-timg0", + "esp-hal/esp32", "esp-backtrace/esp32", "esp-println/esp32", "esp-wifi/esp32", "esp-mbedtls/esp32", ] esp32c3 = [ - "esp32c3-hal/embassy-time-timg0", + "esp-hal/esp32c3", "esp-backtrace/esp32c3", "esp-println/esp32c3", "esp-wifi/esp32c3", "esp-mbedtls/esp32c3", ] esp32s2 = [ - "esp32s2-hal/embassy-time-timg0", + "esp-hal/esp32s2", "esp-backtrace/esp32s2", "esp-println/esp32s2", "esp-wifi/esp32s2", "esp-mbedtls/esp32s2", ] esp32s3 = [ - "esp32s3-hal/embassy-time-timg0", + "esp-hal/esp32s3", "esp-backtrace/esp32s3", "esp-println/esp32s3", "esp-wifi/esp32s3", @@ -125,16 +123,6 @@ async = [ "embassy-time", "dep:embedded-io-async", "esp-mbedtls/async", - "esp32c3-hal?/embassy", - "esp32-hal?/embassy", - "esp32s2-hal?/embassy", - "esp32s3-hal?/embassy", - "esp32c3-hal?/async", - "esp32-hal?/async", - "esp32s2-hal?/async", - "esp32s3-hal?/async", - "esp32c3-hal?/embassy-executor-thread", - "esp32-hal?/embassy-executor-thread", - "esp32s2-hal?/embassy-executor-thread", - "esp32s3-hal?/embassy-executor-thread", + "esp-hal/embassy", + "esp-hal/async", ] diff --git a/esp-mbedtls/Cargo.toml b/esp-mbedtls/Cargo.toml index e865779..de7493e 100644 --- a/esp-mbedtls/Cargo.toml +++ b/esp-mbedtls/Cargo.toml @@ -10,15 +10,12 @@ log = "0.4.17" embedded-io = { version = "0.6.1" } embedded-io-async = { version = "0.6.0", optional = true } crypto-bigint = { version = "0.5.3", default-features = false, features = ["extra-sizes"] } -esp32-hal = { version = "0.18.0", optional = true } -esp32c3-hal = { version = "0.15.0", optional = true } -esp32s2-hal = { version = "0.15.0", optional = true } -esp32s3-hal = { version = "0.15.0", optional = true } +esp-hal = { version = "0.16.1" } cfg-if = "1.0.0" [features] async = ["dep:embedded-io-async"] -esp32 = ["esp32-hal", "esp-mbedtls-sys/esp32"] -esp32c3 = ["esp32c3-hal", "esp-mbedtls-sys/esp32c3"] -esp32s2 = ["esp32s2-hal", "esp-mbedtls-sys/esp32s2"] -esp32s3 = ["esp32s3-hal", "esp-mbedtls-sys/esp32s3"] +esp32 = ["esp-hal/esp32", "esp-mbedtls-sys/esp32"] +esp32c3 = ["esp-hal/esp32c3", "esp-mbedtls-sys/esp32c3"] +esp32s2 = ["esp-hal/esp32s2", "esp-mbedtls-sys/esp32s2"] +esp32s3 = ["esp-hal/esp32s3", "esp-mbedtls-sys/esp32s3"] diff --git a/esp-mbedtls/src/lib.rs b/esp-mbedtls/src/lib.rs index 97a9524..ad3fdd6 100644 --- a/esp-mbedtls/src/lib.rs +++ b/esp-mbedtls/src/lib.rs @@ -4,17 +4,7 @@ use embedded_io::ErrorType; #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; pub use crate::hal::rsa::Rsa; diff --git a/examples/async_client.rs b/examples/async_client.rs index 6fb917b..851de2f 100644 --- a/examples/async_client.rs +++ b/examples/async_client.rs @@ -5,17 +5,7 @@ #![feature(type_alias_impl_trait)] #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Ipv4Address, Stack, StackResources}; diff --git a/examples/async_client_mTLS.rs b/examples/async_client_mTLS.rs index 6c46bb8..5ce37d1 100644 --- a/examples/async_client_mTLS.rs +++ b/examples/async_client_mTLS.rs @@ -6,17 +6,7 @@ use embassy_executor::Spawner; #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Ipv4Address, Stack, StackResources}; diff --git a/examples/async_server.rs b/examples/async_server.rs index 47306f4..09c439b 100644 --- a/examples/async_server.rs +++ b/examples/async_server.rs @@ -8,17 +8,7 @@ #![feature(type_alias_impl_trait)] #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, IpListenEndpoint, Stack, StackResources}; diff --git a/examples/async_server_mTLS.rs b/examples/async_server_mTLS.rs index 1e0134f..a5d1901 100644 --- a/examples/async_server_mTLS.rs +++ b/examples/async_server_mTLS.rs @@ -25,17 +25,7 @@ #![allow(non_snake_case)] #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, IpListenEndpoint, Stack, StackResources}; diff --git a/examples/crypto_self_test.rs b/examples/crypto_self_test.rs index 849227d..d9b7764 100644 --- a/examples/crypto_self_test.rs +++ b/examples/crypto_self_test.rs @@ -3,17 +3,7 @@ #![no_main] #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use esp_backtrace as _; use esp_mbedtls::set_debug; @@ -22,7 +12,10 @@ use esp_println::{logger::init_logger, println}; /// Only used for ROM functions #[allow(unused_imports)] use esp_wifi::{initialize, EspWifiInitFor}; -use hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, systimer::SystemTimer, Rng}; +use hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, Rng}; + +#[cfg(any(feature = "esp32c3", feature = "esp32s2", feature = "esp32s3"))] +use hal::systimer::SystemTimer; #[entry] fn main() -> ! { @@ -30,11 +23,7 @@ fn main() -> ! { // Init ESP-WIFI heap for malloc let peripherals = Peripherals::take(); - #[cfg(feature = "esp32")] - let mut system = peripherals.DPORT.split(); - #[cfg(not(feature = "esp32"))] - #[allow(unused_mut)] - let mut system = peripherals.SYSTEM.split(); + let system = peripherals.SYSTEM.split(); let clocks = ClockControl::max(system.clock_control).freeze(); #[cfg(feature = "esp32c3")] @@ -131,13 +120,18 @@ fn main() -> ! { // Took 1325770 cycles // Done + #[cfg(any(feature = "esp32c3", feature = "esp32s2", feature = "esp32s3"))] let pre_calc = SystemTimer::now(); + #[cfg(any(feature = "esp32c3", feature = "esp32s2", feature = "esp32s3"))] log::info!("pre_cal {}", pre_calc); esp_mbedtls::mbedtls_mpi_self_test(1i32); - let post_calc = SystemTimer::now(); - let hw_time = post_calc - pre_calc; - log::info!("post_cal {}", post_calc); - println!("Took {} cycles", hw_time); + #[cfg(any(feature = "esp32c3", feature = "esp32s2", feature = "esp32s3"))] + { + let post_calc = SystemTimer::now(); + let hw_time = post_calc - pre_calc; + log::info!("post_cal {}", post_calc); + println!("Took {} cycles", hw_time); + } } println!("Done"); diff --git a/examples/sync_client.rs b/examples/sync_client.rs index e26753a..ff647e5 100644 --- a/examples/sync_client.rs +++ b/examples/sync_client.rs @@ -4,17 +4,7 @@ #![no_main] #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use embedded_io::*; use esp_backtrace as _; diff --git a/examples/sync_client_mTLS.rs b/examples/sync_client_mTLS.rs index 117230f..bcc883b 100644 --- a/examples/sync_client_mTLS.rs +++ b/examples/sync_client_mTLS.rs @@ -4,17 +4,7 @@ #![allow(non_snake_case)] #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use embedded_io::*; use esp_backtrace as _; diff --git a/examples/sync_server.rs b/examples/sync_server.rs index a6756ae..dce77ee 100644 --- a/examples/sync_server.rs +++ b/examples/sync_server.rs @@ -7,17 +7,7 @@ #![no_main] #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use embedded_io::*; use esp_backtrace as _; diff --git a/examples/sync_server_mTLS.rs b/examples/sync_server_mTLS.rs index bb04e47..fb3e09c 100644 --- a/examples/sync_server_mTLS.rs +++ b/examples/sync_server_mTLS.rs @@ -24,17 +24,7 @@ #![allow(non_snake_case)] #[doc(hidden)] -#[cfg(feature = "esp32")] -pub use esp32_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32c3")] -pub use esp32c3_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s2")] -pub use esp32s2_hal as hal; -#[doc(hidden)] -#[cfg(feature = "esp32s3")] -pub use esp32s3_hal as hal; +pub use esp_hal as hal; use embedded_io::*; use esp_backtrace as _; diff --git a/justfile b/justfile index 2b7c457..6f47f85 100644 --- a/justfile +++ b/justfile @@ -1,17 +1,17 @@ export SSID := "Dummy" export PASSWORD := "Dummy" -all: (check "xtensa-esp32-none-elf" "esp32" "esp") (check "xtensa-esp32s3-none-elf" "esp32s3" "esp") (check "riscv32imc-unknown-none-elf" "esp32c3" "nightly") +all: (check "esp32" "esp") (check "esp32s3" "esp") (check "esp32c3" "nightly") cd esp-mbedtls && cargo +nightly fmt --all -- --check [private] -check target arch toolchain: - cargo +{{ toolchain }} build --target {{ target }} --example sync_client --features {{ arch }} - cargo +{{ toolchain }} build --target {{ target }} --example sync_client_mTLS --features {{ arch }} - cargo +{{ toolchain }} build --target {{ target }} --example async_client --features="async {{ arch }}" - cargo +{{ toolchain }} build --target {{ target }} --example async_client_mTLS --features="async {{ arch }}" - cargo +{{ toolchain }} build --target {{ target }} --example sync_server --features {{ arch }} - cargo +{{ toolchain }} build --target {{ target }} --example sync_server_mTLS --features {{ arch }} - cargo +{{ toolchain }} build --target {{ target }} --example async_server --features="async {{ arch }}" - cargo +{{ toolchain }} build --target {{ target }} --example async_server_mTLS --features="async {{ arch }}" +check arch toolchain: + cargo +{{ toolchain }} b{{ arch }} --example sync_client + cargo +{{ toolchain }} b{{ arch }} --example sync_client_mTLS + cargo +{{ toolchain }} b{{ arch }} --example async_client --features="async" + cargo +{{ toolchain }} b{{ arch }} --example async_client_mTLS --features="async" + cargo +{{ toolchain }} b{{ arch }} --example sync_server + cargo +{{ toolchain }} b{{ arch }} --example sync_server_mTLS + cargo +{{ toolchain }} b{{ arch }} --example async_server --features="async" + cargo +{{ toolchain }} b{{ arch }} --example async_server_mTLS --features="async" cargo +{{ toolchain }} fmt --all -- --check