Skip to content

Commit

Permalink
Update to esp-hal 0.16.1 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyGrondin authored Mar 18, 2024
1 parent 1589f72 commit b339fe8
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 163 deletions.
13 changes: 9 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
30 changes: 9 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
]
13 changes: 5 additions & 8 deletions esp-mbedtls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
12 changes: 1 addition & 11 deletions esp-mbedtls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 1 addition & 11 deletions examples/async_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
12 changes: 1 addition & 11 deletions examples/async_client_mTLS.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
12 changes: 1 addition & 11 deletions examples/async_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
12 changes: 1 addition & 11 deletions examples/async_server_mTLS.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
36 changes: 15 additions & 21 deletions examples/crypto_self_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,19 +12,18 @@ 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() -> ! {
init_logger(log::LevelFilter::Info);

// 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")]
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 1 addition & 11 deletions examples/sync_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down
12 changes: 1 addition & 11 deletions examples/sync_client_mTLS.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down
12 changes: 1 addition & 11 deletions examples/sync_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down
12 changes: 1 addition & 11 deletions examples/sync_server_mTLS.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down
20 changes: 10 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b339fe8

Please sign in to comment.