Skip to content

Commit 17daa46

Browse files
authored
Enable ESP32 HIL (#1977)
* Enable ESP32 HIL * RMT fixed * SPI DMA partially works, _pcnt tests not working * bckup * finish * readme and cleanup * rebase + cleanup * RMT S2 pin typo + clean forgotten comments * review comments * update 10000 * indentation * replace cfg gate with cfg_if
1 parent fba475e commit 17daa46

23 files changed

+108
-59
lines changed

.github/workflows/hil.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ jobs:
8686
- soc: esp32h2
8787
rust-target: riscv32imac-unknown-none-elf
8888
# # Xtensa devices:
89+
- soc: esp32
90+
rust-target: xtensa-esp32-none-elf
8991
- soc: esp32s2
9092
rust-target: xtensa-esp32s2-none-elf
9193
- soc: esp32s3
@@ -168,6 +170,10 @@ jobs:
168170
host: armv7
169171
hubs: "1-1"
170172
# Xtensa devices:
173+
- soc: esp32
174+
runner: esp32-jtag
175+
host: aarch64
176+
hubs: "1 3"
171177
- soc: esp32s2
172178
runner: esp32s2-jtag
173179
host: armv7

hil-test/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,17 @@ Our self-hosted runners have the following setup:
103103
- `GPIO9` and `GPIO10` are connected.
104104
- `GPIO43 (TX)` and `GPIO45` are connected.
105105
- RPi: Raspbian 12 configured with the following [setup]
106+
- ESP32 (`esp32-jtag`):
107+
- Devkit: `ESP32-DevKitC-V4` connected via UART.
108+
- `GPIO32` and `GPIO33` are I2C pins.
109+
- `GPIO4` and `GPIO5` are connected.
110+
- `GPIO26` and `GPIO27` are connected.
111+
- Probe: `ESP-Prog` connected with the [following connections][connection_esp32]
112+
- RPi: Raspbian 12 configured with the following [setup]
106113

107114
[connection_c2]: https://docs.espressif.com/projects/esp-idf/en/stable/esp32c2/api-guides/jtag-debugging/configure-other-jtag.html#configure-hardware
108115
[connection_s2]: https://docs.espressif.com/projects/esp-idf/en/stable/esp32s2/api-guides/jtag-debugging/configure-other-jtag.html#configure-hardware
116+
[connection_esp32]: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/jtag-debugging/configure-other-jtag.html#configure-hardware.html#configure-hardware
109117
[`hil.yml`]: https://github.com/esp-rs/esp-hal/blob/main/.github/workflows/hil.yml
110118
[setup]: #rpi-setup
111119

hil-test/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ macro_rules! i2c_pins {
3030
cfg_if::cfg_if! {
3131
if #[cfg(any(esp32s2, esp32s3))] {
3232
($io.pins.gpio2, $io.pins.gpio3)
33+
} else if #[cfg(esp32)] {
34+
($io.pins.gpio32, $io.pins.gpio33)
3335
} else if #[cfg(esp32c6)] {
3436
($io.pins.gpio6, $io.pins.gpio7)
3537
} else if #[cfg(esp32h2)] {
@@ -49,7 +51,11 @@ macro_rules! common_test_pins {
4951
cfg_if::cfg_if! {
5052
if #[cfg(any(esp32s2, esp32s3))] {
5153
($io.pins.gpio9, $io.pins.gpio10)
52-
} else {
54+
}
55+
else if #[cfg(esp32)] {
56+
($io.pins.gpio26, $io.pins.gpio27)
57+
}
58+
else {
5359
($io.pins.gpio2, $io.pins.gpio3)
5460
}
5561
}

hil-test/tests/embassy_timers_executors.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@
88
#![no_main]
99

1010
use embassy_time::{Duration, Ticker, Timer};
11-
use esp_hal::{
12-
interrupt::software::SoftwareInterruptControl,
13-
peripherals::Peripherals,
14-
prelude::*,
15-
timer::{timg::TimerGroup, ErasedTimer, OneShotTimer, PeriodicTimer},
16-
};
1711
#[cfg(not(feature = "esp32"))]
1812
use esp_hal::{
13+
interrupt::software::SoftwareInterruptControl,
1914
interrupt::Priority,
2015
timer::systimer::{Alarm, FrozenUnit, Periodic, SystemTimer, Target},
16+
timer::ErasedTimer,
17+
};
18+
use esp_hal::{
19+
peripherals::Peripherals,
20+
prelude::*,
21+
timer::{timg::TimerGroup, OneShotTimer, PeriodicTimer},
2122
};
2223
#[cfg(not(feature = "esp32"))]
2324
use esp_hal_embassy::InterruptExecutor;
2425
use hil_test as _;
2526

27+
#[cfg(not(feature = "esp32"))]
2628
macro_rules! mk_static {
2729
($t:ty,$val:expr) => {{
2830
static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
@@ -123,7 +125,9 @@ fn set_up_embassy_with_systimer(peripherals: Peripherals) {
123125
#[embedded_test::tests(executor = esp_hal_embassy::Executor::new())]
124126
mod test {
125127
use super::*;
126-
use crate::{test_cases::*, test_helpers::*};
128+
use crate::test_cases::*;
129+
#[cfg(not(feature = "esp32"))]
130+
use crate::test_helpers::*;
127131

128132
#[init]
129133
fn init() -> Peripherals {

hil-test/tests/gpio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! GPIO Test
22
//!
33
//! Folowing pins are used:
4-
//! GPIO2 / GPIO9 (esp32s2 and esp32s3)
5-
//! GPIO3 / GPIO10 (esp32s2 and esp32s3)
4+
//! GPIO2 / GPIO9 (esp32s2 / esp32s3) / GPIO26 (esp32)
5+
//! GPIO3 / GPIO10 (esp32s2 / esp32s3) / GPIO27 (esp32)
66
77
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
88
//% FEATURES: generic-queue

hil-test/tests/i2c.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
//! SDA GPIO2 (esp32s2 and esp32s3)
55
//! GPIO6 (esp32c6)
66
//! GPIO18 (esp32c2)
7-
//! GPIO4 (esp32, esp32h2 and esp32c3)
7+
//! GPIO4 (esp32h2 and esp32c3)
8+
//! GPIO32 (esp32)
89
//!
910
//! SCL GPIO3 (esp32s2 and esp32s3)
10-
//! GPIO7 (esp32c6, esp32 and esp32c3)
11+
//! GPIO7 (esp32c6 and esp32c3)
1112
//! GPIO22 (esp32h2)
1213
//! GPIO19 (esp32c2)
14+
//! GPIO33 (esp32)
1315
1416
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
1517

hil-test/tests/i2s_async.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![no_main]
1414

1515
use esp_hal::{
16-
dma::{Dma, DmaChannel0, DmaPriority},
16+
dma::{Dma, DmaPriority},
1717
gpio::Io,
1818
i2s::{asynch::*, DataFormat, I2s, I2sTx, Standard},
1919
peripheral::Peripheral,
@@ -23,6 +23,17 @@ use esp_hal::{
2323
};
2424
use hil_test as _;
2525

26+
cfg_if::cfg_if! {
27+
if #[cfg(any(
28+
feature = "esp32",
29+
feature = "esp32s2",
30+
))] {
31+
use esp_hal::dma::Spi2DmaChannel as DmaChannel0;
32+
} else {
33+
use esp_hal::dma::DmaChannel0;
34+
}
35+
}
36+
2637
const BUFFER_SIZE: usize = 2000;
2738

2839
#[derive(Clone)]
@@ -91,7 +102,14 @@ mod tests {
91102
let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
92103

93104
let dma = Dma::new(peripherals.DMA);
94-
let dma_channel = dma.channel0;
105+
106+
cfg_if::cfg_if! {
107+
if #[cfg(any(feature = "esp32", feature = "esp32s2"))] {
108+
let dma_channel = dma.spi2channel;
109+
} else {
110+
let dma_channel = dma.channel0;
111+
}
112+
}
95113

96114
let (tx_buffer, tx_descriptors, rx_buffer, rx_descriptors) =
97115
esp_hal::dma_circular_buffers!(BUFFER_SIZE, BUFFER_SIZE);

hil-test/tests/pcnt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//!
33
//! It's assumed GPIO2 is connected to GPIO3
44
//! (GPIO9 and GPIO10 for esp32s2 and esp32s3)
5+
//! (GPIO26 and GPIO27 for esp32)
56
67
//% CHIPS: esp32 esp32c6 esp32h2 esp32s2 esp32s3
78

hil-test/tests/qspi_read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//!
88
//! Connect MISO and GPIO pins.
99
10-
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
10+
//% CHIPS: esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
1111

1212
#![no_std]
1313
#![no_main]

hil-test/tests/qspi_write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//!
1010
//! Connect MOSI and PCNT pins.
1111
12-
//% CHIPS: esp32 esp32c6 esp32h2 esp32s2 esp32s3
12+
//% CHIPS: esp32c6 esp32h2 esp32s2 esp32s3
1313

1414
#![no_std]
1515
#![no_main]

0 commit comments

Comments
 (0)