|
| 1 | +name: HIL |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths-ignore: |
| 8 | + - "**/ci.yml" |
| 9 | + - "**/*.md" |
| 10 | + push: |
| 11 | + paths-ignore: |
| 12 | + - "**/ci.yml" |
| 13 | + - "**/*.md" |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +env: |
| 17 | + CARGO_TERM_COLOR: always |
| 18 | + |
| 19 | +# Cancel any currently running workflows from the same PR, branch, or |
| 20 | +# tag when a new workflow is triggered. |
| 21 | +# |
| 22 | +# https://stackoverflow.com/a/66336834 |
| 23 | +concurrency: |
| 24 | + cancel-in-progress: true |
| 25 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 26 | + |
| 27 | + |
| 28 | +jobs: |
| 29 | + build-espflash: |
| 30 | + name: Build espflash |
| 31 | + runs-on: ubuntu-20.04 |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - uses: ./.github/actions/setup-target |
| 36 | + with: |
| 37 | + arch: x86_64 |
| 38 | + target: x86_64-unknown-linux-gnu |
| 39 | + |
| 40 | + - name: Build espflash |
| 41 | + run: cargo build --release |
| 42 | + working-directory: espflash |
| 43 | + |
| 44 | + - uses: actions/upload-artifact@v3 |
| 45 | + with: |
| 46 | + name: espflash |
| 47 | + path: target/release/espflash |
| 48 | + if-no-files-found: error |
| 49 | + |
| 50 | + run-target: |
| 51 | + name: ${{ matrix.board.mcu }}${{ matrix.board.freq }} |
| 52 | + if: ${{ github.repository_owner == 'esp-rs' }} |
| 53 | + needs: build-espflash |
| 54 | + runs-on: [self-hosted, linux, x64, "${{ matrix.board.mcu }}${{ matrix.board.freq }}" ] |
| 55 | + strategy: |
| 56 | + matrix: |
| 57 | + board: |
| 58 | + - mcu: esp32 |
| 59 | + - mcu: esp32c2 |
| 60 | + freq: -26mhz |
| 61 | + flag: -x 26mhz |
| 62 | + - mcu: esp32c3 |
| 63 | + - mcu: esp32c6 |
| 64 | + - mcu: esp32h2 |
| 65 | + - mcu: esp32s2 |
| 66 | + - mcu: esp32s3 |
| 67 | + fail-fast: false |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + - uses: actions/download-artifact@v3 |
| 71 | + with: |
| 72 | + name: espflash |
| 73 | + path: espflash_app |
| 74 | + |
| 75 | + - run: chmod +x espflash_app/espflash |
| 76 | + |
| 77 | + - name: board-info test |
| 78 | + env: |
| 79 | + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + result=$(espflash_app/espflash board-info) |
| 83 | + echo "$result" |
| 84 | + if [[ $? -ne 0 || ! "$result" =~ "esp32" ]]; then |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | +
|
| 88 | + - name: flash test |
| 89 | + env: |
| 90 | + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} |
| 91 | + ESPFLASH_APP: espflash/resources/apps/${{ matrix.board.mcu }} |
| 92 | + shell: bash |
| 93 | + run: | |
| 94 | + result=$(espflash_app/espflash flash ${{ env.ESPFLASH_APP }} 2>&1) |
| 95 | + echo "$result" |
| 96 | + if [[ ! $result =~ "Flashing has completed!" ]]; then |
| 97 | + exit 1 |
| 98 | + fi |
| 99 | +
|
| 100 | + - name: monitor test |
| 101 | + env: |
| 102 | + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} |
| 103 | + shell: bash |
| 104 | + run: | |
| 105 | + result=$(timeout 5s espflash_app/espflash monitor --non-interactive || true) |
| 106 | + echo "$result" |
| 107 | + if ! echo "$result" | grep -q "Hello world!"; then |
| 108 | + exit 1 |
| 109 | + fi |
| 110 | +
|
| 111 | + - name: erase/read flash test |
| 112 | + env: |
| 113 | + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} |
| 114 | + run: | |
| 115 | + result=$(espflash_app/espflash erase-flash 2>&1) |
| 116 | + echo "$result" |
| 117 | + if [[ ! $result =~ "Flash has been erased!" ]]; then |
| 118 | + exit 1 |
| 119 | + fi |
| 120 | + result=$(espflash_app/espflash read-flash 0 0x200 flash_content.bin 2>&1) |
| 121 | + echo "$result" |
| 122 | + if [[ ! $result =~ "Flash content successfully read and written to" ]]; then |
| 123 | + exit 1 |
| 124 | + fi |
| 125 | + echo "Checking if flash is empty" |
| 126 | + if hexdump -v -e '/1 "%02x"' "flash_content.bin" | grep -qv '^ff*$'; then |
| 127 | + exit 1 |
| 128 | + fi |
| 129 | + echo "Flash is empty!" |
| 130 | +
|
| 131 | + - name: save-image/write-bin test |
| 132 | + env: |
| 133 | + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} |
| 134 | + ESPFLASH_APP: espflash/resources/apps/${{ matrix.board.mcu }} |
| 135 | + run: | |
| 136 | + result=$(espflash_app/espflash save-image --merge --chip ${{ matrix.board.mcu }} ${{ matrix.board.flag }} ${{ env.ESPFLASH_APP }} app.bin 2>&1) |
| 137 | + echo "$result" |
| 138 | + if [[ ! $result =~ "Image successfully saved!" ]]; then |
| 139 | + exit 1 |
| 140 | + fi |
| 141 | + echo "Writting binary" |
| 142 | + result=$(espflash_app/espflash write-bin 0x0 app.bin 2>&1) |
| 143 | + echo "$result" |
| 144 | + if [[ ! $result =~ "Binary successfully written to flash!" ]]; then |
| 145 | + exit 1 |
| 146 | + fi |
| 147 | + echo "Monitoring..." |
| 148 | + result=$(timeout 5s espflash_app/espflash monitor --non-interactive || true) |
| 149 | + echo "$result" |
| 150 | + if ! echo "$result" | grep -q "Hello world!"; then |
| 151 | + exit 1 |
| 152 | + fi |
| 153 | +
|
| 154 | +
|
0 commit comments