Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test all feature sets #2901

Merged
merged 8 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions .github/workflows/hil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,10 @@ jobs:
- name: Build tests
run: cargo xtask build-tests ${{ matrix.target.soc }}

- name: Prepare artifact
run: |
# Create the 'tests' directory if it doesn't exist
mkdir -p tests

# Find ELF files in the specified path and move them to 'tests'
find "hil-test/target/${{ matrix.target.rust-target }}/release/deps/" -type f -exec file {} + | \
grep ELF | \
awk -F: '{print $1}' | \
xargs -I {} mv {} tests

# Rename files in 'tests' by removing everything after the first dash
for file in tests/*-*; do
base_name="$(basename "$file" | cut -d'-' -f1)"
mv "$file" "tests/$base_name"
done
- uses: actions/upload-artifact@v4
with:
name: tests-${{ matrix.target.soc }}
path: /home/runner/work/esp-hal/esp-hal/tests
path: /home/runner/work/esp-hal/esp-hal/target/tests/${{ matrix.target.soc }}
if-no-files-found: error
overwrite: true

Expand Down
4 changes: 4 additions & 0 deletions esp-hal/src/gpio/interconnect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ fn disconnect_peripheral_output_from_pin(pin: &mut AnyPin, signal: gpio::OutputS
/// A configurable input signal between a peripheral and a GPIO pin.
///
/// Multiple input signals can be connected to one pin.
#[instability::unstable]
pub struct InputSignal {
pin: AnyPin,
is_inverted: bool,
Expand Down Expand Up @@ -350,6 +351,7 @@ impl DirectInputSignal {
/// A configurable output signal between a peripheral and a GPIO pin.
///
/// Multiple pins can be connected to one output signal.
#[instability::unstable]
pub struct OutputSignal {
pin: AnyPin,
is_inverted: bool,
Expand Down Expand Up @@ -512,6 +514,7 @@ enum InputConnectionInner {
/// This is mainly intended for internal use, but it can be used to connect
/// peripherals within the MCU without external hardware.
#[derive(Clone)]
#[doc(hidden)] // FIXME: replace with `#[unstable]` when we can mark delegated methods https://github.com/Kobzol/rust-delegate/issues/77
pub struct InputConnection(InputConnectionInner);

impl Peripheral for InputConnection {
Expand Down Expand Up @@ -623,6 +626,7 @@ enum OutputConnectionInner {
///
/// This is mainly intended for internal use, but it can be used to connect
/// peripherals within the MCU without external hardware.
#[doc(hidden)] // FIXME: replace with `#[unstable]` when we can mark delegated methods https://github.com/Kobzol/rust-delegate/issues/77
pub struct OutputConnection(OutputConnectionInner);

impl Sealed for OutputConnection {}
Expand Down
31 changes: 23 additions & 8 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,20 @@ use crate::{
private::{self, Sealed},
};

pub mod interconnect;
mod placeholder;

pub use placeholder::NoPin;

#[cfg(soc_etm)]
crate::unstable_module! {
pub mod interconnect;

#[cfg(soc_etm)]
pub mod etm;
}

#[cfg(lp_io)]
crate::unstable_module! {
#[cfg(lp_io)]
pub mod lp_io;
}

#[cfg(all(rtc_io, not(esp32)))]
crate::unstable_module! {
#[cfg(all(rtc_io, not(esp32)))]
pub mod rtc_io;
}

Expand Down Expand Up @@ -796,6 +793,7 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
(
interconnect::InputSignal::new(self.degrade_pin(private::Internal)),
Expand Down Expand Up @@ -1303,6 +1301,8 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[inline]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
self.pin.split()
}
Expand All @@ -1312,6 +1312,7 @@ where
///
/// The input signal can be passed to peripherals in place of an input pin.
#[inline]
#[instability::unstable]
pub fn peripheral_input(&self) -> interconnect::InputSignal {
self.pin.peripheral_input()
}
Expand All @@ -1322,6 +1323,7 @@ where
/// The output signal can be passed to peripherals in place of an output
/// pin.
#[inline]
#[instability::unstable]
pub fn into_peripheral_output(self) -> interconnect::OutputSignal {
self.pin.into_peripheral_output()
}
Expand Down Expand Up @@ -1499,6 +1501,7 @@ where
///
/// The input signal can be passed to peripherals in place of an input pin.
#[inline]
#[instability::unstable]
pub fn peripheral_input(&self) -> interconnect::InputSignal {
self.pin.peripheral_input()
}
Expand Down Expand Up @@ -1630,6 +1633,8 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[inline]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
self.pin.split()
}
Expand All @@ -1640,6 +1645,7 @@ where
/// The output signal can be passed to peripherals in place of an output
/// pin.
#[inline]
#[instability::unstable]
pub fn into_peripheral_output(self) -> interconnect::OutputSignal {
self.pin.into_peripheral_output()
}
Expand Down Expand Up @@ -1765,6 +1771,8 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[inline]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
self.pin.split()
}
Expand All @@ -1774,6 +1782,7 @@ where
///
/// The input signal can be passed to peripherals in place of an input pin.
#[inline]
#[instability::unstable]
pub fn peripheral_input(&self) -> interconnect::InputSignal {
self.pin.peripheral_input()
}
Expand All @@ -1784,6 +1793,7 @@ where
/// The output signal can be passed to peripherals in place of an output
/// pin.
#[inline]
#[instability::unstable]
pub fn into_peripheral_output(self) -> interconnect::OutputSignal {
self.pin.into_peripheral_output()
}
Expand Down Expand Up @@ -1920,6 +1930,7 @@ where
///
/// The input signal can be passed to peripherals in place of an input pin.
#[inline]
#[instability::unstable]
pub fn peripheral_input(&self) -> interconnect::InputSignal {
self.pin.degrade_pin(private::Internal).split().0
}
Expand Down Expand Up @@ -2092,6 +2103,8 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[inline]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
self.pin.degrade_pin(private::Internal).split()
}
Expand All @@ -2102,6 +2115,7 @@ where
/// The output signal can be passed to peripherals in place of an output
/// pin.
#[inline]
#[instability::unstable]
pub fn into_peripheral_output(self) -> interconnect::OutputSignal {
self.split().1
}
Expand Down Expand Up @@ -2154,6 +2168,7 @@ pub(crate) mod internal {
/// using external hardware.
#[inline]
#[allow(unused_braces, reason = "False positive")]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
handle_gpio_input!(self, target, { target.split() })
}
Expand Down
12 changes: 7 additions & 5 deletions hil-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ cfg-if = "1.0.0"
critical-section = "1.1.3"
defmt = "0.3.8"
defmt-rtt = { version = "0.4.1", optional = true }
embassy-executor = "0.6.0"
embassy-futures = "0.1.1"
embassy-sync = "0.6.0"
embassy-time = "0.3.2"
Expand All @@ -206,7 +207,7 @@ embedded-hal-async = "1.0.0"
embedded-hal-nb = "1.0.0"
esp-alloc = { path = "../esp-alloc", optional = true }
esp-backtrace = { path = "../esp-backtrace", default-features = false, features = ["exception-handler", "defmt", "semihosting"] }
esp-hal = { path = "../esp-hal", features = ["digest", "unstable"], optional = true }
esp-hal = { path = "../esp-hal", features = ["digest"], optional = true }
esp-hal-embassy = { path = "../esp-hal-embassy", optional = true }
esp-wifi = { path = "../esp-wifi", optional = true, features = ["wifi"] }
portable-atomic = "1.9.0"
Expand All @@ -220,7 +221,7 @@ digest = { version = "0.10.7", default-features = false }
elliptic-curve = { version = "0.13.8", default-features = false, features = ["sec1"] }
embassy-executor = { version = "0.6.0", default-features = false }
# Add the `embedded-test/defmt` feature for more verbose testing
embedded-test = { version = "0.5.0", git = "https://github.com/probe-rs/embedded-test.git", rev = "7109473", default-features = false }
embedded-test = { version = "0.5.0", git = "https://github.com/probe-rs/embedded-test.git", rev = "7109473", default-features = false, features = ["embassy", "external-executor"] }
fugit = "0.3.7"
hex-literal = "0.4.1"
nb = "1.1.0"
Expand All @@ -234,7 +235,8 @@ esp-build = { path = "../esp-build" }
esp-metadata = { path = "../esp-metadata" }

[features]
default = ["embassy"]
default = []
unstable = ["esp-hal/unstable"]

defmt = ["dep:defmt-rtt", "esp-hal/defmt", "embedded-test/defmt"]

Expand Down Expand Up @@ -286,14 +288,14 @@ esp32s3 = [
]
# Async & Embassy:
embassy = [
"embedded-test/embassy",
"embedded-test/external-executor",
"dep:esp-hal-embassy",
]
generic-queue = [
"embassy",
"embassy-time/generic-queue-64"
]
integrated-timers = [
"embassy",
"esp-hal-embassy/integrated-timers",
]
octal-psram = ["esp-hal/octal-psram", "esp-alloc"]
Expand Down
39 changes: 39 additions & 0 deletions hil-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,42 @@ macro_rules! unconnected_pin {
}
}};
}

// A simple looping executor to test async code without esp-hal-embassy (which
// needs `esp-hal/unstable`).
#[cfg(not(feature = "embassy"))]
mod executor {
use core::marker::PhantomData;

use embassy_executor::{raw, Spawner};

#[export_name = "__pender"]
fn __pender(_: *mut ()) {}

pub struct Executor {
inner: raw::Executor,
not_send: PhantomData<*mut ()>,
}

impl Executor {
pub fn new() -> Self {
Self {
inner: raw::Executor::new(core::ptr::null_mut()),
not_send: PhantomData,
}
}

pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! {
init(self.inner.spawner());

loop {
unsafe { self.inner.poll() };
}
}
}
}

#[cfg(feature = "embassy")]
pub use esp_hal_embassy::Executor;
#[cfg(not(feature = "embassy"))]
pub use executor::Executor;
1 change: 1 addition & 0 deletions hil-test/tests/aes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! AES Test

//% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down
1 change: 1 addition & 0 deletions hil-test/tests/aes_dma.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! AES DMA Test

//% CHIPS: esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down
1 change: 1 addition & 0 deletions hil-test/tests/clock_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Clock Monitor Test

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down
1 change: 1 addition & 0 deletions hil-test/tests/crc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! CRC and MD5 Tests

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down
1 change: 1 addition & 0 deletions hil-test/tests/critical_section.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Ensure invariants of locks are upheld.

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: unstable

// TODO: add multi-core tests

Expand Down
1 change: 1 addition & 0 deletions hil-test/tests/delay.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Delay Test
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down
3 changes: 2 additions & 1 deletion hil-test/tests/delay_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! `embedded_hal_async::delay::DelayNs` trait.

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down Expand Up @@ -69,7 +70,7 @@ async fn test_async_delay_ms(mut timer: impl DelayNs, duration: u32) {
}

#[cfg(test)]
#[embedded_test::tests(default_timeout = 2, executor = esp_hal_embassy::Executor::new())]
#[embedded_test::tests(default_timeout = 2, executor = hil_test::Executor::new())]
mod tests {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions hil-test/tests/dma_macros.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! DMA macro tests

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down
1 change: 1 addition & 0 deletions hil-test/tests/dma_mem2mem.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! DMA Mem2Mem Tests

//% CHIPS: esp32c2 esp32c3 esp32c6 esp32h2 esp32s3
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down
1 change: 1 addition & 0 deletions hil-test/tests/ecc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! ECC Test

//% CHIPS: esp32c2 esp32c6 esp32h2
//% FEATURES: unstable

#![no_std]
#![no_main]
Expand Down
Loading
Loading