Skip to main content

ESP-IDF Adv. - Assign. 3.1

·2 mins·
Table of Contents
Reduce binary size by working on configuration.

In this assignment, you will analyze the binary image size and optimize the memory footprint of your application.

Assignment steps
#

We will:

  1. Build the original project to spot any oversized or suspicious sections (e.g., .text, .data, .rodata) that may hide unoptimized code.
  2. Change configuration to reduce it.
  3. Rebuild the project to check the improvement.

Build the original project
#

  • > ESP-IDF: Full Clean Project
  • > ESP-IDF: Build Your Project

You will get the summary table of Fig.1 for the binary image.

Fig.1 - Size calculation

Fig.1 - Size calculation

Removing the logs
#

  • Remove the logging output in the menuconfig
    if you don’t remember how to do that, check assignment 1.3
  • > ESP-IDF: Build Your Project
Fig.2 - Size calculation after removing logging

Fig.2 - Size calculation after removing logging

The binary size is 77kb less than before.

Certificate Bundle
#

  • Open menuconfig: > ESP-IDF: SDK Configuration Editor (menuconfig)
  • Uncheck Certificate BundleEnable trusted root certificate bundle
  • > ESP-IDF: Build Your Project
Fig.3 - Size calculation after removing certificate bundle

Fig.3 - Size calculation after removing certificate bundle

MQTT unused options
#

  • Open menuconfig: > ESP-IDF: SDK Configuration Editor (menuconfig)
  • Uncheck ESP-MQTT ConfigurationsEnable MQTT over SSL
  • Uncheck ESP-MQTT ConfigurationsEnable MQTT over Websocket
  • > ESP-IDF: Build Your Project
Fig.4 - Size calculation after removing mqtt ssl and websocket support

Fig.4 - Size calculation after removing mqtt ssl and websocket support

We gained another 6.7kb.

Conclusion
#

In this assignment, we saw how to check the size of our binary and how to use the menuconfig to removed unused options to improve the memory footprint of our application.

Next step: assignment 3.2

Related

ESP-IDF Adv. - Assign. 2.1
4 mins
Event loop: Manage temperature and alarm sensor via events
ESP-IDF Adv. - Assign. 3.2
8 mins
Explore core dump – guided
ESP-IDF Adv. - Assign. 4.1
2 mins
Change partition table to Factory app, two ota definitions