text: /*
   *  Copyright (C) 2020-2021 FotaHub Inc. All rights reserved.
   *
   *  Licensed under the Apache License, Version 2.0 (the "License"); you may
   *  not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *  http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   *  This file is part of the FotaHub(R) Device SDK program (https://fotahub.com)
   */
  #include "NVSDrv.h"
  
  #include "nvs_flash.h"
  #include "esp_err.h"
  
  void nvs_init(void)
  {
    esp_err_t err = nvs_flash_init();
    if (err == ((int32_t)(ESP_ERR_NVS_NO_FREE_PAGES))) 
    {
      ESP_ERROR_CHECK(nvs_flash_erase());
      err = nvs_flash_init();
    }
    ESP_ERROR_CHECK(err);
  }
  