mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/psram_fallback_in_wifi_osi_v5.2' into 'release/v5.2'
Some checks failed
docker / docker (push) Has been cancelled
Some checks failed
docker / docker (push) Has been cancelled
fix(wifi): Add PSRAM failure fallback in WiFi Queue API's (backport v5.2) See merge request espressif/esp-idf!33346
This commit is contained in:
commit
c8c6fd1413
@ -44,6 +44,9 @@
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
#include "private/esp_modem_wrapper.h"
|
||||
#if __has_include("esp_psram.h")
|
||||
#include "esp_psram.h"
|
||||
#endif
|
||||
|
||||
#define TAG "esp_adapter"
|
||||
|
||||
@ -255,36 +258,31 @@ static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex)
|
||||
|
||||
static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
{
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
|
||||
/*
|
||||
* Since release/v5.1, FreeRTOS has been updated to always use internal memory (i.e., DRAM)
|
||||
* for dynamic memory allocation. Calling FreeRTOS creation functions (e.g., xTaskCreate(), xQueueCreate())
|
||||
* will guarantee that the memory allocated for those tasks/objects is from internal memory.
|
||||
* For more details, please refer to the Migration Guide in release/v5.1.
|
||||
*/
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
/* Use xQueueCreateWithCaps() to allocate from SPIRAM */
|
||||
return (void *)xQueueCreateWithCaps(queue_len, item_size, MALLOC_CAP_SPIRAM);
|
||||
#else
|
||||
return (void *)xQueueCreate(queue_len, item_size);
|
||||
#endif
|
||||
#else
|
||||
return (void *)xQueueCreate(queue_len, item_size);
|
||||
#endif
|
||||
StaticQueue_t *queue_buffer = heap_caps_malloc_prefer(sizeof(StaticQueue_t) + (queue_len * item_size), 2,
|
||||
MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM,
|
||||
MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
|
||||
if (!queue_buffer) {
|
||||
return NULL;
|
||||
}
|
||||
QueueHandle_t queue_handle = xQueueCreateStatic(queue_len, item_size, (uint8_t *)queue_buffer + sizeof(StaticQueue_t),
|
||||
queue_buffer);
|
||||
if (!queue_handle) {
|
||||
free(queue_buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void *)queue_handle;
|
||||
}
|
||||
|
||||
static void queue_delete_wrapper(void *queue)
|
||||
{
|
||||
if (queue) {
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
vQueueDeleteWithCaps(queue);
|
||||
#else
|
||||
StaticQueue_t *queue_buffer = NULL;
|
||||
xQueueGetStaticBuffers(queue, NULL, &queue_buffer);
|
||||
vQueueDelete(queue);
|
||||
#endif
|
||||
#else
|
||||
vQueueDelete(queue);
|
||||
#endif
|
||||
if (queue_buffer) {
|
||||
free(queue_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,9 @@
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp32s2/rom/ets_sys.h"
|
||||
#include "private/esp_modem_wrapper.h"
|
||||
#if __has_include("esp_psram.h")
|
||||
#include "esp_psram.h"
|
||||
#endif
|
||||
|
||||
#define TAG "esp_adapter"
|
||||
|
||||
@ -246,36 +249,31 @@ static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex)
|
||||
|
||||
static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
{
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
|
||||
/*
|
||||
* Since release/v5.1, FreeRTOS has been updated to always use internal memory (i.e., DRAM)
|
||||
* for dynamic memory allocation. Calling FreeRTOS creation functions (e.g., xTaskCreate(), xQueueCreate())
|
||||
* will guarantee that the memory allocated for those tasks/objects is from internal memory.
|
||||
* For more details, please refer to the Migration Guide in release/v5.1.
|
||||
*/
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
/* Use xQueueCreateWithCaps() to allocate from SPIRAM */
|
||||
return (void *)xQueueCreateWithCaps(queue_len, item_size, MALLOC_CAP_SPIRAM);
|
||||
#else
|
||||
return (void *)xQueueCreate(queue_len, item_size);
|
||||
#endif
|
||||
#else
|
||||
return (void *)xQueueCreate(queue_len, item_size);
|
||||
#endif
|
||||
StaticQueue_t *queue_buffer = heap_caps_malloc_prefer(sizeof(StaticQueue_t) + (queue_len * item_size), 2,
|
||||
MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM,
|
||||
MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
|
||||
if (!queue_buffer) {
|
||||
return NULL;
|
||||
}
|
||||
QueueHandle_t queue_handle = xQueueCreateStatic(queue_len, item_size, (uint8_t *)queue_buffer + sizeof(StaticQueue_t),
|
||||
queue_buffer);
|
||||
if (!queue_handle) {
|
||||
free(queue_buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void *)queue_handle;
|
||||
}
|
||||
|
||||
static void queue_delete_wrapper(void *queue)
|
||||
{
|
||||
if (queue) {
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
vQueueDeleteWithCaps(queue);
|
||||
#else
|
||||
StaticQueue_t *queue_buffer = NULL;
|
||||
xQueueGetStaticBuffers(queue, NULL, &queue_buffer);
|
||||
vQueueDelete(queue);
|
||||
#endif
|
||||
#else
|
||||
vQueueDelete(queue);
|
||||
#endif
|
||||
if (queue_buffer) {
|
||||
free(queue_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,9 @@
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp32s3/rom/ets_sys.h"
|
||||
#include "private/esp_modem_wrapper.h"
|
||||
#if __has_include("esp_psram.h")
|
||||
#include "esp_psram.h"
|
||||
#endif
|
||||
|
||||
#define TAG "esp_adapter"
|
||||
|
||||
@ -249,36 +252,31 @@ static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex)
|
||||
|
||||
static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
{
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
|
||||
/*
|
||||
* Since release/v5.1, FreeRTOS has been updated to always use internal memory (i.e., DRAM)
|
||||
* for dynamic memory allocation. Calling FreeRTOS creation functions (e.g., xTaskCreate(), xQueueCreate())
|
||||
* will guarantee that the memory allocated for those tasks/objects is from internal memory.
|
||||
* For more details, please refer to the Migration Guide in release/v5.1.
|
||||
*/
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
/* Use xQueueCreateWithCaps() to allocate from SPIRAM */
|
||||
return (void *)xQueueCreateWithCaps(queue_len, item_size, MALLOC_CAP_SPIRAM);
|
||||
#else
|
||||
return (void *)xQueueCreate(queue_len, item_size);
|
||||
#endif
|
||||
#else
|
||||
return (void *)xQueueCreate(queue_len, item_size);
|
||||
#endif
|
||||
StaticQueue_t *queue_buffer = heap_caps_malloc_prefer(sizeof(StaticQueue_t) + (queue_len * item_size), 2,
|
||||
MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM,
|
||||
MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
|
||||
if (!queue_buffer) {
|
||||
return NULL;
|
||||
}
|
||||
QueueHandle_t queue_handle = xQueueCreateStatic(queue_len, item_size, (uint8_t *)queue_buffer + sizeof(StaticQueue_t),
|
||||
queue_buffer);
|
||||
if (!queue_handle) {
|
||||
free(queue_buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void *)queue_handle;
|
||||
}
|
||||
|
||||
static void queue_delete_wrapper(void *queue)
|
||||
{
|
||||
if (queue) {
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
vQueueDeleteWithCaps(queue);
|
||||
#else
|
||||
StaticQueue_t *queue_buffer = NULL;
|
||||
xQueueGetStaticBuffers(queue, NULL, &queue_buffer);
|
||||
vQueueDelete(queue);
|
||||
#endif
|
||||
#else
|
||||
vQueueDelete(queue);
|
||||
#endif
|
||||
if (queue_buffer) {
|
||||
free(queue_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user