fix(firmware): redesign partition table for 4MB flash; fix flash size in esptool.js

The XMC embedded flash on ESP32-S3 (QFN56) has JEDEC ID 164020 which esptool.js
does not recognise — it returns flash size -1 causing 'File doesn't fit in
available flash' before any bytes are written.

firmware/sdkconfig.defaults:
  CONFIG_ESPTOOLPY_FLASHSIZE 16MB → 4MB
  4MB is the minimum supported flash. The spi_flash check only panics when
  physical < header, so 4MB header is safe on 16MB boards as well.

firmware/partitions.csv:
  Redesigned to fit within 4MB flash:
    factory  0x010000–0x200000  (~1.9MB, fits current 1.7MB binary + 330KB headroom)
    ota_0    0x200000–0x3F0000  (~1.9MB, A/B OTA + rollback preserved)
    otadata  0x3F0000–0x3F2000  (8KB)
  Total flash used: 0x3F2000 (98.6% of 4MB). Drops ota_1 (was at 8MB, unusable
  on 4MB devices anyway); rollback still works factory↔ota_0.

dashboard/js/onboard.js:
  flashSize: 'detect' → '4MB'  (detect returned -1 for this chip's JEDEC ID;
  hardcoding '4MB' correctly sets the binary header for all supported boards)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-04-17 10:40:58 -04:00
parent 7cdcb361df
commit d83759899f
3 changed files with 12 additions and 11 deletions

View file

@ -533,7 +533,7 @@
await loader.writeFlash({
fileArray: [{ data: firmwareData, address: offset }],
flashSize: 'detect',
flashSize: '4MB',
flashMode: 'dio',
flashFreq: '80m',
eraseAll: false,

View file

@ -1,11 +1,10 @@
# Name, Type, SubType, Offset, Size, Flags
# NVS, PHY init, and OTA data in standard low-flash locations
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
# Factory app at standard 0x10000 offset (4 MB)
factory, app, factory, 0x10000, 0x400000,
# Dual OTA partitions for A/B updates with rollback
ota_0, app, ota_0, 0x410000,0x400000,
ota_1, app, ota_1, 0x810000,0x400000,
phy_init, data, phy, 0xF000, 0x1000,
# Factory app at standard 0x10000 offset (~1.9MB — fits current ~1.7MB binary)
factory, app, factory, 0x10000, 0x1F0000,
# Single OTA partition for A/B updates with rollback (fits in 4MB flash)
ota_0, app, ota_0, 0x200000,0x1F0000,
# OTA data partition — bootloader uses this to track which OTA slot to boot
otadata, data, ota, 0xc10000,0x2000,
otadata, data, ota, 0x3F0000,0x2000,

1 # Name, Type, SubType, Offset, Size, Flags
2 # NVS, PHY init, and OTA data in standard low-flash locations
3 nvs, data, nvs, 0x9000, 0x6000,
4 phy_init, data, phy, 0xf000, 0x1000, phy_init, data, phy, 0xF000, 0x1000,
5 # Factory app at standard 0x10000 offset (4 MB) # Factory app at standard 0x10000 offset (~1.9MB — fits current ~1.7MB binary)
6 factory, app, factory, 0x10000, 0x400000, factory, app, factory, 0x10000, 0x1F0000,
7 # Dual OTA partitions for A/B updates with rollback # Single OTA partition for A/B updates with rollback (fits in 4MB flash)
8 ota_0, app, ota_0, 0x410000,0x400000, ota_0, app, ota_0, 0x200000,0x1F0000,
ota_1, app, ota_1, 0x810000,0x400000,
9 # OTA data partition — bootloader uses this to track which OTA slot to boot
10 otadata, data, ota, 0xc10000,0x2000, otadata, data, ota, 0x3F0000,0x2000,

View file

@ -4,9 +4,11 @@
# Chip target
CONFIG_IDF_TARGET="esp32s3"
# Flash size — partitions.csv requires 12.1MB (factory 4MB + ota_0 4MB + ota_1 4MB)
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="16MB"
# Flash size — partitions.csv requires ~3.9MB (factory 1.9MB + ota_0 1.9MB + otadata)
# Using 4MB as minimum supported flash. Safe on 16MB boards: spi_flash only panics
# when physical < header, not when physical > header.
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
# WiFi CSI Configuration
CONFIG_ESP_WIFI_RX_BCN_ADAPT=y