From 1114232d7e4a7d9b9f6a7586c988c4d29b1ecfe2 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Mon, 18 Sep 2023 10:50:37 +0530 Subject: [PATCH] [ESP32] Initialize the KVS partition when nvs encryption is enabled (#29280) --- src/platform/ESP32/ConfigurationManagerImpl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/platform/ESP32/ConfigurationManagerImpl.cpp b/src/platform/ESP32/ConfigurationManagerImpl.cpp index 45c1cb9a14021a..188fb75a43e86b 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.cpp +++ b/src/platform/ESP32/ConfigurationManagerImpl.cpp @@ -118,6 +118,15 @@ CHIP_ERROR ConfigurationManagerImpl::Init() err = MapConfigError(esp_err); SuccessOrExit(err); } + + esp_err = nvs_flash_secure_init_partition(CHIP_DEVICE_CONFIG_CHIP_KVS_NAMESPACE_PARTITION, &cfg); + if (esp_err == ESP_ERR_NVS_NO_FREE_PAGES || esp_err == ESP_ERR_NVS_NEW_VERSION_FOUND) + { + ChipLogError(DeviceLayer, "Failed to initialize NVS partition %s err:0x%02x", + CHIP_DEVICE_CONFIG_CHIP_KVS_NAMESPACE_PARTITION, esp_err); + err = MapConfigError(esp_err); + SuccessOrExit(err); + } #else // Initialize the nvs partitions, // nvs_flash_init_partition() will initialize the partition only if it is not already initialized.