|
| 1 | +name: Compressed images - test with simulator target |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ 'master', 'main', 'release/**' ] |
| 6 | + pull_request: |
| 7 | + branches: [ '*' ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + compressed_update_simulator_tests: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + container: |
| 13 | + image: ghcr.io/wolfssl/wolfboot-ci-sim:v1.0 |
| 14 | + timeout-minutes: 20 |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + # The sink decoder is a separate output path in src/gzip.c, and |
| 19 | + # GZIP_SMALL selects a different Huffman decoder behind it, so both |
| 20 | + # have to be exercised and not merely built. The window sizes the |
| 21 | + # decoder's buffer and bounds back-references, so the smallest and |
| 22 | + # the default are both run. |
| 23 | + sign: [ ED25519, ECC256 ] |
| 24 | + window: [ 4096, 16384 ] |
| 25 | + # The container on internal flash is read in place; on external |
| 26 | + # flash it is pulled in through the read callback, which is a |
| 27 | + # different path through the decoder's input. |
| 28 | + config: [ sim-compressed-update, sim-compressed-update-ext, |
| 29 | + sim-compressed-update-ext-enc ] |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + submodules: true |
| 35 | + |
| 36 | + - name: Trust workspace |
| 37 | + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 38 | + |
| 39 | + - name: make clean |
| 40 | + run: | |
| 41 | + make distclean |
| 42 | +
|
| 43 | + - name: Install zlib headers |
| 44 | + run: | |
| 45 | + apt-get update && apt-get install -y zlib1g-dev |
| 46 | +
|
| 47 | + - name: Select config |
| 48 | + run: | |
| 49 | + cp config/examples/${{ matrix.config }}.config .config |
| 50 | + sed -i "s/^SIGN?=.*/SIGN?=${{ matrix.sign }}/" .config |
| 51 | + sed -i "s/^WOLFBOOT_COMPRESSED_WINDOW=.*//" .config |
| 52 | + echo "WOLFBOOT_COMPRESSED_WINDOW=${{ matrix.window }}" >> .config |
| 53 | +
|
| 54 | + - name: Build tools |
| 55 | + run: | |
| 56 | + make -C tools/keytools && make -C tools/bin-assemble |
| 57 | +
|
| 58 | + # Not a bare `make`: that also assembles internal_flash.dd with the |
| 59 | + # update partition inside it, which is wrong when the partition lives |
| 60 | + # on the external device. The test target below builds both images. |
| 61 | + - name: Build wolfboot.elf and test-app/image.elf |
| 62 | + run: | |
| 63 | + make clean && make wolfboot.elf test-app/image.elf |
| 64 | +
|
| 65 | + - name: Run the compressed update simulator test |
| 66 | + run: | |
| 67 | + ./tools/scripts/sim-compressed-update.sh |
| 68 | +
|
| 69 | + compressed_update_cross_build: |
| 70 | + runs-on: ubuntu-latest |
| 71 | + container: |
| 72 | + image: ghcr.io/wolfssl/wolfboot-ci-arm:v1.0 |
| 73 | + timeout-minutes: 20 |
| 74 | + strategy: |
| 75 | + fail-fast: false |
| 76 | + matrix: |
| 77 | + config: [ stm32h7-compressed-update, stm32f439zi-compressed-update ] |
| 78 | + |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + with: |
| 82 | + submodules: true |
| 83 | + |
| 84 | + - name: Trust workspace |
| 85 | + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 86 | + |
| 87 | + - name: Install zlib headers |
| 88 | + run: | |
| 89 | + apt-get update && apt-get install -y zlib1g-dev |
| 90 | +
|
| 91 | + - name: Select config |
| 92 | + run: | |
| 93 | + cp config/examples/${{ matrix.config }}.config .config |
| 94 | +
|
| 95 | + - name: Build |
| 96 | + run: | |
| 97 | + make clean && make keysclean && make |
| 98 | +
|
| 99 | + # The installer walks the boot partition a sector at a time and the |
| 100 | + # trailer lives in its last sector, so a partition that is not a whole |
| 101 | + # number of sectors would have its tail erased by the trailer write. |
| 102 | + - name: Check the partition geometry |
| 103 | + run: | |
| 104 | + BOOT=$(grep -E '^WOLFBOOT_PARTITION_SIZE\??=' .config | tail -1 | cut -d= -f2) |
| 105 | + UPD=$(grep -E '^WOLFBOOT_PARTITION_UPDATE_SIZE\??=' .config | tail -1 | cut -d= -f2) |
| 106 | + SEC=$(grep -E '^WOLFBOOT_SECTOR_SIZE\??=' .config | tail -1 | cut -d= -f2) |
| 107 | + echo "boot $BOOT, update $UPD, sector $SEC" |
| 108 | + [ $(($BOOT % $SEC)) -eq 0 ] || { echo "boot not sector aligned"; exit 1; } |
| 109 | + [ $(($UPD % $SEC)) -eq 0 ] || { echo "update not sector aligned"; exit 1; } |
| 110 | + # The point of the mode: the update partition is the smaller one. |
| 111 | + [ $(($UPD)) -lt $(($BOOT)) ] || { echo "update is not smaller than boot"; exit 1; } |
| 112 | + echo "ok: update is $(( 100 * $UPD / $BOOT ))% of boot" |
| 113 | +
|
| 114 | + # The window knob has to reach the decoder's buffer, which is the RAM |
| 115 | + # the mode actually costs. |
| 116 | + - name: Check the decoder window buffer was sized from the config |
| 117 | + run: | |
| 118 | + WIN=$(grep -E '^WOLFBOOT_COMPRESSED_WINDOW\??=' .config | tail -1 | cut -d= -f2) |
| 119 | + SZ=$(arm-none-eabi-nm -S wolfboot.elf | awk '$4=="compressed_window" {print $2}') |
| 120 | + [ -n "$SZ" ] || { echo "compressed_window not linked in"; exit 1; } |
| 121 | + WANT=$((2 * $WIN)) |
| 122 | + [ $((0x$SZ)) -eq $WANT ] || \ |
| 123 | + { echo "compressed_window is $((0x$SZ)) bytes, expected $WANT"; exit 1; } |
| 124 | + echo "ok: compressed_window is $((0x$SZ)) bytes for a $WIN window" |
| 125 | +
|
| 126 | + # Signing has to refuse a container the update partition cannot hold, |
| 127 | + # so a release that compresses worse than the split fails here rather |
| 128 | + # than on the device. |
| 129 | + - name: Check a container is produced and fits |
| 130 | + run: | |
| 131 | + UPD=$(grep -E '^WOLFBOOT_PARTITION_UPDATE_SIZE\??=' .config | tail -1 | cut -d= -f2) |
| 132 | + SEC=$(grep -E '^WOLFBOOT_SECTOR_SIZE\??=' .config | tail -1 | cut -d= -f2) |
| 133 | + SIGN=$(grep -E '^SIGN\??=' .config | tail -1 | cut -d= -f2 | tr 'A-Z' 'a-z') |
| 134 | + HASH=$(grep -E '^HASH\??=' .config | tail -1 | cut -d= -f2 | tr 'A-Z' 'a-z') |
| 135 | + WIN=$(grep -E '^WOLFBOOT_COMPRESSED_WINDOW\??=' .config | tail -1 | cut -d= -f2) |
| 136 | + WOLFBOOT_PARTITION_SIZE=$(grep -E '^WOLFBOOT_PARTITION_SIZE\??=' .config | tail -1 | cut -d= -f2) \ |
| 137 | + WOLFBOOT_PARTITION_UPDATE_SIZE=$UPD WOLFBOOT_SECTOR_SIZE=$SEC \ |
| 138 | + WOLFBOOT_COMPRESSED_WINDOW=$WIN \ |
| 139 | + ./tools/keytools/sign --compress --$SIGN --$HASH \ |
| 140 | + test-app/image.elf wolfboot_signing_private_key.der 2 |
| 141 | + SZ=$(stat -c%s test-app/image_v2_signed_compressed.bin) |
| 142 | + LIMIT=$(( $(($UPD)) - $(($SEC)) )) |
| 143 | + echo "container $SZ bytes, limit $LIMIT" |
| 144 | + [ "$SZ" -le "$LIMIT" ] || { echo "container does not fit"; exit 1; } |
| 145 | + echo "ok: container fits the update partition" |
0 commit comments