Merge branch 'configs_for_controller_ram_optimizatin' into 'main'

examples/controller: add configs for controller RAM optimization

See merge request app-frameworks/esp-matter!1039
This commit is contained in:
Shu Chen
2025-02-18 10:40:01 +08:00
6 changed files with 67 additions and 3 deletions
+11
View File
@@ -98,3 +98,14 @@ I cannot send commands to the light from the controller:
- If you are still facing issues, reproduce the issue on the default example for the device and then raise an [issue](https://github.com/espressif/esp-matter/issues). Make sure to share these:
- The complete device logs for both the devices taken over UART.
- The esp-matter and esp-idf branch you are using.
### A1.3 RAM optimization
- The `sdkconfig.defaults.ram_optimization` file is provided for RAM optimization. These configurations enable SPIRAM (CONFIG_SPIRAM=y) and allow the BSS segment to be placed in SPIRAM (CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY). With these configurations, [linker file](./main/linker.lf) can move move BSS segments of certain main controller libraries to SPIRAM. Build the example with the sdkconfig:
```
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.ram_optimization" set-target esp32s3 build
```
- The OTBR's sdkconfig file `sdkconfig.defaults.otbr` has RAM optimization configurations enabled by default.
- If you encounter a crash with error message: "PSRAM chip not found or not supported, or wrong PSRAM line mode", please check whether the module has SPIRAM and if the SPIRAM mode is configured correctly:
- For 2MB SPIRAM, set `CONFIG_SPIRAM_MODE_QUAD=y`
- For SPIRAM larger than 2MB, set `CONFIG_SPIRAM_MODE_OCT=y`
- Refer to [linker](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/optimizations.html#configuration-options-to-optimize-ram-and-flash) for other options to optimize RAM and Flash.
+2 -1
View File
@@ -1,6 +1,7 @@
idf_component_register(SRC_DIRS "."
INCLUDE_DIRS "."
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils")
PRIV_INCLUDE_DIRS "." "${ESP_MATTER_PATH}/examples/common/utils"
LDFRAGMENTS "linker.lf")
if(CONFIG_SPIFFS_ATTESTATION_TRUST_STORE)
spiffs_create_partition_image(paa_cert ${CMAKE_SOURCE_DIR}/paa_cert FLASH_IN_PROJECT)
+6
View File
@@ -48,6 +48,12 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
#if CONFIG_OPENTHREAD_BORDER_ROUTER
static bool sThreadBRInitialized = false;
if (!sThreadBRInitialized) {
// TODO: Remove InitThreadStack() and StartThreadTask() if submodule contains the fix
// (https://github.com/project-chip/connectedhomeip/pull/37033)
if (chip::DeviceLayer::ThreadStackMgr().InitThreadStack() != CHIP_NO_ERROR ||
chip::DeviceLayer::ThreadStackMgr().StartThreadTask() != CHIP_NO_ERROR) {
break;
}
esp_openthread_set_backbone_netif(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"));
esp_openthread_lock_acquire(portMAX_DELAY);
esp_openthread_border_router_init();
+31
View File
@@ -0,0 +1,31 @@
[mapping:CHIP]
archive: libCHIP.a
entries:
if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
* (extram_bss)
else:
* (default)
[mapping:esp_matter]
archive: libesp_matter.a
entries:
if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
* (extram_bss)
else:
* (default)
[mapping:main]
archive: libmain.a
entries:
if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
* (extram_bss)
else:
* (default)
[mapping:openthread_bss]
archive: libopenthread.a
entries:
if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y && OPENTHREAD_ENABLED = y:
* (extram_bss)
else:
* (default)
+6 -2
View File
@@ -74,13 +74,17 @@ CONFIG_CHIP_PROJECT_CONFIG="main/matter_project_config.h"
# Enable ble controller
CONFIG_ENABLE_ESP32_BLE_CONTROLLER=y
# SPIRAM
# Use SPIRAM and external alloc
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_QUAD=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=512
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=8192
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=16384
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL=y
CONFIG_ESP_MATTER_MEM_ALLOC_MODE_EXTERNAL=y
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
# Enable HKDF for mbedtls
CONFIG_MBEDTLS_HKDF_C=y
@@ -0,0 +1,11 @@
# Use SPIRAM and external alloc
CONFIG_SPIRAM=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=512
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=16384
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL=y
CONFIG_ESP_MATTER_MEM_ALLOC_MODE_EXTERNAL=y
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y