firmware icon indicating copy to clipboard operation
firmware copied to clipboard

Add custom esp32 libs to save some iram space

Open jp-bennett opened this issue 1 year ago • 3 comments

This adds the results from a build of https://github.com/espressif/esp32-arduino-lib-builder v4.4 with the extra sdkconfig options of:

CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM=y
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_ESP_WIFI_IRAM_OPT=n
CONFIG_ESP32_WIFI_RX_IRAM_OPT=n
CONFIG_SPIRAM_CACHE_LIBCHAR_IN_IRAM=n
CONFIG_SPIRAM_CACHE_LIBSTR_IN_IRAM=n
CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=0
CONFIG_SPIRAM_CACHE_LIBMISC_IN_IRAM=n
CONFIG_SPIRAM_CACHE_LIBTIME_IN_IRAM=n

Which reduces iram usage from Used static IRAM: 130970 bytes ( 102 remain, 99.9% used) to Used static IRAM: 113762 bytes ( 17310 remain, 86.8% used)

This pr turns it on for just the tbeam target, since that's all I've tested it on.

jp-bennett avatar Jul 23 '24 14:07 jp-bennett

I'd not overwrite the files but host the modified tool chain on a GitHub and just link it instead of the stock one. Pretty much like we use the rp2040 of earlphilower

caveman99 avatar Jul 24 '24 21:07 caveman99

@caveman99 I totally agree, and spent several hours trying to do exactly that, and failed to find the magic incantation to make it work. I'm sure it's possible, but this approach is what actually compiled and worked.

I'll take another shot at including it as a framework-package, and see if I can find how to do it.

Edit: Yeah, once again I hit the same problem, rooted in the frustrating lack of documentation on how to do this. I can specify my compiled libs using platform_packages = platformio/framework-arduinoespressif32-libs and it compiles, but the output firmware doesn't actually use the custom changes. No change in iram usage.

jp-bennett avatar Jul 25 '24 14:07 jp-bennett

@jp-bennett You may want to grab a platformio package zip from https://github.com/mskvortsov/meshtastic-esp32-arduino-libs, I've put your sdkconfig options into there. And I'm ok if you want to import that repo into the meshtastic github organization.

mskvortsov avatar Aug 19 '24 09:08 mskvortsov