Skip to content

Commit

Permalink
Update HIL to probe-rs#2292 (#1307)
Browse files Browse the repository at this point in the history
* feat: Update probe-rs/embedded-test to probe-rs#2292

* feat: Remove lib
  • Loading branch information
SergioGasquez authored Mar 18, 2024
1 parent 9cfef08 commit ffe61e8
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 47 deletions.
12 changes: 8 additions & 4 deletions hil-test/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
[env]
DEFMT_LOG="debug"
DEFMT_LOG="info"
RUST_LOG = "warn"

[target.'cfg(target_arch = "riscv32")']
runner = "probe-rs test --"
runner = "probe-rs run"
rustflags = [
"-C", "link-arg=-Tlinkall.x",
"-C", "link-arg=-Tdefmt.x",
"-C", "link-arg=-Tembedded-test.x",
"-C", "link-arg=-Tdefmt.x", # Comment this line when using log feature
]

[target.'cfg(target_arch = "xtensa")']
# TODO: Xtensa not yet fully supported by `probe-rs`
runner = "probe-rs test --"
runner = "probe-rs run"
rustflags = [
"-C", "link-arg=-nostartfiles",
"-C", "link-arg=-Wl,-Tlinkall.x",
"-C", "link-arg=-Tdefmt.x",
"-C", "link-arg=-Tembedded-test.x",

]
44 changes: 18 additions & 26 deletions hil-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ version = "0.0.0"
edition = "2021"
publish = false

[lib]
harness = false
test = false

[[test]]
name = "aes"
harness = false
Expand All @@ -24,42 +20,44 @@ harness = false
name = "uart"
harness = false


[dependencies]
defmt = "0.3.5"
defmt-rtt = "0.4.0"
embedded-test = "0.3.0"
panic-probe = "0.3.1"
semihosting = "0.1.6"

# HAL package:
esp-hal = { path = "../esp-hal", features = ["defmt", "eh1"], optional = true }

# Traits:
defmt = { version = "0.3.5", optional = true }
defmt-rtt = { version = "0.4.0", optional = true }
log = { version = "0.4.20", optional = true }
esp-hal = { path = "../esp-hal", features = ["eh1"], optional = true }
embedded-hal = { version = "0.2.7", features = ["unproven"] }
embedded-hal-async = { version = "1.0.0", optional = true }
embedded-hal-1 = { version = "1.0.0", package = "embedded-hal" }
embassy-executor = { default-features = false, version = "0.5.0", features = ["executor-thread", "arch-riscv32"], optional = true }

[dev-dependencies]
embedded-test = {git = "https://github.com/probe-rs/embedded-test/", branch = "next"}

[features]
default = ["defmt"]
# Device support (required!):
esp32 = ["esp-hal/esp32"]
esp32c2 = ["esp-hal/esp32c2"]
esp32c3 = ["esp-hal/esp32c3"]
esp32c6 = ["esp-hal/esp32c6"]
esp32h2 = ["esp-hal/esp32h2"]
esp32s2 = ["esp-hal/esp32s2"]
esp32s3 = ["esp-hal/esp32s3"]

# Async & Embassy:
async = ["dep:embedded-hal-async", "esp-hal?/async"]

embassy = ["esp-hal?/embassy"]

embassy = ["esp-hal?/embassy", "embedded-test/embassy", "dep:embassy-executor"]
embassy-executor-interrupt = ["esp-hal?/embassy-executor-interrupt"]
embassy-executor-thread = ["esp-hal?/embassy-executor-thread"]

embassy-time-systick-16mhz = ["esp-hal?/embassy-time-systick-16mhz"]
embassy-time-systick-80mhz = ["esp-hal?/embassy-time-systick-80mhz"]
embassy-time-timg0 = ["esp-hal?/embassy-time-timg0"]
# Loggging:
# Adding log feature of embedded test to defmt or log makes the testing more verbose
# log = ["dep:log", "embedded-test/log", "embedded-test/init-log"]
# defmt = ["dep:defmt", "dep:defmt-rtt", "embedded-test/defmt"]
log = ["dep:log", "embedded-test/init-log", "esp-hal?/log"]
# Using defmt crate requires editting `.cargo/config.toml`rustflags.
defmt = ["dep:defmt", "dep:defmt-rtt", "esp-hal?/defmt"]

# cargo build/run
[profile.dev]
Expand Down Expand Up @@ -98,9 +96,3 @@ incremental = false
lto = 'fat'
opt-level = 3 # <-
overflow-checks = false # <-

# TODO: remove when able
[patch.crates-io]
# FIXME: defmt patch can be removed since embedded-test already takes care of that?
defmt = { git = "https://github.com/t-moe/defmt", branch = "features/defmt_test_riscv" }
panic-probe = { git = "https://github.com/t-moe/defmt", branch = "features/defmt_test_riscv" }
21 changes: 19 additions & 2 deletions hil-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ The `hil.yml` workflow will build the test suite for all our available targets a
Currently, here are the Virtual Machines set up for HIL testing:
- ESP32-C3:
- Has an `ESP32-C3-DevKit-RUST-1` connected via USB-JTAG-SERIAL.
- Pins 2 and 4 are connected for `spi_full_duplex` and `uart` tests.
- VM has the following setup:
```
# Install Rust:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y --profile minimal
# Source the current shell:
$ source "$HOME/.cargo/env"
# Install dependencies
$ sudo apt install -y pkg-config libudev-dev
# Install probe-rs
$ cargo install probe-rs --git=https://github.com/probe-rs/probe-rs --branch=feature/testing-rebased --features=cli --bin=probe-rs --locked --force
# Add the udev rules
$ wget -O - https://probe.rs/files/69-probe-rs.rules | sudo tee /etc/udev/rules.d/69-probe-rs.rules > /dev/null
# Add the user to plugdev group
$ sudo usermod -a -G plugdev $USER
# Reboot the VM
```
- ESP32-C6:
- Has an `ESP32-C6-DevKitC-1 V1.2` connected via USB-JTAG-SERIAL.
- Pins 2 and 4 are connected for `spi_full_duplex` and `uart` tests.
Expand All @@ -71,7 +88,7 @@ Currently, here are the Virtual Machines set up for HIL testing:
# Install dependencies
$ sudo apt install -y pkg-config libudev-dev
# Install probe-rs
$ cargo install probe-rs --git=https://github.com/SergioGasquez/probe-rs --branch=feature/testing --features=cli --bin=probe-rs --locked --force
$ cargo install probe-rs --git=https://github.com/probe-rs/probe-rs --branch=feature/testing-rebased --features=cli --bin=probe-rs --locked --force
# Add the udev rules
$ wget -O - https://probe.rs/files/69-probe-rs.rules | sudo tee /etc/udev/rules.d/69-probe-rs.rules > /dev/null
# Add the user to plugdev group
Expand All @@ -90,7 +107,7 @@ Currently, here are the Virtual Machines set up for HIL testing:
# Install dependencies
$ sudo apt install -y pkg-config libudev-dev
# Install probe-rs
$ cargo install probe-rs --git=https://github.com/SergioGasquez/probe-rs --branch=feature/testing --features=cli --bin=probe-rs --locked --force
$ cargo install probe-rs --git=https://github.com/probe-rs/probe-rs --branch=feature/testing-rebased --features=cli --bin=probe-rs --locked --force
# Add the udev rules
$ wget -O - https://probe.rs/files/69-probe-rs.rules | sudo tee /etc/udev/rules.d/69-probe-rs.rules > /dev/null
# Add the user to plugdev group
Expand Down
6 changes: 0 additions & 6 deletions hil-test/src/lib.rs

This file was deleted.

6 changes: 5 additions & 1 deletion hil-test/tests/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#![no_std]
#![no_main]

use hil_test::esp_hal::{
#[cfg(feature = "defmt")]
use defmt_rtt as _;
use esp_hal::{
aes::{Aes, Mode},
peripherals::Peripherals,
};
Expand All @@ -21,8 +23,10 @@ impl Context<'_> {
}
}

#[cfg(test)]
#[embedded_test::tests]
mod tests {
#[cfg(feature = "defmt")]
use defmt::assert_eq;

use super::*;
Expand Down
16 changes: 10 additions & 6 deletions hil-test/tests/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
#![no_std]
#![no_main]

#[cfg(feature = "defmt")]
use defmt_rtt as _;
use embedded_hal_1::digital::{InputPin as _, OutputPin as _, StatefulOutputPin as _};
use hil_test::esp_hal::{
use esp_hal::{
gpio::{GpioPin, Input, Output, PullDown, PushPull, IO},
peripherals::Peripherals,
};
Expand All @@ -30,9 +32,11 @@ impl Context {
}
}

#[cfg(test)]
#[embedded_test::tests]
mod tests {
use defmt::{assert_eq, unwrap};
#[cfg(feature = "defmt")]
use defmt::assert_eq;

use super::*;

Expand All @@ -53,18 +57,18 @@ mod tests {
// `StatefulOutputPin`:
assert_eq!(ctx.io1.is_set_low(), Ok(true));
assert_eq!(ctx.io1.is_set_high(), Ok(false));
unwrap!(ctx.io1.set_high());
assert!(ctx.io1.set_high().is_ok());
assert_eq!(ctx.io1.is_set_low(), Ok(false));
assert_eq!(ctx.io1.is_set_high(), Ok(true));

// `ToggleableOutputPin`:
unwrap!(ctx.io1.toggle());
assert!(ctx.io1.toggle().is_ok());
assert_eq!(ctx.io1.is_set_low(), Ok(true));
assert_eq!(ctx.io1.is_set_high(), Ok(false));
unwrap!(ctx.io1.toggle());
assert!(ctx.io1.toggle().is_ok());
assert_eq!(ctx.io1.is_set_low(), Ok(false));
assert_eq!(ctx.io1.is_set_high(), Ok(true));
// Leave in initial state for next test
unwrap!(ctx.io1.toggle());
assert!(ctx.io1.toggle().is_ok());
}
}
6 changes: 5 additions & 1 deletion hil-test/tests/spi_full_duplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#![no_std]
#![no_main]

use hil_test::esp_hal::{
#[cfg(feature = "defmt")]
use defmt_rtt as _;
use esp_hal::{
clock::ClockControl,
gpio::IO,
peripherals::Peripherals,
Expand Down Expand Up @@ -46,8 +48,10 @@ impl Context {
}
}

#[cfg(test)]
#[embedded_test::tests]
mod tests {
#[cfg(feature = "defmt")]
use defmt::assert_eq;

use super::*;
Expand Down
6 changes: 5 additions & 1 deletion hil-test/tests/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#![no_std]
#![no_main]

use hil_test::esp_hal::{
#[cfg(feature = "defmt")]
use defmt_rtt as _;
use esp_hal::{
clock::ClockControl,
peripherals::{Peripherals, UART0},
prelude::*,
Expand Down Expand Up @@ -48,8 +50,10 @@ impl Context {
}
}

#[cfg(test)]
#[embedded_test::tests]
mod tests {
#[cfg(feature = "defmt")]
use defmt::assert_eq;

use super::*;
Expand Down

0 comments on commit ffe61e8

Please sign in to comment.