ESP8266 Developer Zone The Official ESP8266 Forum 2021-04-22T22:50:36+08:00 https://bbs.espressif.com:443/feed.php?f=65&t=74898 2021-04-22T22:50:36+08:00 2021-04-22T22:50:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=74898&p=99692#p99692 <![CDATA[Re: cannot read nvs_flash]]> Statistics: Posted by alphasion — Thu Apr 22, 2021 10:50 pm


]]>
2021-04-22T17:18:37+08:00 2021-04-22T17:18:37+08:00 https://bbs.espressif.com:443/viewtopic.php?t=74898&p=99686#p99686 <![CDATA[Re: cannot read nvs_flash]]> Statistics: Posted by Her Mary — Thu Apr 22, 2021 5:18 pm


]]>
2021-04-17T10:42:25+08:00 2021-04-17T10:42:25+08:00 https://bbs.espressif.com:443/viewtopic.php?t=74898&p=99643#p99643 <![CDATA[cannot read nvs_flash]]>

nvs_flash_init()

and write some parameters into nvs

Code:

nvs_handle mHandler;
                  if (nvs_open(WIFI_TAG, NVS_READWRITE, &mHandler) == ESP_OK)
                  {
                     nvs_set_str(mHandler, NVS_SSID, wifi_ssid);
                     nvs_set_str(mHandler, NVS_PASS, wifi_pass);
                     if (nvs_commit(mHandler) == ESP_OK)
                     {
                        i2c_oled_showstr(0, 6, "W");
                     }
                     nvs_close(mHandler);
                  }

but while i try to read this with this code

Code:

nvs_handle mHandler;
   bool ret = false;
   ret = nvs_open(WIFI_TAG, NVS_READONLY, &mHandler);
   ESP_ERROR_CHECK(nvs_get_str(mHandler, NVS_SSID, wifi_ssid, &wifi_ssid_length));
   ESP_ERROR_CHECK(nvs_get_str(mHandler, NVS_PASS, wifi_pass, &wifi_pass_length));
   nvs_close(mHandler);
   return ret;

there is an error :
ESP_ERROR_CHECK failed: esp_err_t 0x110c (ESP_ERR_NVS_INVALID_LENGTH) at 0x40221cd8
could any one tell me where my problem is?thx
btw,my partition table is Single Factory app,no OTA

Statistics: Posted by alphasion — Sat Apr 17, 2021 10:42 am


]]>