ESPSomfy-RTS/docs/adr/0003-pioarduino-idf55.md
cjkas a1622e652d build: move to pioarduino 55.03.312 (Arduino 3.3.12, ESP-IDF 5.5)
IDF 4.4 gets no more security fixes, and the planned RMT radio needs
IDF 5's RMT driver.  See docs/adr/0003-pioarduino-idf55.md.

- Every env on one pinned pioarduino release.  C6 drops its own
  library list and flags but stays a debug build on huge_app.
- Release envs build at CORE_DEBUG_LEVEL=2 so the ESP32 image fits its
  1.5 MB OTA slot (17 KB free); debug envs stay at 3.
- Drop the C3: its image is 76.5 KB over the OTA slot on IDF 5.5.
- CI installs pioarduino's Core and checks firmware.bin against the app
  partition, failing under 8 KB free.  PlatformIO's "Flash:" figure
  reads ~45 KB low and passed a C3 image that doesn't fit.
- esp_task_wdt_reconfigure(): on 3.x the core already starts the watchdog
  and esp_task_wdt_init() fails, so the C6 build kept the 5 s default.
- An updated firmware is kept only once it has run 60 s with the
  network up; a reset before then rolls back to the previous one.
- ETH.begin() takes the 3.x argument order; Arduino 2.x branches gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 22:05:22 +02:00

2.6 KiB

Firmware builds on pioarduino (Arduino 3.x, ESP-IDF 5.5), pinned to one release

We moved every firmware env from espressif32 @ 6.13.0 (Arduino 2.0.17 on ESP-IDF 4.4.7) to pioarduino's 55.03.312 (Arduino 3.3.12 on ESP-IDF 5.5). IDF 4.4 no longer gets security fixes for Wi-Fi, lwIP and mbedTLS, and the planned RMT radio needs IDF 5's RMT driver. The official PlatformIO platform never shipped Arduino 3.x, so pioarduino, a community fork, is the only way to get it in PlatformIO. We pin one release URL rather than stable, so a framework upgrade is always its own PR with its own size check and hardware test.

Considered Options

  • Stay on IDF 4.4. Rejected: no more security fixes, and no new RMT driver.
  • Rebuild the IDF libraries with custom_sdkconfig to leave out PPP, NAT and provisioning (about 20 KB the firmware never uses). Deferred: it makes builds much slower, and log level 2 already makes the ESP32 build fit.
  • Grow the app slots in the partition table. Rejected: an OTA update can't change the partition table, so every existing device would need a USB flash.

Consequences

  • Firmware size. The ESP32 image grows from 1,382,640 bytes (v3.0.14) to 1,555,472 at CORE_DEBUG_LEVEL=2, leaving 17 KB of the 1.5 MB OTA slot. At level 3 it doesn't fit, so release envs build at level 2 (warnings and errors) and debug envs stay at 3. PlatformIO's "Flash:" figure counts ELF sections, not the image, and reads about 45 KB low, so CI checks firmware.bin against the app partition and fails under 8 KB free (.github/size_check.py).
  • No more C3 builds. Its image grows by 214 KB to 1,651,216 bytes, 76.5 KB over the OTA slot even at level 2. C3 boards stay on the 3.0.x releases.
  • Ethernet PHY ids are ours. Arduino 3.x renumbered eth_phy_type_t (ETH_PHY_GENERIC is 0). NVS, backups and the web UI keep the Arduino 2.x numbers as eth_phy_id_t (src/EthPhy.h), translated by name when Ethernet starts. Never cast a stored id to the framework enum.
  • Ethernet only on the original ESP32. Arduino 3.x has the RMII MAC API only where CONFIG_ETH_USE_ESP32_EMAC is set. S3 and C6 build without Ethernet.
  • Updates roll back until proven. We override the core's verifyRollbackLater() hook to return true, and loop() marks the new firmware valid once it has run 60 s and the network is up. A reset before then boots the previous firmware. The LittleFS image an update wrote stays, so the old firmware runs with the new web UI.
  • Tooling. pioarduino needs its own Core fork (pip install pioarduino, the pioarduino IDE extension in VS Code), which it installs into ~/.platformio/penv in place of PlatformIO Core.