platformio / platform-espressif8266

Espressif 8266: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif8266
Apache License 2.0
330 stars 219 forks source link

Program size check does not respect `board_upload.maximum_size` from `platformio.ini` #313

Open einglis opened 9 months ago

einglis commented 9 months ago

I'm building firmware for the Sonoff Basic device and it supports OTA updates. As a result it's important that the firmware isn't larger than half the total flash size.

Using board_build.ldscript = eagle.flash.1m64.ld I can influence the available space, as shown by post-build the size check:

Flash: [======    ]  58.7% (used 563013 bytes from 958448 bytes)

But:

What is happening is that in .platformio/platforms/espressif8266/builder/main.py, this action:

env.VerboseAction(
      lambda source, target, env: _update_max_upload_size(env),
      "Retrieving maximum program size $SOURCE"))

parses the .ld file and extracts the true flash size from this line:

  irom0_0_seg :                         org = 0x40201010, len = 0xe9ff0

but that all happens well after the user scripting stage. Without editing the .ld file, I can't see how to avoid this behaviour, and I don't want to do that anyway because:

One resolution would be for _update_max_upload_size to use the minimum of the current/scripted value (if non-zero) and the parsed value.