From e39e3177596d9af0ea33dc49ee959d7eca8bb14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 23 Aug 2024 15:22:29 +0200 Subject: [PATCH 1/2] Conditionally enable generic-queue feature --- hil-test/Cargo.toml | 9 ++++--- hil-test/tests/embassy_interrupt_executor.rs | 26 +++++++++++--------- hil-test/tests/embassy_timers_executors.rs | 1 + hil-test/tests/gpio.rs | 1 + hil-test/tests/i2s_async.rs | 1 + hil-test/tests/lcd_cam_i8080_async.rs | 1 + hil-test/tests/spi_full_duplex_dma_async.rs | 1 + hil-test/tests/uart_async.rs | 1 + hil-test/tests/uart_tx_rx_async.rs | 1 + 9 files changed, 28 insertions(+), 14 deletions(-) diff --git a/hil-test/Cargo.toml b/hil-test/Cargo.toml index fad3a4f8f10..5f56a44bfea 100644 --- a/hil-test/Cargo.toml +++ b/hil-test/Cargo.toml @@ -149,7 +149,7 @@ defmt = "0.3.8" defmt-rtt = { version = "0.4.1", optional = true } embassy-futures = "0.1.1" embassy-sync = "0.6.0" -embassy-time = { version = "0.3.1", features = ["generic-queue-64"] } +embassy-time = { version = "0.3.1" } embedded-hal = "1.0.0" embedded-hal-02 = { version = "0.2.7", package = "embedded-hal", features = ["unproven"] } embedded-hal-async = { version = "1.0.0", optional = true } @@ -166,7 +166,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.4.0", default-features = false } +embedded-test = { version = "0.4.0", default-features = false, git = "https://github.com/probe-rs/embedded-test.git", branch = "embassy" } fugit = "0.3.7" hex-literal = "0.4.1" nb = "1.1.0" @@ -214,8 +214,11 @@ embassy = [ "embedded-test/external-executor", "dep:esp-hal-embassy", ] +generic-queue = [ + "embassy-time/generic-queue-64" +] integrated-timers = [ - "embassy-executor/integrated-timers", + "esp-hal-embassy/integrated-timers", ] # https://doc.rust-lang.org/cargo/reference/profiles.html#test diff --git a/hil-test/tests/embassy_interrupt_executor.rs b/hil-test/tests/embassy_interrupt_executor.rs index 97bd21e814b..aefe42c7bc2 100644 --- a/hil-test/tests/embassy_interrupt_executor.rs +++ b/hil-test/tests/embassy_interrupt_executor.rs @@ -8,6 +8,15 @@ #![no_main] use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal}; +use esp_hal::{ + clock::ClockControl, + interrupt::Priority, + peripherals::Peripherals, + system::{SoftwareInterrupt, SystemControl}, + timer::timg::TimerGroup, +}; +use esp_hal_embassy::InterruptExecutor; +use hil_test as _; macro_rules! mk_static { ($t:ty,$val:expr) => {{ @@ -26,24 +35,19 @@ async fn interrupt_driven_task(signal: &'static Signal SoftwareInterrupt<1> { let peripherals = Peripherals::take(); let system = SystemControl::new(peripherals.SYSTEM); - let _clocks = ClockControl::boot_defaults(system.clock_control).freeze(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); + + let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks); + esp_hal_embassy::init(&clocks, timg0.timer0); + system.software_interrupt_control.software_interrupt1 } diff --git a/hil-test/tests/embassy_timers_executors.rs b/hil-test/tests/embassy_timers_executors.rs index 966a41d6461..03dc1b82795 100644 --- a/hil-test/tests/embassy_timers_executors.rs +++ b/hil-test/tests/embassy_timers_executors.rs @@ -1,6 +1,7 @@ //! Embassy timer and executor Test //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: integrated-timers #![no_std] #![no_main] diff --git a/hil-test/tests/gpio.rs b/hil-test/tests/gpio.rs index a9acca00f6f..3109041085c 100644 --- a/hil-test/tests/gpio.rs +++ b/hil-test/tests/gpio.rs @@ -5,6 +5,7 @@ //! GPIO3 //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: generic-queue #![no_std] #![no_main] diff --git a/hil-test/tests/i2s_async.rs b/hil-test/tests/i2s_async.rs index 345776d2a32..d6bb540b897 100644 --- a/hil-test/tests/i2s_async.rs +++ b/hil-test/tests/i2s_async.rs @@ -6,6 +6,7 @@ //! with loopback mode enabled). It's using circular DMA mode //% CHIPS: esp32c3 esp32c6 esp32s3 esp32h2 +//% FEATURES: generic-queue #![no_std] #![no_main] diff --git a/hil-test/tests/lcd_cam_i8080_async.rs b/hil-test/tests/lcd_cam_i8080_async.rs index cc57f291ab7..1d230ca1482 100644 --- a/hil-test/tests/lcd_cam_i8080_async.rs +++ b/hil-test/tests/lcd_cam_i8080_async.rs @@ -1,6 +1,7 @@ //! lcd_cam i8080 tests //% CHIPS: esp32s3 +//% FEATURES: generic-queue #![no_std] #![no_main] diff --git a/hil-test/tests/spi_full_duplex_dma_async.rs b/hil-test/tests/spi_full_duplex_dma_async.rs index cc0c4db5935..ba2a8f865d5 100644 --- a/hil-test/tests/spi_full_duplex_dma_async.rs +++ b/hil-test/tests/spi_full_duplex_dma_async.rs @@ -15,6 +15,7 @@ //! Connect PCNT (GPIO2) and MOSI (GPIO3) and MISO (GPIO6) and GPIO5 pins. //% CHIPS: esp32 esp32c6 esp32h2 esp32s3 +//% FEATURES: generic-queue #![no_std] #![no_main] diff --git a/hil-test/tests/uart_async.rs b/hil-test/tests/uart_async.rs index f7b8222953c..b3cb05612f2 100644 --- a/hil-test/tests/uart_async.rs +++ b/hil-test/tests/uart_async.rs @@ -7,6 +7,7 @@ //! Connect TX (GPIO2) and RX (GPIO3) pins. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: generic-queue #![no_std] #![no_main] diff --git a/hil-test/tests/uart_tx_rx_async.rs b/hil-test/tests/uart_tx_rx_async.rs index a74523d1b5f..627cab28aa0 100644 --- a/hil-test/tests/uart_tx_rx_async.rs +++ b/hil-test/tests/uart_tx_rx_async.rs @@ -7,6 +7,7 @@ //! Connect TX (GPIO2) and RX (GPIO3) pins. //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 +//% FEATURES: generic-queue #![no_std] #![no_main] From 21a54d5bad9f4b60a57ba36426a552ebc4a12f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 23 Aug 2024 17:10:07 +0200 Subject: [PATCH 2/2] Allow specifying multiple feature sets and run all of them --- hil-test/Cargo.toml | 4 +- hil-test/tests/embassy_interrupt_executor.rs | 1 + hil-test/tests/embassy_timers_executors.rs | 1 + xtask/src/lib.rs | 58 ++++++++++++++------ 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/hil-test/Cargo.toml b/hil-test/Cargo.toml index 5f56a44bfea..885ce9aea74 100644 --- a/hil-test/Cargo.toml +++ b/hil-test/Cargo.toml @@ -136,7 +136,7 @@ required-features = ["async", "embassy"] [[test]] name = "embassy_interrupt_executor" harness = false -required-features = ["async", "embassy", "integrated-timers"] +required-features = ["async", "embassy"] [[test]] name = "twai" @@ -166,7 +166,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.4.0", default-features = false, git = "https://github.com/probe-rs/embedded-test.git", branch = "embassy" } +embedded-test = { version = "0.4.0", default-features = false } fugit = "0.3.7" hex-literal = "0.4.1" nb = "1.1.0" diff --git a/hil-test/tests/embassy_interrupt_executor.rs b/hil-test/tests/embassy_interrupt_executor.rs index aefe42c7bc2..acb6b2c60ba 100644 --- a/hil-test/tests/embassy_interrupt_executor.rs +++ b/hil-test/tests/embassy_interrupt_executor.rs @@ -3,6 +3,7 @@ //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 //% FEATURES: integrated-timers +//% FEATURES: generic-queue #![no_std] #![no_main] diff --git a/hil-test/tests/embassy_timers_executors.rs b/hil-test/tests/embassy_timers_executors.rs index 03dc1b82795..c44605dd7ed 100644 --- a/hil-test/tests/embassy_timers_executors.rs +++ b/hil-test/tests/embassy_timers_executors.rs @@ -2,6 +2,7 @@ //% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3 //% FEATURES: integrated-timers +//% FEATURES: generic-queue #![no_std] #![no_main] diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index c2349a71710..9e28b57faab 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -57,11 +57,11 @@ pub enum Package { pub struct Metadata { example_path: PathBuf, chips: Vec, - features: Vec, + feature_sets: Vec>, } impl Metadata { - pub fn new(example_path: &Path, chips: Vec, features: Vec) -> Self { + pub fn new(example_path: &Path, chips: Vec, feature_sets: Vec>) -> Self { let chips = if chips.is_empty() { Chip::iter().collect() } else { @@ -71,7 +71,7 @@ impl Metadata { Self { example_path: example_path.to_path_buf(), chips, - features, + feature_sets, } } @@ -90,8 +90,8 @@ impl Metadata { } /// A list of all features required for building a given examples. - pub fn features(&self) -> &[String] { - &self.features + pub fn feature_sets(&self) -> &[Vec] { + &self.feature_sets } /// If the specified chip is in the list of chips, then it is supported. @@ -155,7 +155,7 @@ pub fn load_examples(path: &Path) -> Result> { .with_context(|| format!("Could not read {}", path.display()))?; let mut chips = Vec::new(); - let mut features = Vec::new(); + let mut feature_sets = Vec::new(); // We will indicate metadata lines using the `//%` prefix: for line in text.lines().filter(|line| line.starts_with("//%")) { @@ -183,13 +183,13 @@ pub fn load_examples(path: &Path) -> Result> { .map(|s| Chip::from_str(s, false).unwrap()) .collect::>(); } else if key == "FEATURES" { - features = split.into(); + feature_sets.push(split.into()); } else { log::warn!("Unrecognized metadata key '{key}', ignoring"); } } - examples.push(Metadata::new(&path, chips, features)); + examples.push(Metadata::new(&path, chips, feature_sets)); } Ok(examples) @@ -202,19 +202,45 @@ pub fn execute_app( target: &str, app: &Metadata, action: CargoAction, - mut repeat: usize, + repeat: usize, ) -> Result<()> { log::info!( "Building example '{}' for '{}'", app.example_path().display(), chip ); - if !app.features().is_empty() { - log::info!(" Features: {}", app.features().join(",")); + + let feature_sets = if app.feature_sets().is_empty() { + vec![vec![]] + } else { + app.feature_sets().to_vec() + }; + + for features in feature_sets { + execute_app_with_features(package_path, chip, target, app, action, repeat, features)?; } + Ok(()) +} + +/// Run or build the specified test or example for the specified chip, with the +/// specified features enabled. +pub fn execute_app_with_features( + package_path: &Path, + chip: Chip, + target: &str, + app: &Metadata, + action: CargoAction, + mut repeat: usize, + mut features: Vec, +) -> Result<()> { + if !features.is_empty() { + log::info!("Features: {}", features.join(",")); + } + features.push(chip.to_string()); + let package = app.example_path().strip_prefix(package_path)?; - log::info!("Package: {:?}", package); + log::info!("Package: {}", package.display()); let (bin, subcommand) = if action == CargoAction::Build { repeat = 1; // Do not repeat builds in a loop let bin = if package.starts_with("src/bin") { @@ -233,9 +259,6 @@ pub fn execute_app( (format!("--example={}", app.name()), "run") }; - let mut features = app.features().to_vec(); - features.push(chip.to_string()); - let mut builder = CargoArgsBuilder::default() .subcommand(subcommand) .arg("--release") @@ -256,7 +279,10 @@ pub fn execute_app( let args = builder.build(); log::debug!("{args:#?}"); - for _ in 0..repeat { + for i in 0..repeat { + if repeat != 1 { + log::info!("Run {}/{}", i + 1, repeat); + } cargo::run(&args, package_path)?; }