fix(openthread): fix configuration-related issues

This commit is contained in:
Xu Si Yu
2026-08-17 14:12:40 +08:00
parent a25d1a419f
commit 33fbf82bdd
4 changed files with 14 additions and 8 deletions
@@ -241,7 +241,9 @@ esp_err_t esp_openthread_launch_mainloop(void)
esp_err_t esp_openthread_deinit(void)
{
esp_openthread_lock_acquire(portMAX_DELAY);
esp_openthread_instances_deinit(esp_openthread_get_instance());
esp_openthread_lock_release();
return esp_openthread_platform_deinit();
}
@@ -30,7 +30,10 @@ bool esp_openthread_instances_init(void)
void esp_openthread_instances_deinit(otInstance *instance)
{
otInstanceFinalize(instance);
(void)instance;
for (int i = 0; i < OT_INSTANCE_COUNT; i++) {
otInstanceFinalize(s_instances[i]);
}
}
bool esp_openthread_tasklets_are_pending(otInstance *instance)
@@ -28,11 +28,13 @@ void otPlatMessagePoolInit(otInstance *aInstance, uint16_t aMinNumFreeBuffers, s
uint16_t num_buffers = aMinNumFreeBuffers;
#if CONFIG_OPENTHREAD_PLATFORM_MALLOC_CAP_SPIRAM
if (!esp_psram_is_initialized() && num_buffers > OT_MSGPOOL_NUM_BUFFERS_NO_PSRAM) {
ESP_LOGW(OT_PLAT_LOG_TAG, "PSRAM not available, reducing message pool from %u to %u buffers",
num_buffers, OT_MSGPOOL_NUM_BUFFERS_NO_PSRAM);
num_buffers = OT_MSGPOOL_NUM_BUFFERS_NO_PSRAM;
}
#endif
otMessageBuffer *buffer_pool = (otMessageBuffer *)heap_caps_calloc_prefer(num_buffers, aBufferSize, 3, esp_openthread_get_alloc_caps(), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
s_buffer_pool_pointer = (otMessageBuffer **)heap_caps_calloc_prefer(num_buffers, sizeof(otMessageBuffer **), 3, esp_openthread_get_alloc_caps(), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);