From 93cd0e68e64d21bda464b6279aad7b0839d57db5 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Fri, 1 Dec 2023 16:21:58 +0530 Subject: [PATCH 1/5] [ESP32] Option to configure the system buffer pool allocation from heap --- config/esp32/components/chip/Kconfig | 7 +++++++ src/platform/ESP32/CHIPPlatformConfig.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index d3f621f98f4024..9169d9361d4fd9 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -163,6 +163,13 @@ menu "CHIP Core" help Option to enable/disable CHIP data model. + config CHIP_SYSTEM_CONFIG_POOL_USE_HEAP + bool "Use heap memory for system buffer pool" + default y + help + Option to use heap memory for system buffer pool. + If enabled, will allocate system buffer pool from Heap. + endmenu # "General Options" menu "Networking Options" diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index 82b6a6262a1e1b..24fbf7c4f1b809 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -146,3 +146,9 @@ #ifndef CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS #define CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS CONFIG_MRP_MAX_RETRANS #endif // CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS + +#ifdef CONFIG_CHIP_SYSTEM_CONFIG_POOL_USE_HEAP +#define CHIP_SYSTEM_CONFIG_POOL_USE_HEAP 1 +#else +#define CHIP_SYSTEM_CONFIG_POOL_USE_HEAP 0 +#endif From 3d731354d866a7e6b0b08a41da2861d09a7f771f Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Sat, 3 Aug 2024 10:31:03 +0530 Subject: [PATCH 2/5] address reviews --- config/esp32/components/chip/Kconfig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 9169d9361d4fd9..f00bd8de4736c1 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -164,11 +164,13 @@ menu "CHIP Core" Option to enable/disable CHIP data model. config CHIP_SYSTEM_CONFIG_POOL_USE_HEAP - bool "Use heap memory for system buffer pool" - default y + bool "Use heap memory to allocate object pools" + default n help - Option to use heap memory for system buffer pool. - If enabled, will allocate system buffer pool from Heap. + This option enables the use of heap memory to allocate object pools. + When enabled, it do not enforce the maximum number of entries in object pools + to allocate. + endmenu # "General Options" From c784d211e2d829c9921dd8a08fe6749ede31c7f8 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Sat, 3 Aug 2024 10:32:45 +0530 Subject: [PATCH 3/5] minor adjustment to help text --- config/esp32/components/chip/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index f00bd8de4736c1..af6d361c12b25c 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -168,8 +168,7 @@ menu "CHIP Core" default n help This option enables the use of heap memory to allocate object pools. - When enabled, it do not enforce the maximum number of entries in object pools - to allocate. + When enabled, it do not enforce the maximum number of entries in object pools. endmenu # "General Options" From 48243aa3000cf17e8f5abc8c45de7e461f22fe65 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Mon, 5 Aug 2024 12:05:21 +0530 Subject: [PATCH 4/5] some minor adjustments --- config/esp32/components/chip/Kconfig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index af6d361c12b25c..d7263637e17c51 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -168,8 +168,10 @@ menu "CHIP Core" default n help This option enables the use of heap memory to allocate object pools. - When enabled, it do not enforce the maximum number of entries in object pools. - + When this option is enabled, it does not pre-allocate the object pools. + Additionally, there is no limit, (i.e. free heap is the limit) on the + maximum number of entries that can be allocated. + This option can be usefull if you run into static DRAM overflow. endmenu # "General Options" From 552b684f2a2df183cedf88d10f27be0fc1fae780 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Tue, 27 Aug 2024 10:06:38 +0530 Subject: [PATCH 5/5] Add notes regarding expected failures --- config/esp32/components/chip/Kconfig | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index d7263637e17c51..147bb97af25278 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -168,10 +168,20 @@ menu "CHIP Core" default n help This option enables the use of heap memory to allocate object pools. - When this option is enabled, it does not pre-allocate the object pools. - Additionally, there is no limit, (i.e. free heap is the limit) on the - maximum number of entries that can be allocated. - This option can be usefull if you run into static DRAM overflow. + When enabled, object pools are not pre-allocated. + Additionally, the maximum number of entries that can be allocated is + only limited by the available heap memory. + + This option can be useful if you encounter static DRAM overflow. + + NOTE: Since there is no cap on pool sizes, this may lead to issues + where embedded code assumes the pool size is limited, and no other + mechanisms are in place to restrict the size of allocations. + + NOTE: If enabled and the free heap is exhausted, this may result in + undefined behavior, potential non-compliance with specifications, + or failure during certification tests. Even if it passes, it may fail + to function properly with actual controllers. endmenu # "General Options"