nvs: check that storage has at least one free page
This change adds a check for the free page count to nvs_flash_init. Under normal operation, NVS keeps at least one free page available, except for transient states such as freeing up new page. Due to external factors (such as NVS partition size reduction) this free page could be lost, making NVS operation impossible. Previously this would cause an error when performing any nvs_set operation or opening a new namespace. With this change, an error is returned from nvs_flash_init to indicate that NVS partition is in such a state.
This commit is contained in:
@@ -105,6 +105,11 @@ esp_err_t PageManager::load(uint32_t baseSector, uint32_t sectorCount)
|
||||
}
|
||||
}
|
||||
|
||||
// partition should have at least one free page
|
||||
if (mFreePageList.size() == 0) {
|
||||
return ESP_ERR_NVS_NO_FREE_PAGES;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user