ESPSomfy-RTS/.github/workflows/build.yaml
cjkas dfb003d2f7 build: add the ESP32-P4 (#29)
For boards such as Waveshare's ESP32-P4-WIFI6-POE-ETH: WiFi through the
board's ESP32-C6 on SDIO (esp-hosted), Ethernet on the P4's RMII MAC with
an IP101.  Not tested on a device: no P4 board was at hand.

- platformio.ini: env esp32p4 (esp32-p4_r3, chip v3.01+) and esp32p4es
  (esp32-p4, the esp32p4_es libraries, chips before v2.0).  An image runs
  on one of the two only, so each has its own release files, chip models
  "p4" and "p4es".  Both keep the OTA slot: at level 2 they leave about
  128 KB of it.
- Ethernet clock mode: stored as eth_clock_id_t in the ESP32's numbering
  and translated by name, like the PHY id.  The P4's eth_clock_mode_t is
  the IDF's emac_rmii_clock_mode_t, whose 0 is a deprecated default; only
  clock in (GPIO 50) translates there.
- P4 Ethernet defaults: the Waveshare wiring (IP101 as TLK110, address 1,
  MDC 31, MDIO 52, reset 51), board type 8.  The ESP32's put MDIO on an
  SDIO pin.
- Settings take pins up to GPIO 54, the P4's last, instead of 48.
- Radio defaults: SPI 32/33/27, CSN 46 (the framework's Waveshare
  variant), TX 2, RX 3.
- Web UI: a Waveshare ESP32-P4-ETH preset, the P4's clock mode, pin lists
  up to GPIO 54 without the pins the C6 link, Ethernet, USB and UART0 use.
- CI builds and releases both, with their ELFs; bootloader at 0x2000.
- ADR 0003: amended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 19:41:39 +01:00

264 lines
9.6 KiB
YAML

name: ESPSomfy-RTS Build
on:
push:
branches: [main]
pull_request:
release:
types: [published]
jobs:
test:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
# pioarduino's fork of PlatformIO Core, which the pioarduino platform needs.
# Pinned: 6.2.0.post1 reports itself as 6.2.0-post.1, which the
# platform's ">=6.2.0" reads as a pre-release and refuses.
- name: Install PlatformIO
run: pip install pioarduino==6.2.0
- name: Run native unit tests
run: pio test -e native
webui:
name: Web UI tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "22"
# The protocol 2 client (data-src/js) against the recorded fixtures.
- name: Run web UI tests
run: node --test "test/js/*.test.js"
build:
# Don't build or publish firmware that fails its tests.
needs: [test, webui]
permissions: write-all
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# fwname: firmware-only binary for OTA updates
# elfname: the symbols of that binary, to decode a crash's backtrace
# obname: onboard image (bootloader + partitions + firmware + littlefs merged)
# for flashing a new chip via USB/serial
# addr_bootloader: chip-dependent (ESP32: 0x1000, S3/C3/C6: 0x0, C5/P4: 0x2000)
# addr_fs: must match the spiffs offset in the env's partition table
# (0x310000 in both esp32_3MB.csv and esp32_huge_app.csv)
include:
- env: esp32dev
name: ESP32
chip: ESP32
addr_bootloader: "0x1000"
addr_fs: "0x310000"
fwname: SomfyController.ino.esp32.bin
elfname: SomfyController.ino.esp32.elf
fsname: SomfyController.littlefs.esp32.bin
obname: SomfyController.onboard.esp32.bin
- env: esp32s3
name: ESP32-S3
chip: ESP32-S3
addr_bootloader: "0x0"
addr_fs: "0x670000"
fwname: SomfyController.ino.esp32s3.bin
elfname: SomfyController.ino.esp32s3.elf
fsname: SomfyController.littlefs.esp32s3.bin
obname: SomfyController.onboard.esp32s3.bin
- env: esp32c3
name: ESP32-C3
chip: ESP32-C3
addr_bootloader: "0x0"
addr_fs: "0x310000"
fwname: SomfyController.ino.esp32c3.bin
elfname: SomfyController.ino.esp32c3.elf
fsname: SomfyController.littlefs.esp32c3.bin
obname: SomfyController.onboard.esp32c3.bin
- env: esp32c5
name: ESP32-C5
chip: ESP32-C5
addr_bootloader: "0x2000"
addr_fs: "0x310000"
fwname: SomfyController.ino.esp32c5.bin
elfname: SomfyController.ino.esp32c5.elf
fsname: SomfyController.littlefs.esp32c5.bin
obname: SomfyController.onboard.esp32c5.bin
- env: esp32c6
name: ESP32-C6
chip: ESP32-C6
addr_bootloader: "0x0"
addr_fs: "0x310000"
fwname: SomfyController.ino.esp32c6.bin
elfname: SomfyController.ino.esp32c6.elf
fsname: SomfyController.littlefs.esp32c6.bin
obname: SomfyController.onboard.esp32c6.bin
- env: esp32p4
name: ESP32-P4
chip: ESP32-P4
addr_bootloader: "0x2000"
addr_fs: "0x310000"
fwname: SomfyController.ino.esp32p4.bin
elfname: SomfyController.ino.esp32p4.elf
fsname: SomfyController.littlefs.esp32p4.bin
obname: SomfyController.onboard.esp32p4.bin
- env: esp32p4es
name: ESP32-P4 (before v3.0)
chip: ESP32-P4
addr_bootloader: "0x2000"
addr_fs: "0x310000"
fwname: SomfyController.ino.esp32p4es.bin
elfname: SomfyController.ino.esp32p4es.elf
fsname: SomfyController.littlefs.esp32p4es.bin
obname: SomfyController.onboard.esp32p4es.bin
steps:
- name: Get Release
if: github.event_name == 'release'
id: get_release
uses: bruceadams/get-release@v1.3.2
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Check out code
uses: actions/checkout@v4
- name: Update version from release tag
if: github.event_name == 'release'
run: |
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
sed -i "s/#define FW_VERSION \"v[0-9.]*\"/#define FW_VERSION \"v${VERSION}\"/" src/ConfigSettings.h
sed -i "s/^[0-9.].*/${VERSION}/" data-src/appversion
sed -i "s/\?v=[0-9.]*c/?v=${VERSION}c/g" data-src/index.html
sed -i "s/appVersion = 'v[0-9.]*'/appVersion = 'v${VERSION}'/" data-src/index.js
- name: Commit version update
if: github.event_name == 'release' && matrix.env == 'esp32dev'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src/ConfigSettings.h data-src/appversion data-src/index.html data-src/index.js
git commit -m "chore: bump version to ${{ github.event.release.tag_name }}"
git push origin HEAD:${{ github.event.release.target_commitish }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install PlatformIO and esptool
run: pip install pioarduino==6.2.0 esptool
- name: Build LittleFS image
run: pio run -e ${{ matrix.env }} -t buildfs
- name: Save LittleFS image
run: cp .pio/build/${{ matrix.env }}/littlefs.bin littlefs.bin
- name: Build firmware
run: pio run -e ${{ matrix.env }}
- name: Check firmware size
run: python .github/size_check.py .pio/build/${{ matrix.env }} ${{ matrix.env }} 8
- name: Restore LittleFS image
run: cp littlefs.bin .pio/build/${{ matrix.env }}/littlefs.bin
- name: List build artifacts
run: find .pio/build/${{ matrix.env }} -maxdepth 1 -name "*.bin" | sort
- name: Create onboard image
run: |
python -m esptool --chip ${{ matrix.chip }} \
merge-bin -o ${{ matrix.obname }} \
${{ matrix.addr_bootloader }} .pio/build/${{ matrix.env }}/bootloader.bin \
0x8000 .pio/build/${{ matrix.env }}/partitions.bin \
0x10000 .pio/build/${{ matrix.env }}/firmware.bin \
${{ matrix.addr_fs }} .pio/build/${{ matrix.env }}/littlefs.bin
- name: Compress onboard image
run: zip ${{ matrix.obname }}.zip ${{ matrix.obname }}
# A panic prints "ELF file SHA256: <first hex digits>". The .sha256 file
# beside the ELF holds the whole hash, so a crash log shows which build
# it came from.
- name: Compress ELF
run: |
cp .pio/build/${{ matrix.env }}/firmware.elf ${{ matrix.elfname }}
sha256sum ${{ matrix.elfname }} > ${{ matrix.elfname }}.sha256
cat ${{ matrix.elfname }}.sha256
zip -9 ${{ matrix.elfname }}.zip ${{ matrix.elfname }} ${{ matrix.elfname }}.sha256
- name: Upload artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: |
.pio/build/${{ matrix.env }}/firmware.bin
.pio/build/${{ matrix.env }}/firmware.elf
.pio/build/${{ matrix.env }}/partitions.bin
.pio/build/${{ matrix.env }}/bootloader.bin
.pio/build/${{ matrix.env }}/littlefs.bin
${{ matrix.obname }}.zip
retention-days: 5
- name: Upload LittleFS
if: github.event_name == 'release'
uses: shogo82148/actions-upload-release-asset@v1.7.5
with:
github_token: ${{ github.token }}
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_name: ${{ matrix.fsname }}
asset_path: .pio/build/${{ matrix.env }}/littlefs.bin
overwrite: true
- name: Upload firmware
if: github.event_name == 'release'
uses: shogo82148/actions-upload-release-asset@v1.7.5
with:
github_token: ${{ github.token }}
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_name: ${{ matrix.fwname }}
asset_path: .pio/build/${{ matrix.env }}/firmware.bin
overwrite: true
- name: Upload onboard image
if: github.event_name == 'release'
uses: shogo82148/actions-upload-release-asset@v1.7.5
with:
github_token: ${{ github.token }}
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_name: ${{ matrix.obname }}.zip
asset_path: ${{ matrix.obname }}.zip
overwrite: true
asset_content_type: application/zip
- name: Upload ELF
if: github.event_name == 'release'
uses: shogo82148/actions-upload-release-asset@v1.7.5
with:
github_token: ${{ github.token }}
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_name: ${{ matrix.elfname }}.zip
asset_path: ${{ matrix.elfname }}.zip
overwrite: true
asset_content_type: application/zip