Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size of binary grows by 15-20% with latest version #471

Open
luebbe opened this issue Jan 7, 2018 · 13 comments
Open

Size of binary grows by 15-20% with latest version #471

luebbe opened this issue Jan 7, 2018 · 13 comments
Assignees
Milestone

Comments

@luebbe
Copy link
Collaborator

luebbe commented Jan 7, 2018

Hi folks,

maybe not the 100% correct place to ask the question here, but I'm hoping for some tips nevertheless.

The binary size of my https://github.com/luebbe/homie-sonoff/ project grew by 20% (from 366544 bytes to 416192 bytes) by switching to the latest version of homie and updating all the dependencies. This is becoming a bit of a problem on sonoff devices which only have 1 MByte of flash.
I don't really understand what is causing this.
Is it possible that the linker just links everything, even unused code from piolibdeps into the binary?
How can I prevent this from happening?

@timpur
Copy link
Contributor

timpur commented Jan 7, 2018

im going to be looking into this also with v2.1

@timpur timpur self-assigned this Jan 7, 2018
@timpur timpur added this to the v2.1.0 milestone Jan 7, 2018
@timpur timpur mentioned this issue Jan 7, 2018
17 tasks
@luebbe
Copy link
Collaborator Author

luebbe commented Jan 8, 2018

FYI I made a little experiment with my homie-ota project. In https://github.com/luebbe/homie-ota/tree/playground. I changed platformio.ini so that four builds are made in the following order

  • serial1 with no "extra" lib_deps
  • ssd1306 with the ssd1306 dependency
  • u8g2 with the u8g2 dependency
  • serial2 with no "extra" lib_deps (just a clone of serial1)

if you delete .piolibdeps before "pio run", you can see that the ssd1306 and u8g2 lib_deps are downloaded and installed when needed.
The resulting binary size of all four builds is exactly the same (404KByte), which I find mildly confusing. I would have expected more for the "ssd1306" and "u8g2" builds.
Or do the binaries grow in fixed chunks, because only multiples of n KByte can be flashed?

@timpur
Copy link
Contributor

timpur commented Jan 8, 2018

Good question, I have no idea but when I have time I hope to find out my self. Will pass on anything I learn.

@kylegordon
Copy link
Contributor

kylegordon commented Jan 15, 2018

Can confirm, using https://github.com/euphi/Homie_BareMinimum results in a 395K binary, with Homie v2.0.0-beta.3, v2.0.0-beta.2, and Develop

This also allows a one time flash of the Sonoff device I'm using at the moment ( Sonoff Touch with ESP8285 ), and then all future OTA updates fail with an error 400 NOT_ENOUGH_SPACE

Has Homie gotten fat? :-) ( I don't think so, I think it's likely to be a dependency somewhere )

@timpur
Copy link
Contributor

timpur commented Jan 15, 2018

Biggest change to homie that i know was changing the web server to use the async version. Will look into whats causing the bloat.

I do know that were still dependant on the core webClient and thats why i requested for a asyncWebClient (me-no-dev/ESPAsyncWebServer#283). The idea being were using as much async stuff as possible and the async version builds on from asyncTCP which is required for mqtt and the asyncWebServer, thus this could reduce firmware size.

@euphi
Copy link
Member

euphi commented Jan 16, 2018

For a more modular design (--> homie 3.0) it would be nice to be able to remove the Web server completely.

I don't need it, because I upload config.json via USB to SPIFFS and the Web server is not used in normal mode.

As a first step, it could be removed by using compiler flags.

@timpur
Copy link
Contributor

timpur commented Jan 16, 2018

Yes homie 3.0 will aim for that

@euphi
Copy link
Member

euphi commented Jan 17, 2018

Homie-BareMinimum:

Old (7.12.17)
354489 7928 31992 394409 604a9 .pioenvs/esp01/firmware.elf

New (17.1.18):
390705 9088 32496 432289 698a1 .pioenvs/esp01-latest/firmware.elf

LDF old:

Library Dependency Graph
|-- <Hash> v1.0
|-- <Homie> v2.0.0
|   |-- <ArduinoJson> v5.11.2
|   |-- <AsyncMqttClient> v0.8.1
|   |   |-- <ESPAsyncTCP> v1.1.3
|   |-- <Bounce2> v2.3
|   |-- <ESP Async WebServer> v1.1.1
|   |   |-- <ESPAsyncTCP> v1.1.3
|   |   |-- <ESP8266WiFi> v1.0
|   |   |-- <Hash> v1.0
|   |   |-- <ArduinoJson> v5.11.2
|   |-- <Ticker> v1.0
|   |-- <ESP8266HTTPClient> v1.1
|   |   |-- <ESP8266WiFi> v1.0
|   |-- <ESP8266WiFi> v1.0
|   |-- <DNSServer> v1.1.0
|   |   |-- <ESP8266WiFi> v1.0
|   |-- <ESPAsyncTCP> v1.1.3
|   |-- <ESP8266mDNS>
|   |   |-- <ESP8266WiFi> v1.0

|-- <Homie> v2.0.0
|   |-- <ArduinoJson> v5.12.0
|   |-- <AsyncMqttClient> v0.8.2
|   |   |-- <ESPAsyncTCP> v1.1.3
|   |-- <Bounce2> v2.3
|   |-- <ESP Async WebServer> v1.1.1
|   |   |-- <ESPAsyncTCP> v1.1.3
|   |   |-- <ESP8266WiFi> v1.0
|   |   |-- <ArduinoJson> v5.12.0
|   |   |-- <Hash> v1.0
|   |-- <DNSServer> v1.1.0
|   |   |-- <ESP8266WiFi> v1.0
|   |-- <Ticker> v1.0
|   |-- <ESP8266mDNS>
|   |   |-- <ESP8266WiFi> v1.0
|   |-- <ESP8266WiFi> v1.0
|   |-- <ESP8266HTTPClient> v1.1
|   |   |-- <ESP8266WiFi> v1.0
|   |-- <ESPAsyncTCP> v1.1.3
|-- <Hash> v1.0

@timpur
Copy link
Contributor

timpur commented Jan 17, 2018

@euphi which branch/commit for each ?? because homie dev hasn't had major changes in that time frame??

@euphi
Copy link
Member

euphi commented Jan 17, 2018

Yes, it seems to be caused by dependencies.

The difference between 2.0.0-beta3 and develop is quite small.

Unfortunately platformio does not show the full version (platformio/platformio-core#1274).

@jowi24
Copy link

jowi24 commented Mar 19, 2018

For me, upgrading Espressif 8266 platform from 1.5.0 to 1.6.0 caused an increase of 11%.

@kylegordon
Copy link
Contributor

I agree, with espressif8266@1.5.0, my binary is 8.9% smaller.

Is this something https://github.com/platformio/platform-espressif8266 can help with?

@kleini
Copy link
Collaborator

kleini commented Jan 24, 2019

Please see #563 for one first compiler flag to reduce the size by just disabling not used features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants