Skip to content

Commit 6f3c96d

Browse files
Improve HIL (#754)
* ci: Use job.env to avoid duplications * ci: Add erase-region, hold-in-reset, reset and checksum-md5 tests * ci: Use bash scripts * cI: Update workflow * feat: Udpate testing elfs * test: Read 0x2000 bytes of flash * docs: Add TODOs for issue #697 * fix: Typo Co-authored-by: Jesse Braham <[email protected]> * docs: Improve the todo comment --------- Co-authored-by: Jesse Braham <[email protected]>
1 parent ad1cb9f commit 6f3c96d

File tree

18 files changed

+154
-83
lines changed

18 files changed

+154
-83
lines changed

.github/workflows/hil.yml

Lines changed: 32 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@ jobs:
3232
runs-on: ubuntu-20.04
3333
steps:
3434
- uses: actions/checkout@v4
35-
if: github.event_name != 'workflow_dispatch'
36-
37-
- uses: actions/checkout@v4
38-
if: github.event_name == 'workflow_dispatch'
3935
with:
40-
repository: ${{ github.event.inputs.repository }}
41-
ref: ${{ github.event.inputs.branch }}
36+
repository: ${{ github.event.inputs.repository || github.repository }}
37+
ref: ${{ github.event.inputs.branch || github.ref }}
4238

4339
- uses: ./.github/actions/setup-target
4440
with:
@@ -57,15 +53,9 @@ jobs:
5753

5854
run-target:
5955
name: ${{ matrix.board.mcu }}${{ matrix.board.freq }}
60-
if: ${{ github.repository_owner == 'esp-rs' }}
56+
if: github.repository_owner == 'esp-rs'
6157
needs: build-espflash
62-
runs-on:
63-
[
64-
self-hosted,
65-
linux,
66-
x64,
67-
"${{ matrix.board.mcu }}${{ matrix.board.freq }}",
68-
]
58+
runs-on: [self-hosted, linux, x64, "${{ matrix.board.mcu }}${{ matrix.board.freq }}"]
6959
strategy:
7060
matrix:
7161
board:
@@ -79,88 +69,47 @@ jobs:
7969
- mcu: esp32s2
8070
- mcu: esp32s3
8171
fail-fast: false
72+
env:
73+
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }}
74+
ESPFLASH_APP: espflash/tests/data/${{ matrix.board.mcu }}
8275
steps:
8376
- uses: actions/checkout@v4
77+
8478
- uses: actions/download-artifact@v4
8579
with:
8680
name: espflash
8781
path: espflash_app
8882

89-
- run: chmod +x espflash_app/espflash
83+
- name: Set up espflash binary
84+
run: |
85+
chmod +x espflash_app/espflash
86+
echo "$PWD/espflash_app" >> "$GITHUB_PATH"
9087
9188
- name: board-info test
92-
env:
93-
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }}
94-
shell: bash
95-
run: |
96-
result=$(espflash_app/espflash board-info)
97-
echo "$result"
98-
if [[ $? -ne 0 || ! "$result" =~ "esp32" ]]; then
99-
exit 1
100-
fi
89+
run: bash espflash/tests/scripts/board-info.sh
10190

10291
- name: flash test
103-
env:
104-
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }}
105-
ESPFLASH_APP: espflash/tests/data/${{ matrix.board.mcu }}
106-
shell: bash
107-
run: |
108-
result=$(espflash_app/espflash flash --no-skip ${{ env.ESPFLASH_APP }} 2>&1)
109-
echo "$result"
110-
if [[ ! $result =~ "Flashing has completed!" ]]; then
111-
exit 1
112-
fi
92+
run: bash espflash/tests/scripts/flash.sh ${{ env.ESPFLASH_APP }}
11393

11494
- name: monitor test
115-
env:
116-
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }}
117-
shell: bash
118-
run: |
119-
result=$(timeout 5s espflash_app/espflash monitor --non-interactive || true)
120-
echo "$result"
121-
if ! echo "$result" | grep -q "Hello world!"; then
122-
exit 1
123-
fi
124-
125-
- name: erase/read flash test
126-
env:
127-
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }}
128-
run: |
129-
result=$(espflash_app/espflash erase-flash 2>&1)
130-
echo "$result"
131-
if [[ ! $result =~ "Flash has been erased!" ]]; then
132-
exit 1
133-
fi
134-
result=$(espflash_app/espflash read-flash 0 0x200 flash_content.bin 2>&1)
135-
echo "$result"
136-
if [[ ! $result =~ "Flash content successfully read and written to" ]]; then
137-
exit 1
138-
fi
139-
echo "Checking if flash is empty"
140-
if hexdump -v -e '/1 "%02x"' "flash_content.bin" | grep -qv '^ff*$'; then
141-
exit 1
142-
fi
143-
echo "Flash is empty!"
95+
run: bash espflash/tests/scripts/monitor.sh
96+
97+
- name: erase-flash test
98+
run: bash espflash/tests/scripts/erase-flash.sh
14499

145100
- name: save-image/write-bin test
146-
env:
147-
ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }}
148-
ESPFLASH_APP: espflash/tests/data/${{ matrix.board.mcu }}
149101
run: |
150-
result=$(espflash_app/espflash save-image --merge --chip ${{ matrix.board.mcu }} ${{ matrix.board.flag }} ${{ env.ESPFLASH_APP }} app.bin 2>&1)
151-
echo "$result"
152-
if [[ ! $result =~ "Image successfully saved!" ]]; then
153-
exit 1
154-
fi
155-
echo "Writting binary"
156-
result=$(espflash_app/espflash write-bin 0x0 app.bin 2>&1)
157-
echo "$result"
158-
if [[ ! $result =~ "Binary successfully written to flash!" ]]; then
159-
exit 1
160-
fi
161-
echo "Monitoring..."
162-
result=$(timeout 5s espflash_app/espflash monitor --non-interactive || true)
163-
echo "$result"
164-
if ! echo "$result" | grep -q "Hello world!"; then
165-
exit 1
166-
fi
102+
bash espflash/tests/scripts/save-image_write-bin.sh ${{ matrix.board.mcu }} ${{ env.ESPFLASH_APP }}
103+
bash espflash/tests/scripts/monitor.sh
104+
105+
- name: erase-region test
106+
run: bash espflash/tests/scripts/erase-region.sh
107+
108+
- name: hold-in-reset test
109+
run: bash espflash/tests/scripts/hold-in-reset.sh
110+
111+
- name: reset test
112+
run: bash espflash/tests/scripts/reset.sh
113+
114+
- name: checksum-md5 test
115+
run: bash espflash/tests/scripts/checksum-md5.sh

espflash/tests/data/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The elf files under this folder have been generated using `[email protected]`:
2+
3+
```
4+
esp-generate --chip=$CHIP --headless $CHIP
5+
cd $CHIP
6+
cargo build --release
7+
```

espflash/tests/data/esp32

-1.06 MB
Binary file not shown.

espflash/tests/data/esp32c2

-2.38 MB
Binary file not shown.

espflash/tests/data/esp32c3

-2.66 MB
Binary file not shown.

espflash/tests/data/esp32c6

-2.98 MB
Binary file not shown.

espflash/tests/data/esp32h2

-2.89 MB
Binary file not shown.

espflash/tests/data/esp32s2

-1.09 MB
Binary file not shown.

espflash/tests/data/esp32s3

-1.27 MB
Binary file not shown.

espflash/tests/scripts/board-info.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
result=$(espflash board-info)
4+
echo "$result"
5+
if [[ $? -ne 0 || ! "$result" =~ "esp32" ]]; then
6+
exit 1
7+
fi

0 commit comments

Comments
 (0)