diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index fc797b40f88..eca905a4140 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -18,8 +18,48 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: + build-xtasks: + name: Build xtasks | ${{ matrix.host.arch }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + host: + - arch: armv7 + rust-target: armv7-unknown-linux-gnueabihf + - arch: aarch64 + rust-target: aarch64-unknown-linux-gnu + + steps: + - uses: actions/checkout@v4 + if: github.event_name != 'workflow_dispatch' + - uses: actions/checkout@v4 + if: github.event_name == 'workflow_dispatch' + with: + repository: ${{ github.event.inputs.repository }} + ref: ${{ github.event.inputs.branch }} + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + components: rust-src + + - name: Install cross + run: cargo install cross + + - name: Build xtasks + run: cross build --release --target ${{ matrix.host.rust-target }} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: xtask-${{ matrix.host.arch }} + path: target/${{ matrix.host.rust-target }}/release/xtask + build-tests: - name: HIL Test | ${{ matrix.target.soc }} + name: Build HIL Tests | ${{ matrix.target.soc }} runs-on: ubuntu-latest strategy: @@ -92,8 +132,8 @@ jobs: overwrite: true hil: - name: HIL Test | ${{ matrix.target.soc }} - needs: build-tests + name: Run HIL Tests | ${{ matrix.target.soc }} + needs: [build-tests, build-xtasks] runs-on: labels: [self-hosted, "${{ matrix.target.runner }}"] strategy: @@ -104,45 +144,41 @@ jobs: - soc: esp32c2 runner: esp32c2-jtag usb: USB2 + host: aarch64 - soc: esp32c3 runner: esp32c3-usb usb: ACM0 + host: armv7 - soc: esp32c6 runner: esp32c6-usb usb: ACM0 + host: armv7 - soc: esp32h2 runner: esp32h2-usb usb: USB0 + host: armv7 # Xtensa devices: - soc: esp32s2 runner: esp32s2-jtag usb: USB1 + host: armv7 - soc: esp32s3 runner: esp32s3-usb usb: USB0 + host: armv7 steps: - - uses: actions/checkout@v4 - if: github.event_name != 'workflow_dispatch' - - uses: actions/checkout@v4 - if: github.event_name == 'workflow_dispatch' - with: - repository: ${{ github.event.inputs.repository }} - ref: ${{ github.event.inputs.branch }} - - uses: actions/download-artifact@v4 with: name: tests-${{ matrix.target.soc }} path: tests-${{ matrix.target.soc }} + + - uses: actions/download-artifact@v4 + with: + name: xtask-${{ matrix.target.host }} + - name: Run Tests id: run-tests run: | export PATH=$PATH:/home/espressif/.cargo/bin - cargo xtask run-elfs ${{ matrix.target.soc }} tests-${{ matrix.target.soc }} - - - name: Erase Flash on Failure - if: ${{ failure() && steps.run-tests.conclusion == 'failure' }} - env: - ESPFLASH_PORT: /dev/tty${{ matrix.target.usb }} - run: | - export PATH=$PATH:/home/espressif/.cargo/bin - espflash erase-flash + chmod +x xtask + ./xtask run-elfs ${{ matrix.target.soc }} tests-${{ matrix.target.soc }} diff --git a/hil-test/README.md b/hil-test/README.md index 58a78ebd8b9..ec8bbc47437 100644 --- a/hil-test/README.md +++ b/hil-test/README.md @@ -21,7 +21,7 @@ We use [probe-rs] for flashing and running the tests on a target device, however ```text cargo install probe-rs-tools \ --git https://github.com/probe-rs/probe-rs \ - --rev bba1bb5 --force --locked + --rev 9bde591 --force --locked ``` Target device **MUST** connected via its USB-Serial-JTAG port, or if unavailable (eg. ESP32, ESP32-C2, ESP32-S2) then you must connect a compatible debug probe such as an [ESP-Prog]. @@ -108,7 +108,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-t # Install dependencies sudo apt install -y pkg-config libudev-dev # Install probe-rs -cargo install probe-rs-tools --git https://github.com/probe-rs/probe-rs --rev bba1bb5 --force +cargo install probe-rs-tools --git https://github.com/probe-rs/probe-rs --rev 9bde591 --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 diff --git a/hil-test/tests/get_time.rs b/hil-test/tests/get_time.rs index 2670ef80333..473d0859163 100644 --- a/hil-test/tests/get_time.rs +++ b/hil-test/tests/get_time.rs @@ -37,6 +37,7 @@ mod tests { } #[test] + #[timeout(3)] fn test_current_time(ctx: Context) { let t1 = esp_hal::time::current_time(); ctx.delay.delay_millis(500); diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 36ded6ce5b6..ee2ec036df1 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -6,7 +6,7 @@ use std::{ process::Command, }; -use anyhow::{bail, Result}; +use anyhow::{bail, Context, Result}; use cargo::CargoAction; use clap::ValueEnum; use esp_metadata::Chip; @@ -151,7 +151,8 @@ pub fn load_examples(path: &Path) -> Result> { for entry in fs::read_dir(path)? { let path = windows_safe_path(&entry?.path()); - let text = fs::read_to_string(&path)?; + let text = fs::read_to_string(&path) + .with_context(|| format!("Could not read {}", path.display()))?; let mut chips = Vec::new(); let mut features = Vec::new(); @@ -184,7 +185,7 @@ pub fn load_examples(path: &Path) -> Result> { } else if key == "FEATURES" { features = split.into(); } else { - log::warn!("Unregognized metadata key '{key}', ignoring"); + log::warn!("Unrecognized metadata key '{key}', ignoring"); } } @@ -240,8 +241,6 @@ pub fn execute_app( .features(&features) .arg(bin); - // probe-rs cannot currently do auto detection, so we need to tell probe-rs run - // which chip we are testing if subcommand == "test" && chip == Chip::Esp32c2 { builder = builder.arg("--").arg("--speed").arg("15000"); } @@ -311,7 +310,8 @@ pub fn build_package( /// Bump the version of the specified package by the specified amount. pub fn bump_version(workspace: &Path, package: Package, amount: Version) -> Result<()> { let manifest_path = workspace.join(package.to_string()).join("Cargo.toml"); - let manifest = fs::read_to_string(&manifest_path)?; + let manifest = fs::read_to_string(&manifest_path) + .with_context(|| format!("Could not read {}", manifest_path.display()))?; let mut manifest = manifest.parse::()?; @@ -530,7 +530,10 @@ pub fn package_version(workspace: &Path, package: Package) -> Result Result<()> { .filter_module("xtask", log::LevelFilter::Info) .init(); - let workspace = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let workspace = workspace.parent().unwrap().canonicalize()?; + let workspace = std::env::current_dir()?; match Cli::parse() { Cli::BuildDocumentation(args) => build_documentation(&workspace, args), @@ -676,24 +675,21 @@ fn run_elfs(args: RunElfArgs) -> Result<()> { log::info!("Running test '{}' for '{}'", elf_name, args.chip); - let command = if args.chip == Chip::Esp32c2 { - Command::new("probe-rs") - .arg("run") - .arg("--speed") - .arg("15000") - .arg(elf_path) - .output()? - } else { - Command::new("probe-rs").arg("run").arg(elf_path).output()? + let mut command = Command::new("probe-rs"); + command.arg("run").arg(elf_path); + + if args.chip == Chip::Esp32c2 { + command.arg("--speed").arg("15000"); }; - println!( - "{}\n{}", - String::from_utf8_lossy(&command.stderr), - String::from_utf8_lossy(&command.stdout) - ); + let mut command = command.spawn().context("Failed to execute probe-rs")?; + let status = command + .wait() + .context("Error while waiting for probe-rs to exit")?; + + log::info!("'{elf_name}' done"); - if !command.status.success() { + if !status.success() { failed.push(elf_name); } }