Skip to content

Commit

Permalink
ci: Use bash scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioGasquez committed Feb 7, 2025
1 parent c6b82b1 commit 45297fd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 28 deletions.
46 changes: 18 additions & 28 deletions .github/workflows/hil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ jobs:
name: espflash
path: espflash_app

- run: chmod +x espflash_app/espflash
- 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_app/espflash board-info)
result=$(espflash board-info)
echo "$result"
if [[ $? -ne 0 || ! "$result" =~ "esp32" ]]; then
exit 1
Expand All @@ -103,7 +107,7 @@ jobs:
- name: flash test
shell: bash
run: |
result=$(espflash_app/espflash flash --no-skip ${{ env.ESPFLASH_APP }} 2>&1)
result=$(espflash flash --no-skip ${{ env.ESPFLASH_APP }} 2>&1)
echo "$result"
if [[ ! $result =~ "Flashing has completed!" ]]; then
exit 1
Expand All @@ -112,58 +116,44 @@ jobs:
- name: monitor test
shell: bash
run: |
result=$(timeout 5s espflash_app/espflash monitor --non-interactive || true)
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: |
result=$(espflash_app/espflash erase-flash 2>&1)
echo "$result"
if [[ ! $result =~ "Flash has been erased!" ]]; then
exit 1
fi
result=$(espflash_app/espflash read-flash 0 0x200 flash_content.bin 2>&1)
echo "$result"
if [[ ! $result =~ "Flash content successfully read and written to" ]]; then
exit 1
fi
echo "Checking if flash is empty"
if hexdump -v -e '/1 "%02x"' "flash_content.bin" | grep -qv '^ff*$'; then
exit 1
fi
echo "Flash is empty!"
bash espflash/tests/scripts/erase-flash.sh
- name: save-image/write-bin test
run: |
result=$(espflash_app/espflash save-image --merge --chip ${{ matrix.board.mcu }} ${{ matrix.board.flag }} ${{ env.ESPFLASH_APP }} app.bin 2>&1)
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_app/espflash write-bin 0x0 app.bin 2>&1)
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_app/espflash monitor --non-interactive || true)
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_app/espflash erase-region 0x1000 0x1000 2>&1)
result=$(espflash erase-region 0x1000 0x1000 2>&1)
echo "$result"
if [[ ! $result =~ "Erasing region at" ]]; then
exit 1
fi
result=$(espflash_app/espflash read-flash 0x1000 0x2000 flash_content.bin 2>&1)
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
Expand All @@ -182,28 +172,28 @@ jobs:
- name: hold-in-reset test
run: |
result=$(espflash_app/espflash hold-in-reset 2>&1)
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_app/espflash reset 2>&1)
result=$(espflash reset 2>&1)
echo "$result"
if [[ ! $result =~ "Resetting target device" ]]; then
exit 1
fi
- name: checksum-md5 test
run: |
result=$(espflash_app/espflash erase-flash 2>&1)
result=$(espflash erase-flash 2>&1)
echo "$result"
if [[ ! $result =~ "Flash has been erased!" ]]; then
exit 1
fi
result=$(espflash_app/espflash checksum-md5 --address 0x1000 --length 0x100 2>&1)
result=$(espflash checksum-md5 --address 0x1000 --length 0x100 2>&1)
echo "$result"
if [[ ! $result =~ "0x827f263ef9fb63d05499d14fcef32f60" ]]; then
exit 1
Expand Down
23 changes: 23 additions & 0 deletions espflash/tests/scripts/erase-flash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

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!"

0 comments on commit 45297fd

Please sign in to comment.