Improve HIL #441
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: HIL | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
merge_group: | |
workflow_dispatch: | |
inputs: | |
repository: | |
description: "Owner and repository to test" | |
required: true | |
default: "esp-rs/espflash" | |
branch: | |
description: "Branch, tag or SHA to checkout." | |
required: true | |
default: "main" | |
env: | |
CARGO_TERM_COLOR: always | |
# Cancel any currently running workflows from the same PR, branch, or | |
# tag when a new workflow is triggered. | |
# | |
# https://stackoverflow.com/a/66336834 | |
concurrency: | |
cancel-in-progress: true | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
jobs: | |
build-espflash: | |
name: Build espflash | |
runs-on: ubuntu-20.04 | |
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: ./.github/actions/setup-target | |
with: | |
arch: x86_64 | |
target: x86_64-unknown-linux-gnu | |
- name: Build espflash | |
run: cargo build --release | |
working-directory: espflash | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: espflash | |
path: target/release/espflash | |
if-no-files-found: error | |
run-target: | |
name: ${{ matrix.board.mcu }}${{ matrix.board.freq }} | |
if: ${{ github.repository_owner == 'esp-rs' }} | |
needs: build-espflash | |
runs-on: | |
[ | |
self-hosted, | |
linux, | |
x64, | |
"${{ matrix.board.mcu }}${{ matrix.board.freq }}", | |
] | |
strategy: | |
matrix: | |
board: | |
- mcu: esp32 | |
- mcu: esp32c2 | |
freq: -26mhz | |
flag: -x 26mhz | |
- mcu: esp32c3 | |
- mcu: esp32c6 | |
- mcu: esp32h2 | |
- mcu: esp32s2 | |
- mcu: esp32s3 | |
fail-fast: false | |
env: | |
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} | |
ESPFLASH_APP: espflash/tests/data/${{ matrix.board.mcu }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: espflash | |
path: espflash_app | |
- run: | | |
chmod +x espflash_app/espflash | |
export PATH="$PWD/espflash_app:$PATH" | |
echo "$PATH" >> "$GITHUB_PATH" | |
- name: board-info test | |
shell: bash | |
run: | | |
result=$(espflash board-info) | |
echo "$result" | |
if [[ $? -ne 0 || ! "$result" =~ "esp32" ]]; then | |
exit 1 | |
fi | |
- name: flash test | |
shell: bash | |
run: | | |
result=$(espflash flash --no-skip ${{ env.ESPFLASH_APP }} 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "Flashing has completed!" ]]; then | |
exit 1 | |
fi | |
- name: monitor test | |
shell: bash | |
run: | | |
result=$(timeout 5s espflash monitor --non-interactive || true) | |
echo "$result" | |
if ! echo "$result" | grep -q "Hello world!"; then | |
exit 1 | |
fi | |
- name: erase-flash test | |
run: | | |
bash espflash/tests/scripts/erase-flash.sh | |
- name: save-image/write-bin test | |
run: | | |
result=$(espflash save-image --merge --chip ${{ matrix.board.mcu }} ${{ matrix.board.flag }} ${{ env.ESPFLASH_APP }} app.bin 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "Image successfully saved!" ]]; then | |
exit 1 | |
fi | |
echo "Writting binary" | |
result=$(espflash write-bin 0x0 app.bin 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "Binary successfully written to flash!" ]]; then | |
exit 1 | |
fi | |
echo "Monitoring..." | |
result=$(timeout 5s espflash monitor --non-interactive || true) | |
echo "$result" | |
if ! echo "$result" | grep -q "Hello world!"; then | |
exit 1 | |
fi | |
- name: erase-region test | |
run: | | |
result=$(espflash erase-region 0x1000 0x1000 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "Erasing region at" ]]; then | |
exit 1 | |
fi | |
result=$(espflash read-flash 0x1000 0x2000 flash_content.bin 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "Flash content successfully read and written to" ]]; then | |
exit 1 | |
fi | |
# Check first 0x1000 bytes are FF | |
if head -c 4096 flash_content.bin | hexdump -v -e '/1 "%02x"' | grep -qv '^ff*$'; then | |
echo "First 0x1000 bytes should be empty (FF)" | |
exit 1 | |
fi | |
# Check next 0x1000 bytes contain some non-FF bytes | |
if ! tail -c 4096 flash_content.bin | hexdump -v -e '/1 "%02x"' | grep -q '[0-e]'; then | |
echo "Next 0x1000 bytes should contain some non-FF bytes" | |
exit 1 | |
fi | |
echo "Flash contents verified!" | |
- name: hold-in-reset test | |
run: | | |
result=$(espflash hold-in-reset 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "Holding target device in reset" ]]; then | |
exit 1 | |
fi | |
- name: reset test | |
run: | | |
result=$(espflash reset 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "Resetting target device" ]]; then | |
exit 1 | |
fi | |
- name: checksum-md5 test | |
run: | | |
result=$(espflash erase-flash 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "Flash has been erased!" ]]; then | |
exit 1 | |
fi | |
result=$(espflash checksum-md5 --address 0x1000 --length 0x100 2>&1) | |
echo "$result" | |
if [[ ! $result =~ "0x827f263ef9fb63d05499d14fcef32f60" ]]; then | |
exit 1 | |
fi |