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

Enable C2 HIL #1680

Merged
merged 6 commits into from
Jun 26, 2024
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ jobs:
matrix:
target:
# RISC-V devices:
- soc: esp32c2
rust-target: riscv32imc-unknown-none-elf
- soc: esp32c3
rust-target: riscv32imc-unknown-none-elf
- soc: esp32c6
Expand Down Expand Up @@ -362,4 +364,4 @@ jobs:
ldproxy: false

- uses: Swatinem/rust-cache@v2
- run: cargo xtask build-tests ${{ matrix.target.soc }}
- run: cargo xtask build-tests ${{ matrix.target.soc }}
4 changes: 4 additions & 0 deletions .github/workflows/hil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
matrix:
target:
# RISC-V devices:
- soc: esp32c2
rust-target: riscv32imc-unknown-none-elf
- soc: esp32c3
rust-target: riscv32imc-unknown-none-elf
- soc: esp32c6
Expand Down Expand Up @@ -99,6 +101,8 @@ jobs:
matrix:
target:
# RISC-V devices:
- soc: esp32c2
runner: esp32c2-jtag
- soc: esp32c3
runner: esp32c3-usb
- soc: esp32c6
Expand Down
19 changes: 13 additions & 6 deletions hil-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,39 @@ Some tests will require physical connections, please see the current [configurat
### Running Tests Remotes (ie. On Self-Hosted Runners)
The [`hil.yml`] workflow builds the test suite for all our available targets and executes them.

Our Virtual Machines have the following setup:
Our self hosted runners have the following setup:
- ESP32-C2 (`esp32c2-jtag`):
- Devkit: `ESP8684-DevKitM-1` connected via UART.
- `GPIO2` and `GPIO3` are connected.
- Probe: `ESP-Prog` connected with the [following connections](https://docs.espressif.com/projects/esp-idf/en/stable/esp32c2/api-guides/jtag-debugging/configure-other-jtag.html#configure-hardware)
- RPi: Raspbian 12 configured with the following [setup](#vm-setup)
- ESP32-C3 (`rustboard`):
- Devkit: `ESP32-C3-DevKit-RUST-1` connected via USB-Serial-JTAG.
- `GPIO2` and `GPIO4` are connected.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO6` are connected.
- RPi: Raspbian 12 configured with the following [setup](#vm-setup)
- ESP32-C6 (`esp32c6-usb`):
- Devkit: `ESP32-C6-DevKitC-1 V1.2` connected via USB-Serial-JTAG (`USB` port).
- `GPIO2` and `GPIO4` are connected.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO6` are connected.
- RPi: Raspbian 12 configured with the following [setup](#vm-setup)
- ESP32-H2 (`esp32h2-usb`):
- Devkit: `ESP32-H2-DevKitM-1` connected via USB-Serial-JTAG (`USB` port).
- `GPIO2` and `GPIO4` are connected.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO8` are connected.
- RPi: Raspbian 12 configured with the following [setup](#vm-setup)
- ESP32-S2 (`esp32s2-jtag`):
- Devkit: `ESP32-S2-Saola-1` connected via UART.
- `GPIO2` and `GPIO4` are connected.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO6` are connected.
- Probe: `ESP-Prog` connected with the [following connections](https://docs.espressif.com/projects/esp-idf/en/stable/esp32s2/api-guides/jtag-debugging/configure-other-jtag.html#configure-hardware)
- RPi: Raspbian 12 configured with the following [setup](#vm-setup)
- ESP32-S3 (`esp32s3-usb`):
- Devkit: `ESP32-S3-DevKitC-1` connected via USB-Serial-JTAG.
- `GPIO2` and `GPIO4` are connected.
- `GPIO2` and `GPIO3` are connected.
- `GPIO5` and `GPIO6` are connected.
- `GPIO1` and `GPIO21` are connected.
- `GPIO43 (TX)` and `GPIO45` are connected.
- RPi: Raspbian 12 configured with the following [setup](#vm-setup)

[`hil.yml`]: https://github.com/esp-rs/esp-hal/blob/main/.github/workflows/hil.yml
Expand Down
3 changes: 2 additions & 1 deletion 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 esp32s3
// esp32c2 is disabled currently as it fails
//% CHIPS: esp32 esp32c3 esp32c6 esp32s3

#![no_std]
#![no_main]
Expand Down
3 changes: 2 additions & 1 deletion hil-test/tests/get_time.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! current_time Test

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
// esp32c2 is disabled currently as it fails
//% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3

#![no_std]
#![no_main]
Expand Down
100 changes: 50 additions & 50 deletions hil-test/tests/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Folowing pins are used:
//! GPIO2
//! GPIO4
//! GPIO3

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

Expand All @@ -17,7 +17,7 @@ use esp_backtrace as _;
use esp_hal::{
clock::ClockControl,
delay::Delay,
gpio::{Gpio2, Gpio4, GpioPin, Input, Io, Level, Output, Pull},
gpio::{Gpio2, Gpio3, GpioPin, Input, Io, Level, Output, Pull},
macros::handler,
peripherals::Peripherals,
system::SystemControl,
Expand All @@ -29,7 +29,7 @@ static INPUT_PIN: Mutex<RefCell<Option<Input<'static, Gpio2>>>> = Mutex::new(Ref

struct Context<'d> {
io2: Input<'d, Gpio2>,
io4: Output<'d, Gpio4>,
io3: Output<'d, Gpio3>,
delay: Delay,
}

Expand All @@ -49,7 +49,7 @@ impl<'d> Context<'d> {

Context {
io2: Input::new(io.pins.gpio2, Pull::Down),
io4: Output::new(io.pins.gpio4, Level::Low),
io3: Output::new(io.pins.gpio3, Level::Low),
delay,
}
}
Expand Down Expand Up @@ -80,15 +80,15 @@ mod tests {
fn init() -> Context<'static> {
let mut ctx = Context::init();
// make sure tests don't interfere with each other
ctx.io4.set_low();
ctx.io3.set_low();
ctx
}

#[test]
async fn test_async_edge(ctx: Context<'static>) {
let counter = AtomicUsize::new(0);
let Context {
mut io2, mut io4, ..
mut io2, mut io3, ..
} = ctx;
embassy_futures::select::select(
async {
Expand All @@ -99,9 +99,9 @@ mod tests {
},
async {
for _ in 0..5 {
io4.set_high();
io3.set_high();
Timer::after(Duration::from_millis(25)).await;
io4.set_low();
io3.set_low();
Timer::after(Duration::from_millis(25)).await;
}
},
Expand Down Expand Up @@ -133,19 +133,19 @@ mod tests {
#[test]
fn test_gpio_output(mut ctx: Context<'static>) {
// `StatefulOutputPin`:
assert_eq!(ctx.io4.is_set_low(), true);
assert_eq!(ctx.io4.is_set_high(), false);
ctx.io4.set_high();
assert_eq!(ctx.io4.is_set_low(), false);
assert_eq!(ctx.io4.is_set_high(), true);
assert_eq!(ctx.io3.is_set_low(), true);
assert_eq!(ctx.io3.is_set_high(), false);
ctx.io3.set_high();
assert_eq!(ctx.io3.is_set_low(), false);
assert_eq!(ctx.io3.is_set_high(), true);

// `ToggleableOutputPin`:
ctx.io4.toggle();
assert_eq!(ctx.io4.is_set_low(), true);
assert_eq!(ctx.io4.is_set_high(), false);
ctx.io4.toggle();
assert_eq!(ctx.io4.is_set_low(), false);
assert_eq!(ctx.io4.is_set_high(), true);
ctx.io3.toggle();
assert_eq!(ctx.io3.is_set_low(), true);
assert_eq!(ctx.io3.is_set_high(), false);
ctx.io3.toggle();
assert_eq!(ctx.io3.is_set_low(), false);
assert_eq!(ctx.io3.is_set_high(), true);
}

#[test]
Expand All @@ -155,23 +155,23 @@ mod tests {
ctx.io2.listen(Event::AnyEdge);
INPUT_PIN.borrow_ref_mut(cs).replace(ctx.io2);
});
ctx.io4.set_high();
ctx.io3.set_high();
ctx.delay.delay_millis(1);
ctx.io4.set_low();
ctx.io3.set_low();
ctx.delay.delay_millis(1);
ctx.io4.set_high();
ctx.io3.set_high();
ctx.delay.delay_millis(1);
ctx.io4.set_low();
ctx.io3.set_low();
ctx.delay.delay_millis(1);
ctx.io4.set_high();
ctx.io3.set_high();
ctx.delay.delay_millis(1);
ctx.io4.set_low();
ctx.io3.set_low();
ctx.delay.delay_millis(1);
ctx.io4.set_high();
ctx.io3.set_high();
ctx.delay.delay_millis(1);
ctx.io4.set_low();
ctx.io3.set_low();
ctx.delay.delay_millis(1);
ctx.io4.set_high();
ctx.io3.set_high();
ctx.delay.delay_millis(1);

let count = critical_section::with(|cs| *COUNTER.borrow_ref(cs));
Expand All @@ -184,86 +184,86 @@ mod tests {
#[test]
fn test_gpio_od(ctx: Context<'static>) {
let mut io2 = OutputOpenDrain::new(unsafe { GpioPin::<2>::steal() }, Level::High, Pull::Up);
let mut io4 = OutputOpenDrain::new(unsafe { GpioPin::<4>::steal() }, Level::High, Pull::Up);
let mut io3 = OutputOpenDrain::new(unsafe { GpioPin::<3>::steal() }, Level::High, Pull::Up);

ctx.delay.delay_millis(1);

assert_eq!(io2.is_high(), true);
assert_eq!(io4.is_high(), true);
assert_eq!(io3.is_high(), true);

io2.set_low();
io4.set_high();
io3.set_high();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_low(), true);
assert_eq!(io4.is_low(), true);
assert_eq!(io3.is_low(), true);

io2.set_high();
io4.set_high();
io3.set_high();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_high(), true);
assert_eq!(io4.is_high(), true);
assert_eq!(io3.is_high(), true);

io2.set_high();
io4.set_low();
io3.set_low();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_low(), true);
assert_eq!(io4.is_low(), true);
assert_eq!(io3.is_low(), true);

io2.set_high();
io4.set_high();
io3.set_high();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_high(), true);
assert_eq!(io4.is_high(), true);
assert_eq!(io3.is_high(), true);

io2.set_low();
io4.set_low();
io3.set_low();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_low(), true);
assert_eq!(io4.is_low(), true);
assert_eq!(io3.is_low(), true);
}

#[test]
fn test_gpio_flex(ctx: Context<'static>) {
let mut io2 = Flex::new(unsafe { GpioPin::<2>::steal() });
let mut io4 = Flex::new(unsafe { GpioPin::<4>::steal() });
let mut io3 = Flex::new(unsafe { GpioPin::<3>::steal() });

io2.set_high();
io2.set_as_output();
io4.set_as_input(Pull::None);
io3.set_as_input(Pull::None);

ctx.delay.delay_millis(1);

assert_eq!(io2.is_set_high(), true);
assert_eq!(io4.is_high(), true);
assert_eq!(io3.is_high(), true);

io2.set_low();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_set_high(), false);
assert_eq!(io4.is_high(), false);
assert_eq!(io3.is_high(), false);

io2.set_as_input(Pull::None);
io4.set_as_output();
io3.set_as_output();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_high(), false);
assert_eq!(io4.is_set_high(), false);
assert_eq!(io3.is_set_high(), false);

io4.set_high();
io3.set_high();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_high(), true);
assert_eq!(io4.is_set_high(), true);
assert_eq!(io3.is_set_high(), true);

io4.set_low();
io3.set_low();
ctx.delay.delay_millis(1);

assert_eq!(io2.is_low(), true);
assert_eq!(io4.is_set_low(), true);
assert_eq!(io3.is_set_low(), true);
}
}
4 changes: 2 additions & 2 deletions hil-test/tests/i2s.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! I2S Loopback Test
//!
//! It's assumed GPIO2 is connected to GPIO4
//! It's assumed GPIO2 is connected to GPIO3
//!
//! This test uses I2S TX to transmit known data to I2S RX (forced to slave mode
//! with loopback mode enabled). It's using circular DMA mode
Expand Down Expand Up @@ -81,7 +81,7 @@ mod tests {
.i2s_rx
.with_bclk(io.pins.gpio0)
.with_ws(io.pins.gpio1)
.with_din(io.pins.gpio4)
.with_din(io.pins.gpio3)
.build();

// enable loopback testing
Expand Down
8 changes: 4 additions & 4 deletions hil-test/tests/rmt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! RMT Loopback Test
//!
//! It's assumed GPIO2 is connected to GPIO4
//! It's assumed GPIO2 is connected to GPIO3

//% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3

Expand Down Expand Up @@ -65,17 +65,17 @@ mod tests {
if #[cfg(any(feature = "esp32", feature = "esp32s2"))] {
let rx_channel = {
use esp_hal::rmt::RxChannelCreator;
rmt.channel1.configure(io.pins.gpio4, rx_config).unwrap()
rmt.channel1.configure(io.pins.gpio3, rx_config).unwrap()
};
} else if #[cfg(feature = "esp32s3")] {
let rx_channel = {
use esp_hal::rmt::RxChannelCreator;
rmt.channel7.configure(io.pins.gpio4, rx_config).unwrap()
rmt.channel7.configure(io.pins.gpio3, rx_config).unwrap()
};
} else {
let rx_channel = {
use esp_hal::rmt::RxChannelCreator;
rmt.channel2.configure(io.pins.gpio4, rx_config).unwrap()
rmt.channel2.configure(io.pins.gpio3, rx_config).unwrap()
};
}
}
Expand Down
Loading
Loading