Merge branch 'nimble/iram_allocation_strategy' into 'master'

NimBLE: Add support to IRAM allocation strategy

See merge request espressif/esp-idf!8015
This commit is contained in:
Angus Gratton 2020-03-27 13:54:25 +08:00
commit 88bf21b21e
3 changed files with 18 additions and 1 deletions

View file

@ -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"

View file

@ -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

View 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