Skip to content

Commit

Permalink
Restored nvs_flash_init
Browse files Browse the repository at this point in the history
  • Loading branch information
nopnop2002 committed Dec 17, 2024
1 parent 02045d9 commit d9f927f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2337,7 +2337,7 @@ esp_err_t mountSPIFFS(char * path, char * label, int max_files) {
.base_path = path,
.partition_label = label,
.max_files = max_files,
.format_if_mount_failed =true
.format_if_mount_failed = true
};

// Use settings defined above to initialize and mount SPIFFS filesystem.
Expand Down Expand Up @@ -2381,6 +2381,18 @@ esp_err_t mountSPIFFS(char * path, char * label, int max_files) {

void app_main(void)
{
// Initialize NVS
// NVS saves the touch position calibration.
ESP_LOGI(TAG, "Initialize NVS");
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// NVS partition was truncated and needs to be erased
// Retry nvs_flash_init
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
ESP_ERROR_CHECK( err );

ESP_LOGI(TAG, "Initializing SPIFFS");
// Maximum files that could be open at the same time is 10.
ESP_ERROR_CHECK(mountSPIFFS("/fonts", "storage0", 10));
Expand Down

0 comments on commit d9f927f

Please sign in to comment.