From 182d859870f1552a89339191645760600a1b339c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= Date: Sat, 5 Sep 2026 23:15:29 +0200 Subject: [PATCH] Shrink LittleFS partition, grow OTA app slots Web assets only use ~489 KB but the default 1.375 MB spiffs partition wasted the rest. Rebalance to 768 KB spiffs / 1.56 MB per app slot (was 1.25 MB), giving the tight esp32 build real headroom (99.6% -> 79.7% flash used) while preserving dual-slot OTA. Wire the custom layout into both the local PlatformIO build (new partitions.csv + platformio.ini) and the Arduino-CLI CI/release pipeline (PartitionScheme=custom, matching littlefs image size and merge_bin offset). --- .github/workflows/ci.yaml | 12 +++---- .github/workflows/release.yaml | 20 ++++++------ partitions.csv | 7 ++++ platformio.ini | 60 ++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 partitions.csv create mode 100644 platformio.ini diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6b4bec0..9f0f7f7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -44,7 +44,7 @@ jobs: - name: Create LittleFS run: | - ./mklittlefs/mklittlefs --create data --size 1441792 SomfyController.littlefs.bin + ./mklittlefs/mklittlefs --create data --size 786432 SomfyController.littlefs.bin - name: Upload binaries uses: actions/upload-artifact@v3 @@ -65,22 +65,22 @@ jobs: - board: esp32 addr_bootloader: 0x1000 chip: ESP32 - fqbn: esp32:esp32:esp32 + fqbn: esp32:esp32:esp32:PartitionScheme=custom name: ESP32 - board: lolin_c3_mini addr_bootloader: 0x0 chip: ESP32-C3 - fqbn: esp32:esp32:lolin_c3_mini + fqbn: esp32:esp32:lolin_c3_mini:PartitionScheme=custom name: LOLIN-C3-mini - board: lolin_s2_mini addr_bootloader: 0x1000 chip: ESP32-S2 - fqbn: esp32:esp32:lolin_s2_mini + fqbn: esp32:esp32:lolin_s2_mini:PartitionScheme=custom name: LOLIN-S2-mini - board: lolin_s3_mini addr_bootloader: 0x0 chip: ESP32-S3 - fqbn: esp32:esp32:lolin_s3_mini + fqbn: esp32:esp32:lolin_s3_mini:PartitionScheme=custom name: LOLIN-S3-mini steps: @@ -137,7 +137,7 @@ jobs: ${{ matrix.addr_bootloader }} build/SomfyController.ino.bootloader.bin \ 0x8000 build/SomfyController.ino.partitions.bin \ 0x10000 build/SomfyController.ino.bin \ - 0x290000 SomfyController.littlefs.bin + 0x330000 SomfyController.littlefs.bin - name: Upload ${{ matrix.name }} uses: actions/upload-artifact@v3 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fe6096d..f3cb7b9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -52,7 +52,7 @@ jobs: - name: Create LittleFS run: | - ./mklittlefs/mklittlefs --create data --size 1441792 SomfyController.littlefs.bin + ./mklittlefs/mklittlefs --create data --size 786432 SomfyController.littlefs.bin - name: Upload binaries uses: actions/upload-artifact@v4 @@ -83,32 +83,32 @@ jobs: - board: esp32 addr_bootloader: 0x1000 chip: ESP32 - fqbn: esp32:esp32:esp32wrover:PartitionScheme=default,FlashMode=qio,FlashFreq=80,UploadSpeed=921600,DebugLevel=none,EraseFlash=none - # esp32:esp32:esp32wrover:PartitionScheme=default,FlashMode=qio,FlashFreq=80,UploadSpeed=921600,DebugLevel=none,EraseFlash=none + fqbn: esp32:esp32:esp32wrover:PartitionScheme=custom,FlashMode=qio,FlashFreq=80,UploadSpeed=921600,DebugLevel=none,EraseFlash=none + # esp32:esp32:esp32wrover:PartitionScheme=custom,FlashMode=qio,FlashFreq=80,UploadSpeed=921600,DebugLevel=none,EraseFlash=none name: ESP32 obname: SomfyController.onboard.esp32.bin fwname: SomfyController.ino.esp32.bin - board: esp32c3 addr_bootloader: 0x0 chip: ESP32-C3 - fqbn: esp32:esp32:esp32c3:JTAGAdapter=default,CDCOnBoot=cdc,PartitionScheme=default,CPUFreq=160,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none - # esp32:esp32:esp32c3:JTAGAdapter=default,CDCOnBoot=default,PartitionScheme=default,CPUFreq=160,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none + fqbn: esp32:esp32:esp32c3:JTAGAdapter=default,CDCOnBoot=cdc,PartitionScheme=custom,CPUFreq=160,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none + # esp32:esp32:esp32c3:JTAGAdapter=default,CDCOnBoot=default,PartitionScheme=custom,CPUFreq=160,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none name: ESP32C3 obname: SomfyController.onboard.esp32c3.bin fwname: SomfyController.ino.esp32c3.bin - board: esp32s2 addr_bootloader: 0x1000 chip: ESP32-S2 - fqbn: esp32:esp32:esp32s2:JTAGAdapter=default,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none - # esp32:esp32:esp32s2:JTAGAdapter=default,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none + fqbn: esp32:esp32:esp32s2:JTAGAdapter=default,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PSRAM=disabled,PartitionScheme=custom,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none + # esp32:esp32:esp32s2:JTAGAdapter=default,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PSRAM=disabled,PartitionScheme=custom,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none name: ESP32S2 obname: SomfyController.onboard.esp32s2.bin fwname: SomfyController.ino.esp32s2.bin - board: esp32s3 addr_bootloader: 0x0 chip: ESP32-S3 - fqbn: esp32:esp32:esp32s3:JTAGAdapter=default,PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=hwcdc,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=default,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none - # esp32:esp32:esp32s3:JTAGAdapter=default,PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=hwcdc,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=default,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none + fqbn: esp32:esp32:esp32s3:JTAGAdapter=default,PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=hwcdc,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=custom,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none + # esp32:esp32:esp32s3:JTAGAdapter=default,PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=hwcdc,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=custom,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none name: ESP32S3 fwname: SomfyController.ino.esp32s3.bin obname: SomfyController.onboard.esp32s3.bin @@ -172,7 +172,7 @@ jobs: ${{ matrix.addr_bootloader }} build${{ matrix.name }}/SomfyController.ino.bootloader.bin \ 0x8000 build${{ matrix.name }}/SomfyController.ino.partitions.bin \ 0x10000 build${{ matrix.name }}/SomfyController.ino.bin \ - 0x290000 SomfyController.littlefs.bin + 0x330000 SomfyController.littlefs.bin - name: Upload Firmware ${{ matrix.name }} uses: shogo82148/actions-upload-release-asset@v1.7.5 diff --git a/partitions.csv b/partitions.csv new file mode 100644 index 0000000..272891b --- /dev/null +++ b/partitions.csv @@ -0,0 +1,7 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x190000, +app1, app, ota_1, 0x1A0000,0x190000, +spiffs, data, spiffs, 0x330000,0xC0000, +coredump, data, coredump,0x3F0000,0x10000, diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..5714b41 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,60 @@ +; PlatformIO configuration for ESPSomfy-RTS +; Compatible with Arduino IDE (source files remain in project root) + +[platformio] +src_dir = . +default_envs = esp32 + +[env] +framework = arduino +platform = espressif32@6.9.0 +monitor_speed = 115200 +upload_speed = 921600 +board_build.filesystem = littlefs +board_build.flash_mode = qio +board_build.partitions = partitions.csv +lib_deps = + bblanchon/ArduinoJson@6.21.5 + knolleary/PubSubClient@2.8.0 + LSatan/SmartRC-CC1101-Driver-Lib@2.5.7 + https://github.com/Links2004/arduinoWebSockets.git#2.4.0 +build_src_filter = + +<*.ino> + +<*.cpp> + +<*.h> + -<.github/> + - + +[env:esp32] +board = esp32dev + +[env:esp32c3] +board = esp32-c3-devkitc-02 +board_build.mcu = esp32c3 +build_flags = + -DARDUINO_USB_MODE=1 + -DARDUINO_USB_CDC_ON_BOOT=1 + +[env:esp32s2] +board = esp32-s2-saola-1 +board_build.mcu = esp32s2 +build_flags = + -DARDUINO_USB_CDC_ON_BOOT=1 + +; ESP32-C6 requires Arduino ESP32 core 3.x (pioarduino platform fork). +; Core 3.x has breaking API changes (ETH, tcpip_adapter removed, etc.) +; that require source code modifications before this will compile. +; [env:esp32c6] +; platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.11/platform-espressif32.zip +; board = esp32-c6-devkitc-1 +; board_build.mcu = esp32c6 +; build_flags = +; -DARDUINO_USB_MODE=1 +; -DARDUINO_USB_CDC_ON_BOOT=1 + +[env:esp32s3] +board = esp32-s3-devkitc-1 +board_build.mcu = esp32s3 +build_flags = + -DARDUINO_USB_MODE=1 + -DARDUINO_USB_CDC_ON_BOOT=1