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

Build our own ESP32 framework #13

Open
dkerr64 opened this issue Dec 12, 2024 · 2 comments
Open

Build our own ESP32 framework #13

dkerr64 opened this issue Dec 12, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dkerr64
Copy link
Collaborator

dkerr64 commented Dec 12, 2024

The size of our binary is creeping up. With addition of vehicle occupancy the binary is now over 90% of available space.

So I investigated whether we can tell Arduino / ESP not to compile pieces we don't use... in other words use menuconfig to configure what components we want. It turns out that Arduino framework defaults to a pre-compiled default ESP32 framework. To change that we can add a sdkconfig.defaults file and make minor tweaks to platform.ini. There is an example here.

I have tried this and modified the example sdkconfig to this...

CONFIG_AUTOSTART_ARDUINO=y
# CONFIG_WS2812_LED_ENABLE is not set
CONFIG_FREERTOS_HZ=1000
CONFIG_MBEDTLS_PSK_MODES=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=y
CONFIG_ESP_HTTPS_SERVER_ENABLE=n
CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n
CONFIG_ESP_INSIGHTS_TRANSPORT_HTTPS=n
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_LOG_COLORS=n
CONFIG_LOG_DEFAULT_LEVEL_NONE=y

and platformio.ini to include...

board_build.embed_txtfiles =
    managed_components/espressif__esp_insights/server_certs/https_server.crt
    managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
    managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
    managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt

and

framework = arduino, espidf

The result of this is binary reduced by about 6% to just under 85% of available flash.

The downside to this is that builds take significantly longer, even incremental builds.

@dkerr64 dkerr64 added the enhancement New feature or request label Dec 12, 2024
@PaulWieland
Copy link
Collaborator

I wonder what makes this firmware so bloated... the ESP Home disco firmware is only 1.1MB.

@dkerr64
Copy link
Collaborator Author

dkerr64 commented Dec 14, 2024

I have added the necessary changes to PR #16 but it is not enabled because it adds considerable time to the builds.

In addition to the space savings, we can also enable CONFIG_FREERTOS_USE_TRACE_FACILITY which gives us the ability to monitor FreeRTOS task memory usage. But that is niche so leave disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants