Skip to content

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

Open
@einglis

Description

@einglis

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:

  • This value is not the same as in sonoff_basic.json: "upload": { ... "maximum_size": 1048576, and
  • This value does not respect attempts to override it in platformio.ini: board_upload.maximum_size = 500000

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:

  • It's not maintainable
  • It might have side effects I'm not aware of

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions