From 05dd46cd7299a6315a953ce5f13fbb6659cd0bbb Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 20 Nov 2017 16:07:52 +1100 Subject: [PATCH] udp_perf/tcp_perf examples: Erase NVS if no more free pages Follows same pattern as other examples. Amendment to https://github.com/espressif/esp-idf/pull/1279 --- examples/performance/tcp_perf/main/tcp_main.c | 8 +++++++- examples/performance/udp_perf/main/udp_main.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/performance/tcp_perf/main/tcp_main.c b/examples/performance/tcp_perf/main/tcp_main.c index c96b0d02b..000ed6d42 100644 --- a/examples/performance/tcp_perf/main/tcp_main.c +++ b/examples/performance/tcp_perf/main/tcp_main.c @@ -124,7 +124,13 @@ static void tcp_conn(void *pvParameters) void app_main(void) { - nvs_flash_init(); + esp_err_t ret = nvs_flash_init(); + if (ret == ESP_ERR_NVS_NO_FREE_PAGES) { + ESP_ERROR_CHECK(nvs_flash_erase()); + ret = nvs_flash_init(); + } + ESP_ERROR_CHECK( ret ); + #if EXAMPLE_ESP_WIFI_MODE_AP ESP_LOGI(TAG, "EXAMPLE_ESP_WIFI_MODE_AP"); wifi_init_softap(); diff --git a/examples/performance/udp_perf/main/udp_main.c b/examples/performance/udp_perf/main/udp_main.c index cad32a813..8bbd05ff0 100644 --- a/examples/performance/udp_perf/main/udp_main.c +++ b/examples/performance/udp_perf/main/udp_main.c @@ -103,7 +103,13 @@ static void udp_conn(void *pvParameters) void app_main(void) { - nvs_flash_init(); + esp_err_t ret = nvs_flash_init(); + if (ret == ESP_ERR_NVS_NO_FREE_PAGES) { + ESP_ERROR_CHECK(nvs_flash_erase()); + ret = nvs_flash_init(); + } + ESP_ERROR_CHECK( ret ); + #if EXAMPLE_ESP_WIFI_MODE_AP ESP_LOGI(TAG, "EXAMPLE_ESP_WIFI_MODE_AP"); wifi_init_softap();