mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
NimBLE: Add support to IRAM allocation strategy
Added IRAM allocation provision under nimble_platform_mem_malloc()
This commit is contained in:
parent
207914a13a
commit
67a6fd6f3b
@ -10,6 +10,7 @@ choice BT_NIMBLE_MEM_ALLOC_MODE
|
||||
- External SPIRAM memory only
|
||||
- Either internal or external memory based on default malloc()
|
||||
behavior in ESP-IDF
|
||||
- Internal IRAM memory wherever applicable else internal DRAM
|
||||
|
||||
Recommended mode here is always internal, since that is most preferred
|
||||
from security perspective. But if application requirement does not
|
||||
@ -26,7 +27,16 @@ choice BT_NIMBLE_MEM_ALLOC_MODE
|
||||
config BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT
|
||||
bool "Default alloc mode"
|
||||
|
||||
endchoice
|
||||
config BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT
|
||||
bool "Internal IRAM"
|
||||
depends on ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY
|
||||
help
|
||||
Allows to use IRAM memory region as 8bit accessible region.
|
||||
|
||||
Every unaligned (8bit or 16bit) access will result in an exception
|
||||
and incur penalty of certain clock cycles per unaligned read/write.
|
||||
|
||||
endchoice #BT_NIMBLE_MEM_ALLOC_MODE
|
||||
|
||||
config BT_NIMBLE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
|
@ -30,6 +30,8 @@ IRAM_ATTR void *nimble_platform_mem_malloc(size_t size)
|
||||
return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL
|
||||
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT
|
||||
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#else
|
||||
return malloc(size);
|
||||
#endif
|
||||
@ -41,6 +43,8 @@ IRAM_ATTR void *nimble_platform_mem_calloc(size_t n, size_t size)
|
||||
return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL
|
||||
return heap_caps_calloc(n, size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT
|
||||
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#else
|
||||
return calloc(n, size);
|
||||
#endif
|
||||
|
3
examples/bluetooth/nimble/blehr/sdkconfig.ci
Normal file
3
examples/bluetooth/nimble/blehr/sdkconfig.ci
Normal file
@ -0,0 +1,3 @@
|
||||
CONFIG_FREERTOS_UNICORE=y
|
||||
CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY=y
|
||||
CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT=y
|
Loading…
x
Reference in New Issue
Block a user