diff --git a/.github/size_check.py b/.github/size_check.py new file mode 100644 index 0000000..a10d402 --- /dev/null +++ b/.github/size_check.py @@ -0,0 +1,52 @@ +"""Fail the build when the firmware leaves too little room in its app slot. + +PlatformIO only fails once the firmware no longer fits. Releases are built at +CORE_DEBUG_LEVEL=2 because the ESP32 image barely fits its 1.5 MB OTA slot, so +this warns while there is still room to act. + +Usage: python .github/size_check.py [min free KB] +Writes a line to $GITHUB_STEP_SUMMARY when it is set. +""" +import os +import struct +import sys + +ENTRY = struct.Struct(" 3 else 8 * 1024 + used = os.path.getsize(os.path.join(build_dir, "firmware.bin")) + slot = app_slot_size(os.path.join(build_dir, "partitions.bin")) + free = slot - used + ok = free >= min_free + line = (f"| {name} | {used:,} | {slot:,} | {free / 1024:.1f} KB | " + f"{'OK' if ok else f'FAIL: under {min_free // 1024} KB free'} |") + print(line) + summary = os.environ.get("GITHUB_STEP_SUMMARY") + if summary: + with open(summary, "a", encoding="utf-8") as f: + f.write("| Env | Firmware | App slot | Free | |\n|---|---|---|---|---|\n") + f.write(line + "\n") + return 0 if ok else 1 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bbc23e1..b94857f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,8 +21,9 @@ jobs: with: python-version: "3.12" + # pioarduino's fork of PlatformIO Core, which the pioarduino platform needs. - name: Install PlatformIO - run: pip install platformio + run: pip install pioarduino - name: Run native unit tests run: pio test -e native @@ -40,7 +41,9 @@ jobs: # fwname: firmware-only binary for OTA updates # obname: onboard image (bootloader + partitions + firmware + littlefs merged) # for flashing a new chip via USB/serial - # addr_bootloader: chip-dependent (ESP32: 0x1000, C3/S3/C6: 0x0) + # addr_bootloader: chip-dependent (ESP32: 0x1000, S3/C6: 0x0) + # No C3: on ESP-IDF 5.5 its image no longer fits the 1.5 MB OTA slot + # (docs/adr/0003-pioarduino-idf55.md). C3 boards stay on 3.0.x. # addr_fs: must match spiffs/littlefs offset in esp32_3MB.csv include: - env: esp32dev @@ -51,14 +54,6 @@ jobs: fwname: SomfyController.ino.esp32.bin fsname: SomfyController.littlefs.esp32.bin obname: SomfyController.onboard.esp32.bin - - env: esp32c3 - name: ESP32-C3 - chip: ESP32-C3 - addr_bootloader: "0x0" - addr_fs: "0x310000" - fwname: SomfyController.ino.esp32c3.bin - fsname: SomfyController.littlefs.esp32c3.bin - obname: SomfyController.onboard.esp32c3.bin - env: esp32s3 name: ESP32-S3 chip: ESP32-S3 @@ -112,7 +107,7 @@ jobs: python-version: "3.12" - name: Install PlatformIO and esptool - run: pip install platformio esptool + run: pip install pioarduino esptool - name: Build LittleFS image run: pio run -e ${{ matrix.env }} -t buildfs @@ -123,6 +118,9 @@ jobs: - 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 diff --git a/AGENTS.md b/AGENTS.md index b902d5b..c4089ab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,3 +2,7 @@ - Fix any test or type errors until the whole suite is green. - Add or update tests for the code you change, even if nobody asked. - to test run `pio test -e native` + +## Building +- Firmware builds need pioarduino's Core (`pip install pioarduino`, or the pioarduino IDE extension). Stock PlatformIO Core refuses the pinned platform, see [ADR 0003](docs/adr/0003-pioarduino-idf55.md). +- The platform installs its Python packages into `~/.platformio/penv` and fails on Windows while `pio.exe` from that env is running. Run builds as `python -m platformio` from that env's Python. diff --git a/README.md b/README.md index 19c5a85..47f6043 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ * Backup does no longer use LITTLEFS. Only RAM is used. Storage should not wear out so quick. * Added uptime info in web UI +## Building +The firmware builds on [pioarduino](https://github.com/pioarduino/platform-espressif32) (Arduino 3.x on ESP-IDF 5.5), not the stock PlatformIO platform. In VS Code use the **pioarduino IDE** extension instead of PlatformIO IDE. On the command line, `pip install pioarduino` gives you `pio`. Run the unit tests with `pio test -e native`. [ADR 0003](docs/adr/0003-pioarduino-idf55.md) explains why. + ## There is a partition layout modification it's just better to perform full ESP32 wipeout. Perform backup then wipeout the firmware and restore from the bkp. * fwname: firmware-only binary for OTA updates * obname: onboard image (bootloader + partitions + firmware + littlefs merged) for flashing a new chip via USB/serial diff --git a/data-src/index.html b/data-src/index.html index 0d9c41c..c2192c9 100644 --- a/data-src/index.html +++ b/data-src/index.html @@ -277,7 +277,7 @@