I got nerd sniped by my OCD on this one. I noticed that the program size check always reports a max size of 1044464 despite my override of board_upload.maximum_size = 400
in my platformio.ini.
I tried digging through the code to identify the cause and submit a PR, but I honestly cannot navigate the python code and identify the point at which the board_upload
is pulled from the platformio.ini and integrated with the env.BoardConfig()
object.
From what I can find, builder/tools/pioplatform.py::PrintConfiguration
prints the expected value (400B Flash (see relevant output below)) while builder/tools/pioupload.py::CheckUploadSize
receives a different env
object that isn’t augmented with the overrides in my platformio.ini. AFAICT, both PrintConfiguration
and CheckUploadSize
use the same call to env.BoardConfig().get("upload.maximum_size", 0)
, so I’m lost as to why different different BoardConfig
objects are generated.
So I guess my questions are…
- Why doesn’t platformio load a single Scons environment for all tasks run in a platformio environment?
- For each Scons environment object created, where does platformio load the ini config, identify the
board_
entries, and insert them into theBoardConfig
object?
# Relevant lines from full output.
HARDWARE: ESP8266 80MHz, 80KB RAM, 400B Flash
... ^^^^
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [==== ] 36.0% (used 29500 bytes from 81920 bytes)
Flash: [=== ] 33.3% (used 347872 bytes from 1044464 bytes)
^^^^^^^
# Full output
user@comp:project$ pio run -e ota -t checkprogsize
Processing ota (platform: espressif8266; board: d1_mini; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 (2.6.2) > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 400B Flash
PACKAGES:
- framework-arduinoespressif8266 3.20704.0 (2.7.4)
- tool-esptool 1.413.0 (4.13)
- tool-esptoolpy 1.20800.0 (2.8.0)
- toolchain-xtensa 2.40802.200502 (4.8.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 39 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <PubSubClient> 2.8.0
|-- <Adafruit Unified Sensor> 1.1.4
|-- <Adafruit BME280 Library> 2.1.2
| |-- <Adafruit Unified Sensor> 1.1.4
| |-- <SPI> 1.0
| |-- <Wire> 1.0
|-- <ArduinoOTA> 1.0
| |-- <ESP8266WiFi> 1.0
| |-- <ESP8266mDNS> 1.2
| | |-- <ESP8266WiFi> 1.0
|-- <SPI> 1.0
|-- <ESP8266WebServer> 1.0
| |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
Building in release mode
Linking .pio/build/ota/firmware.elf
Retrieving maximum program size .pio/build/ota/firmware.elf
Checking size .pio/build/ota/firmware.elf
CheckUploadSize BoardConfig
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [==== ] 36.0% (used 29500 bytes from 81920 bytes)
Flash: [=== ] 33.3% (used 347872 bytes from 1044464 bytes)
=============================================================================== [SUCCESS] Took 1.87 seconds ===============================================================================
Environment Status Duration
------------- -------- ------------
ota SUCCESS 00:00:01.866
# platformio.ini
[env:ota]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
lib_deps =
mbed-quevedo/ESP8266@0.0.0+sha.77388e8f0697
knolleary/PubSubClient@^2.8.0
adafruit/Adafruit Unified Sensor@^1.1.4
adafruit/Adafruit BME280 Library@^2.1.2
board_build.ldscript = eagle.flash.4m.ld
board_upload.maximum_size = 400