Skip to content

Commit

Permalink
Update dependencies, port to portable-atomic (#342)
Browse files Browse the repository at this point in the history
* Update dependencies, port to portable-atomic

* Drop futures-*

* Add patches

* Make portable-atomic optional

* Don't depend on smoltcp and embedded-svc releases

* Update esp-hal to disallow duplicate versions

* Backtrack on the S2 changes

* Remove features from cargo run aliasses

* Update esp-hal, always use portable-atomic
  • Loading branch information
bugadani authored Dec 5, 2023
1 parent 2fd1470 commit d46dfc4
Show file tree
Hide file tree
Showing 31 changed files with 105 additions and 128 deletions.
32 changes: 22 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,43 @@ esp32s3-hal = { version = "0.13.0", default-features = false }
esp32s2-hal = { version = "0.13.0", default-features = false }
smoltcp = { version = "0.10.0", default-features=false, features = ["medium-ethernet", "socket-raw"] }
critical-section = "1.1.1"
atomic-polyfill = "1.0.2"
atomic_enum = "0.2.0" # uses core atomic types which should be fine as long as only load and store is used on them
log = "0.4.18"
portable-atomic = { version = "1.5", default-features = false }
portable_atomic_enum = { version = "0.3.0", features = ["portable-atomic"] }
log = "0.4.20"
embedded-svc = { version = "0.26.1", default-features = false, features = [] }
enumset = { version = "1", default-features = false }
enumset = { version = "1.1.3", default-features = false }
linked_list_allocator = { version = "0.10.5", default-features = false, features = ["const_mut_refs"] }
embedded-io = "0.6.1"
fugit = "0.3.7"
heapless = { version = "0.7.16", default-features = false }
num-derive = { version = "0.3", features = ["full-syntax"] }
num-derive = { version = "0.4" }
num-traits = { version = "0.2", default-features = false }
esp-wifi-sys = { version = "0.1.0", path = "../esp-wifi-sys" }
embassy-sync = { version = "0.4.0" }
embassy-futures = { version = "0.1.0" }
toml-cfg = "0.1.3"
libm = "0.2.7"
cfg-if = "1.0.0"
static_cell = { version = "=1.2", features = ["nightly"] }
static_cell = { version = "2.0", features = ["nightly"] }

embassy-net = { version = "0.2.1", features = ["nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] }
bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "0db8fcb", features = ["macros"] }
embassy-executor = { version = "=0.3.2", package = "embassy-executor", features = ["nightly", "executor-thread", "integrated-timers"] } # temporarily pin because we aren't ready for portable-atomic yet
embassy-executor = { version = "0.3.3", package = "embassy-executor", features = ["nightly", "integrated-timers"] }
embassy-time = { version = "0.1.3", features = ["nightly"] }
futures-util = { version = "0.3.28", default-features = false }
esp-println = { version = "0.6.0" }
esp-backtrace = { version = "0.8.0", features = ["panic-handler", "exception-handler", "print-uart"] }
esp-println = { version = "0.7.0" }
esp-backtrace = { version = "0.9.0", features = ["panic-handler", "exception-handler", "print-uart"] }
embedded-hal-async = { version = "1.0.0-rc.1" }
embedded-io-async = { version = "0.6.0" }

futures-util = { version = "0.3.28", default-features = false, features = ["portable-atomic"] } # need this to activate portable-atomic on AtomicWaker even though we don't use it
atomic-waker = { version = "1.1.2", default-features = false, features = ["portable-atomic"] } # need this to activate portable-atomic on AtomicWaker used by embedded-svc even though we don't use it

# portable-atomic compatible esp-hal revisions
[patch.crates-io]
esp32-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "22f14fd" }
esp32c2-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "22f14fd" }
esp32c3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "22f14fd" }
esp32c6-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "22f14fd" }
esp32s2-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "22f14fd" }
esp32s3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "22f14fd" }
esp-hal-common = { git = "https://github.com/esp-rs/esp-hal.git", rev = "22f14fd" }
47 changes: 7 additions & 40 deletions esp-wifi/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,23 @@
esp32 = "run --features esp32 --target xtensa-esp32-none-elf --features esp32-hal/default,esp32-hal/embassy-time-timg0,esp32-hal/embassy-executor-thread"
esp32s2 = "run --features esp32s2 --target xtensa-esp32s2-none-elf --features esp32s2-hal/default,esp32s2-hal/embassy-time-timg0,esp32s2-hal/embassy-executor-thread"
esp32s3 = "run --features esp32s3 --target xtensa-esp32s3-none-elf --features esp32s3-hal/default,esp32s3-hal/embassy-time-timg0,esp32s3-hal/embassy-executor-thread"
esp32c2 = "run --features esp32c2 --target riscv32imc-unknown-none-elf --features esp32c2-hal/default,esp32c2-hal/embassy-time-timg0"
esp32c3 = "run --features esp32c3 --target riscv32imc-unknown-none-elf --features esp32c3-hal/default,esp32c3-hal/embassy-time-timg0"
esp32c6 = "run --features esp32c6 --target riscv32imac-unknown-none-elf --features esp32c6-hal/default,esp32c6-hal/embassy-time-timg0"
esp32c2 = "run --features esp32c2 --target riscv32imc-unknown-none-elf --features esp32c2-hal/default,esp32c2-hal/embassy-time-timg0,esp32c2-hal/embassy-executor-thread"
esp32c3 = "run --features esp32c3 --target riscv32imc-unknown-none-elf --features esp32c3-hal/default,esp32c3-hal/embassy-time-timg0,esp32c3-hal/embassy-executor-thread"
esp32c6 = "run --features esp32c6 --target riscv32imac-unknown-none-elf --features esp32c6-hal/default,esp32c6-hal/embassy-time-timg0,esp32c6-hal/embassy-executor-thread"

besp32 = "build --features esp32 --target xtensa-esp32-none-elf --features esp32-hal/default,esp32-hal/embassy-time-timg0,esp32-hal/embassy-executor-thread"
besp32s2 = "build --features esp32s2 --target xtensa-esp32s2-none-elf --features esp32s2-hal/default,esp32s2-hal/embassy-time-timg0,esp32s2-hal/embassy-executor-thread"
besp32s3 = "build --features esp32s3 --target xtensa-esp32s3-none-elf --features esp32s3-hal/default,esp32s3-hal/embassy-time-timg0,esp32s3-hal/embassy-executor-thread"
besp32c2 = "build --features esp32c2 --target riscv32imc-unknown-none-elf --features esp32c2-hal/default,esp32c2-hal/embassy-time-timg0"
besp32c3 = "build --features esp32c3 --target riscv32imc-unknown-none-elf --features esp32c3-hal/default,esp32c3-hal/embassy-time-timg0"
besp32c6 = "build --features esp32c6 --target riscv32imac-unknown-none-elf --features esp32c6-hal/default,esp32c6-hal/embassy-time-timg0"
besp32c2 = "build --features esp32c2 --target riscv32imc-unknown-none-elf --features esp32c2-hal/default,esp32c2-hal/embassy-time-timg0,esp32c2-hal/embassy-executor-thread"
besp32c3 = "build --features esp32c3 --target riscv32imc-unknown-none-elf --features esp32c3-hal/default,esp32c3-hal/embassy-time-timg0,esp32c3-hal/embassy-executor-thread"
besp32c6 = "build --features esp32c6 --target riscv32imac-unknown-none-elf --features esp32c6-hal/default,esp32c6-hal/embassy-time-timg0,esp32c6-hal/embassy-executor-thread"

[target.riscv32imc-unknown-none-elf]
runner = "espflash flash --monitor"
rustflags = [
"-C", "link-arg=-Tlinkall.x",
"-C", "link-arg=-Trom_functions.x",

"-C", "force-frame-pointers",

# 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"',
]

[target.riscv32imac-unknown-none-elf]
Expand Down Expand Up @@ -70,23 +53,7 @@ runner = "espflash flash --monitor"
rustflags = [
"-C", "link-arg=-Tlinkall.x",
"-C", "link-arg=-Trom_functions.x",

# Enable the atomic codegen option for Xtensa
"-C", "target-feature=+s32c1i",

# 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"',
# Tell the `core` library that we have atomics, even though it's not
# specified in the target definition
"--cfg", 'target_has_atomic',
"--cfg", 'target_has_atomic="8"',
"--cfg", 'target_has_atomic="16"',
"--cfg", 'target_has_atomic="32"',
"--cfg", 'target_has_atomic="ptr"',
"-C", "force-frame-pointers",
]

[unstable]
Expand Down
17 changes: 10 additions & 7 deletions esp-wifi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ embedded-io.workspace = true
embedded-io-async = { workspace = true, optional = true }
fugit.workspace = true
heapless = { workspace = true, default-features = false }
num-derive = { workspace = true, features = ["full-syntax"] }
num-derive = { workspace = true }
num-traits = { workspace = true, default-features = false }
esp-wifi-sys = { version = "0.1.0", path = "../esp-wifi-sys" }
embassy-sync = { workspace = true, optional = true }
Expand All @@ -48,8 +48,12 @@ embassy-net = { workspace = true, optional = true }
toml-cfg.workspace = true
libm.workspace = true
cfg-if.workspace = true
atomic-polyfill.workspace = true
atomic_enum.workspace = true
portable-atomic.workspace = true
portable_atomic_enum.workspace = true

# We don't use these directly but we need to enable portable-atomic on them
futures-util.workspace = true
atomic-waker.workspace = true

[build-dependencies]
toml-cfg.workspace = true
Expand All @@ -59,7 +63,6 @@ esp-println = { workspace = true, features = ["log"] }
esp-backtrace.workspace = true
embassy-executor.workspace = true
embassy-time.workspace = true
futures-util.workspace = true
bleps = { workspace = true, features = ["async"] }
embedded-hal-async.workspace = true
log.workspace = true
Expand All @@ -69,9 +72,9 @@ static_cell.workspace = true
default = [ "log", "ipv4", "tcp", "udp", "icmp", "igmp", "dns", "dhcpv4" ]

# chip features
esp32c2 = [ "esp32c2-hal", "esp-wifi-sys/esp32c2", "esp-println/esp32c2", "esp-backtrace/esp32c2", "embassy-executor/arch-riscv32" ]
esp32c3 = [ "esp32c3-hal", "esp-wifi-sys/esp32c3", "esp-println/esp32c3", "esp-backtrace/esp32c3", "embassy-executor/arch-riscv32" ]
esp32c6 = [ "esp32c6-hal", "esp-wifi-sys/esp32c6", "esp-println/esp32c6", "esp-backtrace/esp32c6", "embassy-executor/arch-riscv32" ]
esp32c2 = [ "esp32c2-hal", "esp-wifi-sys/esp32c2", "esp-println/esp32c2", "esp-backtrace/esp32c2" ]
esp32c3 = [ "esp32c3-hal", "esp-wifi-sys/esp32c3", "esp-println/esp32c3", "esp-backtrace/esp32c3" ]
esp32c6 = [ "esp32c6-hal", "esp-wifi-sys/esp32c6", "esp-println/esp32c6", "esp-backtrace/esp32c6" ]
esp32 = [ "esp32-hal", "esp-wifi-sys/esp32", "esp-println/esp32", "esp-backtrace/esp32" ]
esp32s2 = [ "esp32s2-hal", "esp-wifi-sys/esp32s2", "esp-println/esp32s2", "esp-backtrace/esp32s2" ]
esp32s3 = [ "esp32s3-hal", "esp-wifi-sys/esp32s3", "esp-println/esp32s3", "esp-backtrace/esp32s3" ]
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/automated-tests/open_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn main() -> ! {
let mut wifi_stack = WifiStack::new(iface, device, sockets, current_millis);

let client_config = Configuration::AccessPoint(AccessPointConfiguration {
ssid: "esp-wifi".into(),
ssid: "esp-wifi".try_into().unwrap(),
..Default::default()
});
let res = controller.set_configuration(&client_config);
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/automated-tests/test_connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() -> ! {
let mut wifi_stack = WifiStack::new(iface, device, sockets, current_millis);

let client_config = Configuration::Client(ClientConfiguration {
ssid: SSID.into(),
ssid: SSID.try_into().unwrap(),
auth_method: AuthMethod::None,
..Default::default()
});
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn main() -> ! {
let mut wifi_stack = WifiStack::new(iface, device, sockets, current_millis);

let client_config = Configuration::AccessPoint(AccessPointConfiguration {
ssid: "esp-wifi".into(),
ssid: "esp-wifi".try_into().unwrap(),
..Default::default()
});
let res = controller.set_configuration(&client_config);
Expand Down
6 changes: 3 additions & 3 deletions esp-wifi/examples/access_point_with_sta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ fn main() -> ! {

let client_config = Configuration::Mixed(
ClientConfiguration {
ssid: SSID.into(),
password: PASSWORD.into(),
ssid: SSID.try_into().unwrap(),
password: PASSWORD.try_into().unwrap(),
..Default::default()
},
AccessPointConfiguration {
ssid: "esp-wifi".into(),
ssid: "esp-wifi".try_into().unwrap(),
..Default::default()
},
);
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ fn main() -> ! {
let wifi_stack = WifiStack::new(iface, device, sockets, current_millis);

let client_config = Configuration::Client(ClientConfiguration {
ssid: SSID.into(),
password: PASSWORD.into(),
ssid: SSID.try_into().unwrap(),
password: PASSWORD.try_into().unwrap(),
..Default::default()
});
let res = controller.set_configuration(&client_config);
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/coex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn main() -> ! {
let wifi_stack = WifiStack::new(iface, device, sockets, current_millis);

let client_config = Configuration::Client(ClientConfiguration {
ssid: SSID.into(),
password: PASSWORD.into(),
ssid: SSID.try_into().unwrap(),
password: PASSWORD.try_into().unwrap(),
..Default::default()
});
let res = controller.set_configuration(&client_config);
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ fn main() -> ! {
let wifi_stack = WifiStack::new(iface, device, sockets, current_millis);

let client_config = Configuration::Client(ClientConfiguration {
ssid: SSID.into(),
password: PASSWORD.into(),
ssid: SSID.try_into().unwrap(),
password: PASSWORD.try_into().unwrap(),
..Default::default()
});
let res = controller.set_configuration(&client_config);
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async fn connection(mut controller: WifiController<'static>) {
}
if !matches!(controller.is_started(), Ok(true)) {
let client_config = Configuration::AccessPoint(AccessPointConfiguration {
ssid: "esp-wifi".into(),
ssid: "esp-wifi".try_into().unwrap(),
..Default::default()
});
controller.set_configuration(&client_config).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions esp-wifi/examples/embassy_access_point_with_sta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ async fn main(spawner: Spawner) -> ! {

let client_config = Configuration::Mixed(
ClientConfiguration {
ssid: SSID.into(),
password: PASSWORD.into(),
ssid: SSID.try_into().unwrap(),
password: PASSWORD.try_into().unwrap(),
..Default::default()
},
AccessPointConfiguration {
ssid: "esp-wifi".into(),
ssid: "esp-wifi".try_into().unwrap(),
..Default::default()
},
);
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/embassy_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ async fn connection(mut controller: WifiController<'static>) {
}
if !matches!(controller.is_started(), Ok(true)) {
let client_config = Configuration::Client(ClientConfiguration {
ssid: SSID.into(),
password: PASSWORD.into(),
ssid: SSID.try_into().unwrap(),
password: PASSWORD.try_into().unwrap(),
..Default::default()
});
controller.set_configuration(&client_config).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/embassy_dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ async fn connection(mut controller: WifiController<'static>) {
}
if !matches!(controller.is_started(), Ok(true)) {
let client_config = Configuration::Client(ClientConfiguration {
ssid: SSID.into(),
password: PASSWORD.into(),
ssid: SSID.try_into().unwrap(),
password: PASSWORD.try_into().unwrap(),
..Default::default()
});
controller.set_configuration(&client_config).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/static_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn main() -> ! {
let mut wifi_stack = WifiStack::new(iface, device, sockets, current_millis);

let client_config = Configuration::Client(ClientConfiguration {
ssid: SSID.into(),
password: PASSWORD.into(),
ssid: SSID.try_into().unwrap(),
password: PASSWORD.try_into().unwrap(),
..Default::default()
});
let res = controller.set_configuration(&client_config);
Expand Down
12 changes: 6 additions & 6 deletions esp-wifi/src/common_adapter/common_adapter_esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use crate::hal::prelude::ram;
use crate::hal::system::RadioClockController;
use crate::hal::system::RadioPeripherals;

use atomic_polyfill::AtomicU32;
use core::sync::atomic::Ordering;
use portable_atomic::{AtomicU32, Ordering};

const SOC_PHY_DIG_REGS_MEM_SIZE: usize = 21 * 4;

Expand All @@ -22,11 +21,11 @@ pub(crate) fn enable_wifi_power_domain() {
let rtc_cntl = &*crate::hal::peripherals::RTC_CNTL::ptr();

rtc_cntl
.dig_pwc
.dig_pwc()
.modify(|_, w| w.wifi_force_pd().clear_bit());

rtc_cntl
.dig_iso
.dig_iso()
.modify(|_, w| w.wifi_force_iso().clear_bit());
}
}
Expand Down Expand Up @@ -205,8 +204,9 @@ unsafe extern "C" fn phy_exit_critical(level: u32) {
#[ram]
#[no_mangle]
unsafe extern "C" fn rtc_get_xtal() -> u32 {
trace!("rtc_get_xtal - just hardcoded value 40 for now");
40
use crate::hal::clock::Clock;
let xtal = crate::hal::rtc_cntl::RtcClock::get_xtal_freq();
xtal.mhz()
}

#[no_mangle]
Expand Down
8 changes: 4 additions & 4 deletions esp-wifi/src/common_adapter/common_adapter_esp32c2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use crate::compat::common::str_from_c;
use crate::hal::system::RadioClockController;
use crate::hal::system::RadioPeripherals;

use atomic_polyfill::AtomicU32;
use core::sync::atomic::Ordering;
use portable_atomic::{AtomicU32, Ordering};

const SOC_PHY_DIG_REGS_MEM_SIZE: usize = 21 * 4;

Expand Down Expand Up @@ -139,6 +138,7 @@ pub(crate) unsafe fn phy_disable_clock() {

#[no_mangle]
pub extern "C" fn rtc_clk_xtal_freq_get() -> i32 {
// JUST SUPPORT 40MHz XTAL for now
40
use crate::hal::clock::Clock;
let xtal = crate::hal::rtc_cntl::RtcClock::get_xtal_freq();
xtal.mhz() as i32
}
11 changes: 5 additions & 6 deletions esp-wifi/src/common_adapter/common_adapter_esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use crate::compat::common::str_from_c;
use crate::hal::system::RadioClockController;
use crate::hal::system::RadioPeripherals;

use atomic_polyfill::AtomicU32;
use core::sync::atomic::Ordering;
use portable_atomic::{AtomicU32, Ordering};

const SOC_PHY_DIG_REGS_MEM_SIZE: usize = 21 * 4;

Expand Down Expand Up @@ -40,18 +39,18 @@ pub(crate) fn enable_wifi_power_domain() {
let syscon = &*crate::hal::peripherals::APB_CTRL::ptr();

rtc_cntl
.dig_pwc
.dig_pwc()
.modify(|_, w| w.wifi_force_pd().clear_bit());

syscon
.wifi_rst_en
.wifi_rst_en()
.modify(|r, w| w.bits(r.bits() | MODEM_RESET_FIELD_WHEN_PU));
syscon
.wifi_rst_en
.wifi_rst_en()
.modify(|r, w| w.bits(r.bits() & !MODEM_RESET_FIELD_WHEN_PU));

rtc_cntl
.dig_iso
.dig_iso()
.modify(|_, w| w.wifi_force_iso().clear_bit());
}
}
Expand Down
Loading

0 comments on commit d46dfc4

Please sign in to comment.