Skip to content

Commit

Permalink
zephyr: esp32s3: add SPIRAM heap option
Browse files Browse the repository at this point in the history
WIP

Signed-off-by: Marek Matej <marek.matej@espressif.com>
  • Loading branch information
Marek Matej committed Sep 23, 2024
1 parent f03b492 commit 5f5acef
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions zephyr/esp32s3/src/wifi/esp_wifi_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@ static inline void esp_wifi_free_func(void *mem)
k_heap_free(&esp_runtime_heap, mem);
}

#elif defined(CONFIG_ESP_WIFI_HEAP_SPIRAM)

#include <zephyr/multi_heap/shared_multi_heap.h>

#define esp_wifi_malloc_func(_sz) shared_multi_heap_aligned_alloc(SMH_REG_ATTR_EXTERNAL, 4, _sz)

static inline void *esp_wifi_calloc_func(size_t n, size_t size)
{
size_t sz;
if (__builtin_mul_overflow(n, size, &sz)) {
return NULL;
}
void *ptr = shared_multi_heap_aligned_alloc(SMH_REG_ATTR_EXTERNAL, 4, sz);
if (ptr) {
memset(ptr, 0, sz);
}
return ptr;
}

#define esp_wifi_free_func(_mem) shared_multi_heap_free(_mem)

#else

#define esp_wifi_malloc_func(_size) k_malloc(_size)
Expand All @@ -89,8 +110,8 @@ uint64_t g_wifi_feature_caps =
#if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE
CONFIG_FEATURE_WPA3_SAE_BIT |
#endif
#if defined(CONFIG_SPIRAM)
CONFIG_FEATURE_CACHE_TX_BUF_BIT |
#if CONFIG_SPIRAM
// CONFIG_FEATURE_CACHE_TX_BUF_BIT |
#endif
#if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT
CONFIG_FEATURE_FTM_INITIATOR_BIT |
Expand Down

0 comments on commit 5f5acef

Please sign in to comment.