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

ESP32: Optimize the temperature-measurement-app to use less RAM and Flash. #4756

Conversation

sweetymhaiske
Copy link
Contributor

@sweetymhaiske sweetymhaiske commented Feb 9, 2021

Problem

Need to optimize the temperature-measurement-app to use less RAM and Flash.

Summary of Changes

a) Added the optimization in the sdkconfig for
1. Wi-Fi and BLE
2. Disable asserts.
3. FreeRTOS unicore mode

Footprint values are as below

Default without optimization

 1 Total sizes:
 2  DRAM .data size:   16200 bytes
 3  DRAM .bss  size:   35736 bytes
 4 Used static DRAM:   51936 bytes (  72644 available, 41.7% used)
 5 Used static IRAM:  116428 bytes (  14644 available, 88.8% used)
 6       Flash code:  643146 bytes
 7     Flash rodata:  127888 bytes
 8 Total image size:~ 939398 bytes (.bin may be padded larger)

Free Heap :- 169012 bytes

Optimization with new sdkconfig.defaults
It includes:-

  1. Bluetooth/NimBLE
  2. Compiler size optimization
  3. FreeRTOS Unicore
  4. WiFi
  1 Total sizes:
  2  DRAM .data size:   14120 bytes
  3  DRAM .bss  size:   35120 bytes
  4 Used static DRAM:   49240 bytes (  75340 available, 39.5% used)
  5 Used static IRAM:  113108 bytes (  17964 available, 86.3% used)
  6       Flash code:  639259 bytes
  7     Flash rodata:  125876 bytes
  8 Total image size:~ 927483 bytes (.bin may be padded larger)

Free Heap: 196004 bytes

Optimization with 'is_debug = false'
It includes the above optimization along with the following

  1. Asserts
  2. Log disable
1 Total sizes:
2  DRAM .data size:   13392 bytes
3  DRAM .bss  size:   35104 bytes
4 Used static DRAM:   48496 bytes (  76084 available, 38.9% used)
5 Used static IRAM:  111064 bytes (  20008 available, 84.7% used)
6       Flash code:  620159 bytes
7     Flash rodata:   84148 bytes
8 Total image size:~ 863867 bytes (.bin may be padded larger)

Free Heap :- 196748 bytes

b) Chose NimBLE as a default BT host for CI sdkconfig.

Fixes #3977

@sweetymhaiske sweetymhaiske changed the title Optimize the temperature-measurement-app to use less RAM and Flash. ESP32: Optimize the temperature-measurement-app to use less RAM and Flash. Feb 9, 2021
@sweetymhaiske sweetymhaiske force-pushed the platform_esp32/temp_app_optimization branch from 2c5cf28 to 27d56ba Compare February 9, 2021 08:11
@dhrishi
Copy link
Contributor

dhrishi commented Feb 9, 2021

LGTM

Copy link
Contributor

@mspang mspang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't disable assertions for CHIP developers. We should separate optimized, release appropriate setting from those suitable for development.

@dhrishi
Copy link
Contributor

dhrishi commented Feb 10, 2021

Please don't disable assertions for CHIP developers. We should separate optimized, release appropriate setting from those suitable for development.

Hi @mspang I thought of demonstrating all possible optimizations in the temperature-measurement-app so that we have a footprint constrained configuration ready. Although, I totally agree with your point. Will it be okay if we add an application specific config option, say release mode (disabled by default) and when enabled, it disables asserts and logs. The other optimized configuration options stay in the sdkconfig.defaults as done in the PR.

@mspang
Copy link
Contributor

mspang commented Feb 10, 2021

Please don't disable assertions for CHIP developers. We should separate optimized, release appropriate setting from those suitable for development.

Hi @mspang I thought of demonstrating all possible optimizations in the temperature-measurement-app so that we have a footprint constrained configuration ready. Although, I totally agree with your point. Will it be okay if we add an application specific config option, say release mode (disabled by default) and when enabled, it disables asserts and logs. The other optimized configuration options stay in the sdkconfig.defaults as done in the PR.

We have such a setting for other apps, it's called "is_debug". ESP32 should have similar.

Debug should be the default.

@sweetymhaiske sweetymhaiske force-pushed the platform_esp32/temp_app_optimization branch 4 times, most recently from c9e446b to 3ebd4d7 Compare February 19, 2021 06:55
@boring-cyborg boring-cyborg bot added the config label Feb 19, 2021
@sweetymhaiske
Copy link
Contributor Author

Hi @mspang, PR is ready as per the changes mentioned.

@sweetymhaiske sweetymhaiske requested a review from mspang February 19, 2021 09:17
@sweetymhaiske sweetymhaiske force-pushed the platform_esp32/temp_app_optimization branch from 3ebd4d7 to 2291cd4 Compare February 19, 2021 09:24
@sweetymhaiske sweetymhaiske force-pushed the platform_esp32/temp_app_optimization branch 4 times, most recently from 04bdadf to ddf8299 Compare February 19, 2021 14:14
@sweetymhaiske sweetymhaiske force-pushed the platform_esp32/temp_app_optimization branch from ddf8299 to 9d80124 Compare February 19, 2021 14:16
@sweetymhaiske sweetymhaiske force-pushed the platform_esp32/temp_app_optimization branch from 9d80124 to b40d727 Compare February 19, 2021 14:17
@dhrishi
Copy link
Contributor

dhrishi commented Feb 20, 2021

Can the relevant folks please take a look and merge if it looks okay. Thanks!

@bzbarsky-apple bzbarsky-apple merged commit d48bcf2 into project-chip:master Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESP32: Optimize the temperature-measurement-app to use less RAM and Flash
6 participants