From 88c88542cecdb57129ff07ab3589601da9e8a102 Mon Sep 17 00:00:00 2001 From: zwx Date: Thu, 4 Dec 2025 19:47:57 +0800 Subject: [PATCH] fix(openthread): open nvs from the configured partition --- .../openthread/src/port/esp_openthread_settings.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/openthread/src/port/esp_openthread_settings.c b/components/openthread/src/port/esp_openthread_settings.c index f9064ee437..e2cc930d26 100644 --- a/components/openthread/src/port/esp_openthread_settings.c +++ b/components/openthread/src/port/esp_openthread_settings.c @@ -130,9 +130,18 @@ static esp_err_t erase_all_key(uint16_t aKey) void otPlatSettingsInit(otInstance *aInstance, const uint16_t *aSensitiveKeys, uint16_t aSensitiveKeysLength) { - esp_err_t err = nvs_open(OT_NAMESPACE, NVS_READWRITE, &s_ot_nvs_handle); + OT_UNUSED_VARIABLE(aInstance); + OT_UNUSED_VARIABLE(aSensitiveKeys); + OT_UNUSED_VARIABLE(aSensitiveKeysLength); + esp_err_t err = ESP_OK; + if (s_storage_name != NULL) { + err = nvs_open_from_partition(s_storage_name, OT_NAMESPACE, NVS_READWRITE, &s_ot_nvs_handle); + } else { + err = nvs_open(OT_NAMESPACE, NVS_READWRITE, &s_ot_nvs_handle); + } + if (err != ESP_OK) { - ESP_LOGE(OT_PLAT_LOG_TAG, "Failed to open NVS namespace (0x%x)", err); + ESP_LOGE(OT_PLAT_LOG_TAG, "Failed to open %s namespace (0x%x)", s_storage_name == NULL ? "nvs" : s_storage_name, err); assert(0); } }