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

Reduce flash usage up to 214k in one click #2929

Merged
merged 3 commits into from
Jul 9, 2019

Conversation

romansavrulin
Copy link
Contributor

This PR gets rid of stringstream and exception usage in @nkolban BLE library. While stringstream itself is a good and safe thing on mature desktop platforms, using it in embedded world mostly for debugging purposes has its impact. In this case we can save about 214k.

Here's a metrics of my test image build.

  • Stringsream=y
  • Exceptions in idf toolchain=y
  • Exceptions in library=y
$ ls -al build/
-rw-r--r--   1 user  staff    628288 25 июн 16:45 firmware_.bin

  • Stringsream=n
  • Exceptions in library=n
  • Exceptions in idf toolchain=y

Note: by default exceptions seems to be enabled in Arduino build configuration. So, actual flash size benefit from this PR on most platforms can be about 137k.


$ ls -al build/
-rw-r--r--   1 user  staff    491184 25 июн 16:49 firmware_.bin

  • Stringsream=n
  • Exceptions in library=n
  • Exceptions in idf toolchain=n
$ ls -al build/
-rw-r--r--   1 user  staff   413616 25 июн 16:38 firmware_.bin

@me-no-dev
Copy link
Member

Big thumbs up! :)

@me-no-dev me-no-dev merged commit a22ec4a into espressif:master Jul 9, 2019
@romansavrulin
Copy link
Contributor Author

@AlexFundorin Don't know actually. I use idf with my own libraries with submodules. But this fix is in the master now. Maybe it will be available after next release of plaformio metadata packages.

If you manage to get it work, just let us know

@AlexFundorin
Copy link

AlexFundorin commented Jul 10, 2019

If you manage to get it work, just let us know

You were fast, Roman.

In platformio.io I've changed
platform = espressif32
to
platform = https://github.com/platformio/platform-espressif32.git#feature/stage

Before change:

DATA:    [==        ]  21.5% (used 70400 bytes from 327680 bytes)
PROGRAM: [========= ]  87.6% (used 1721570 bytes from 1966080 bytes)

After (same sketch):

DATA:    [==        ]  20.4% (used 66972 bytes from 327680 bytes)
PROGRAM: [========  ]  80.2% (used 1577378 bytes from 1966080 bytes)

@romansavrulin
Copy link
Contributor Author

@AlexFundorin if you manage to change .config in idf , disable exceptions there and supply new idf binaries to platformio, you will get extra 77 kB

@romansavrulin romansavrulin deleted the reduce-flash-usage branch July 11, 2019 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants