Skip to content

ESP32-C3 Preferences: nvs_get_blob len fail: schedule NOT_FOUND #6572

Closed
@Sys64736

Description

@Sys64736

Board

ESP32-C3 Devkitc

Device Description

Nothing attached

Hardware Configuration

Nothing attached

Version

latest master

IDE Name

PIO

Operating System

Win10

Flash frequency

80

PSRAM enabled

no

Upload speed

115200

Description

Preferences e.g. code giving error in latest release. Works in 2.0.2

I also can't format or mount SPIFFS on a C3 but I believe that is fixed in PR #6569 ?
Returning err -1

Sketch

https://github.com/espressif/arduino-esp32/blob/master/libraries/Preferences/examples/Prefs2Struct/Prefs2Struct.ino

Debug Message

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xf (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6a8
load:0x403d0000,len:0x2358
SHA-256 comparison failed:
Calculated: 4ab8657f6f5aa80b81c7dd649db3bd64a98999ed7c65acc5a2ab77ce80caf525
Expected: 6babbc7b9ea63e04e0fc89ec224f6268aa3f84392018f73ab33721f768ce2eb6
Attempting to boot anyway...
entry 0x403ce000
[   106][E][Preferences.cpp:503] getBytesLength(): nvs_get_blob len fail: schedule NOT_FOUND
[   106][E][Preferences.cpp:503] getBytesLength(): nvs_get_blob len fail: schedule NOT_FOUND
09:30 235/255
[   122][E][Preferences.cpp:503] getBytesLength(): nvs_get_blob len fail: schedule NOT_FOUND
[   123][E][Preferences.cpp:503] getBytesLength(): nvs_get_blob len fail: schedule NOT_FOUND

Other Steps to Reproduce

Just running example code

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Activity

lbernstone

lbernstone commented on Apr 13, 2022

@lbernstone
Contributor

There is no error checking in that example. It seems likely that the NVS is unable to either open the namespace or is completely full. Erase your flash and try again.

Sys64736

Sys64736 commented on Apr 13, 2022

@Sys64736
Author

I've erased the flash a few times before that, changed partition to default and made sure it was. Tried on 3 different chips, 2 devkits and 1 Lolin mini.
I noticed it as I updated to the latest from 2.0.2, my current project was giving errors with the EEPROM routine that I had with 2.0.3rc1, so I changed the 3 routines I was using to the Preferences library thinking because it was deprecated it might make a difference. Still errors. In my project now, it's working in 2.0.2 it writes and reads to the key no problem but with 2.0.3RC1 it doesn't write to the key.

Before I swapped out the EEPROM library routines to use Preferences, this is the error I was getting when I updated from 2.0.2 to 2.0.3rc1

assert failed: esp_err_t nvs::Page::copyItems(nvs::Page&) nvs_page.cpp:500 (end <= ENTRY_COUNT)
Core 0 register dump:
Then reboot.

I tried to use the exception decoder but even after trying 3 different versions of the Arduino IDE installed, I couldn't get it to work. It was pretty clear it was something to do with nvs though.

Let me know if there's anything else I can do

Sys64736

Sys64736 commented on Apr 13, 2022

@Sys64736
Author

Just an fyi, I don't know if this has anything to do with the fact the same project does not mount the SPIFFS partition either. I even tried the example SPIFFS code in PIO and ArduinoIDE. Both give same result:

Attempting to boot anyway...entry 0x403ce000E (180) SPIFFS: mount failed, -10025E (15468) SPIFFS: mount failed, -10025[ 15431][E][SPIFFS.cpp:114] format(): Formatting SPIFFS failed! Error: -1[ 15432][E][SPIFFS.cpp:89] begin(): Mounting SPIFFS failed! Error: -1SPIFFS Mount Failed

I almost thought the flash got permanently corrupted on the boards somehow because both SPIFFS and nvs were giving me problems but reverting back to 2.0.2 everything works as it should.

Sys64736

Sys64736 commented on Apr 13, 2022

@Sys64736
Author

Probably unrelated but I noticed the config folder and the containing sdkconfig.h is missing in latest from .../tools/sdk/esp32c3/include/

lbernstone

lbernstone commented on Apr 13, 2022

@lbernstone
Contributor

Make sure to run tools/get.py (but I think you would get much nastier compilation errors if this was the problem). I am unable to reproduce the problem with Preferences or SPIFFS with a new esp32-c3 board that I grabbed out of the box.

Sys64736

Sys64736 commented on Apr 14, 2022

@Sys64736
Author

Thanks. my ESP32 works with Pref and SPIFFS examples, but my C3's still gives same errors. Reverted back again to 2.0.2 to double check and both examples ran fine on C3. It's back to the latest now and trying a few different things, It's prob some config thing I'm doing wrong. I'll post back in a bit as soon as I figure out what's going on.

lbernstone

lbernstone commented on Apr 14, 2022

@lbernstone
Contributor

Did you perhaps have encryption turned on at some point? I can't think of what else would cause your nvs to fail. Try the following and see if you get some more info about what failed.

#include <nvs_flash.h>
void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("testing nvs");
  nvs_handle_t hnd;
  esp_err_t err = nvs_flash_init();
  if (err) log_e("NVS Init Error: %s", esp_err_to_name(err));
  err = nvs_open("schedule", NVS_READWRITE, &hnd);
  if (err) log_e("Namespace Open Error: %s", esp_err_to_name(err));
  err = nvs_set_str(hnd, "test_str", "testing123");
  if (err) log_e("Set String Error: %s", esp_err_to_name(err));
  err = nvs_commit(hnd); 
  if (err) log_e("NVS Commit Error: %s", esp_err_to_name(err));
  size_t sz;
  err = nvs_get_str(hnd, "test_str", NULL, &sz);
  if (err) log_e("Get String Error: %s", esp_err_to_name(err));
  char* buff = (char*)malloc(sz * sizeof(char));
  err = nvs_get_str(hnd, "test_str", buff, &sz);
  if (err) log_e("Get String Error: %s", esp_err_to_name(err));
  Serial.printf("Retrieved String: %s", buff);
  nvs_close(hnd);
}
void loop() {delay(-1);}
Sys64736

Sys64736 commented on Apr 14, 2022

@Sys64736
Author

Thanks, the only encryption I had was encrypted flags in a custom partition for later use but no fuses set or any follow up on those flags.

Chips have all been erased and set with default partitions since then and operate normally until the commit mentioned below.

After a few branch changes, I found the one which is causing my issues.

Commit 8ee5f0a is causing the issues for me with SPIFFS and Preferences.

Running the code you posted with Esp32 s3 support (#6341): 8ee5f0a

Attempting to boot anyway...
entry 0x403ce000
testing nvs
[  1109][E][main.cpp:19] setup(): Get String Error: ESP_ERR_NVS_NOT_FOUND
[  1110][E][main.cpp:22] setup(): Get String Error: ESP_ERR_NVS_NOT_FOUND
Guru Meditation Error: Core  0 panic'ed (Load access fault). Exception was unhandled.

Core  0 register dump:
MEPC    : 0x40058eb6  RA      : 0x42019268  SP      : 0x3fc92a60  GP      : 0x3fc8b000
TP      : 0x3fc88e78  T0      : 0x403894e6  T1      : 0x3fc92b2c  T2      : 0xffffffff  
S0/FP   : 0x00000000  S1      : 0x00000001  A0      : 0x00000000  A1      : 0xffffffff
A2      : 0x00000001  A3      : 0x7f7f7f7f  A4      : 0x00000000  A5      : 0x00000004  
A6      : 0x3fe00000  A7      : 0x0000000a  S2      : 0x00000000  S3      : 0x3fc93100
S4      : 0x3fc92e98  S5      : 0x00000009  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x3c030262  S9      : 0x00000000  S10     : 0x3fc92b34  S11     : 0xffffffff
T3      : 0x00000000  T4      : 0x00000000  T5      : 0x00000000  T6      : 0x00000000  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000005  MTVAL   : 0x00000000
MHARTID : 0x00000000

Below is running it with the commit just before S3 support 3f79097

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6a8
load:0x403d0000,len:0x2370
SHA-256 comparison failed:
Calculated: 912c8ece44dc10c27ac7d0fbc21c881181838b5f87f42e05d6797a997e755775
Expected: e48257ed72b4ed90fbd1c7429f3866f76aab94952c8871b8e364f6e503cebde8
Attempting to boot anyway...
entry 0x403ce000
testing nvs
Retrieved String: testing123

Same for the example code with SPIFFS and Preferences.

There's many files changed in Esp32 s3 support (#6341), but I'm thinking it's a library that's common to SPIFFS & nvs maybe? It's like it can't find the partitions anymore

Sys64736

Sys64736 commented on Apr 17, 2022

@Sys64736
Author

@lbernstone I think I've tried everything I can think of. Still getting the bootloop with the ESP32-C3-DevKitC-02 and the Lolin C3 Mini.
The Mini was brand new out of the package.
Output running the nvs sample code you gave with RC-1 & Lolin_c3_mini (brand new)

SHA-256 comparison failed:
Calculated: 4ab8657f6f5aa80b81c7dd649db3bd64a98999ed7c65acc5a2ab77ce80caf525
Expected: 6babbc7b9ea63e04e0fc89ec224f6268aa3f84392018f73ab33721f768ce2eb6
Attempting to boot anyway...
entry 0x403ce000
testing nvs
[  1130][E][main.cpp:19] setup(): Get String Error: ESP_ERR_NVS_NOT_FOUND
[  1130][E][main.cpp:22] setup(): Get String Error: ESP_ERR_NVS_NOT_FOUND
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x40381782
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6a8
load:0x403d0000,len:0x2358
SHA-256 comparison failed:
Calculated: 4ab8657f6f5aa80b81c7dd649db3bd64a98999ed7c65acc5a2ab77ce80caf525
Expected: 6babbc7b9ea63e04e0fc89ec224f6268aa3f84392018f73ab33721f768ce2eb6
Attempting to boot anyway...
entry 0x403ce000
testing nvs
[  1136][E][main.cpp:19] setup(): Get String Error: ESP_ERR_NVS_NOT_FOUND
[  1136][E][main.cpp:22] setup(): Get String Error: ESP_ERR_NVS_NOT_FOUND
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)

Running the ESP32-C3-DevKitC-02 I get similar (not new but erased flash and using default.csv partition) with RC-1

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x40381782
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6a8
load:0x403d0000,len:0x2358
SHA-256 comparison failed:
Calculated: 4ab8657f6f5aa80b81c7dd649db3bd64a98999ed7c65acc5a2ab77ce80caf525
Expected: 6babbc7b9ea63e04e0fc89ec224f6268aa3f84392018f73ab33721f768ce2eb6
Attempting to boot anyway...
entry 0x403ce000
testing nvs
[  1154][E][main.cpp:19] setup(): Get String Error: ESP_ERR_NVS_NOT_FOUND
[  1154][E][main.cpp:22] setup(): Get String Error: ESP_ERR_NVS_NOT_FOUND
Guru Meditation Error: Core  0 panic'ed (Load access fault). Exception was unhandled.

Core  0 register dump:
MEPC    : 0x40058eb6  RA      : 0x42019360  SP      : 0x3fc92a70  GP      : 0x3fc8b000
TP      : 0x3fc88e38  T0      : 0x403894e6  T1      : 0x3fc92b3c  T2      : 0xffffffff  
S0/FP   : 0x00000000  S1      : 0x00000001  A0      : 0x00000000  A1      : 0xffffffff
A2      : 0x00000001  A3      : 0x7f7f7f7f  A4      : 0x00000000  A5      : 0x00000004  
A6      : 0x3fe00000  A7      : 0x0000000a  S2      : 0x00000000  S3      : 0x3fc93110
S4      : 0x3fc92ea8  S5      : 0x00000009  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x3c030262  S9      : 0x00000000  S10     : 0x3fc92b44  S11     : 0xffffffff
T3      : 0x00000000  T4      : 0x00000000  T5      : 0x00000000  T6      : 0x00000000  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000005  MTVAL   : 0x00000000
MHARTID : 0x00000000

I thought it was an issue finding the partitions but running this code with RC-1, partitions are found on both boards.

/* Finding Partitions Example
   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include <Arduino.h>


void getPartionTableInfo()
{
	// Get Partitionsizes
	size_t ul;
	esp_partition_iterator_t _mypartiterator;
	const esp_partition_t *_mypart;
	ul = spi_flash_get_chip_size();
  Serial.println("\n------------------------------------");
	Serial.print("Flash chip size: ");
	Serial.println(ul);  
	Serial.println("Partition table:");
  Serial.println("------------------------------------");
	_mypartiterator = esp_partition_find(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, NULL);
	if (_mypartiterator)
	{
		Serial.println("App Partition table:");
		do
		{
			_mypart = esp_partition_get(_mypartiterator);
			printf("Type: %02x SubType %02x Address 0x%06X Size 0x%06X Encryption %i Label %s\r\n", _mypart->type, _mypart->subtype, _mypart->address, _mypart->size, _mypart->encrypted, _mypart->label);
		} while (_mypartiterator = (esp_partition_next(_mypartiterator)));
	}
	esp_partition_iterator_release(_mypartiterator);
	_mypartiterator = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, NULL);
	if (_mypartiterator)
	{
		Serial.println("Data Partition table:");
		do
		{
			_mypart = esp_partition_get(_mypartiterator);
			printf("Type: %02x SubType %02x Address 0x%06X Size 0x%06X Encryption %i Label %s\r\n", _mypart->type, _mypart->subtype, _mypart->address, _mypart->size, _mypart->encrypted, _mypart->label);
		} while (_mypartiterator = (esp_partition_next(_mypartiterator)));
	}
	esp_partition_iterator_release(_mypartiterator);
}

void setup(){
  Serial.begin(115200);
  while (!Serial) {}
  delay(1000); // delay needed with lolin_c3_mini(no uart chip) because 
               // while(!serial) still missed serial printing flash chip size.
               
 getPartionTableInfo();
}

void loop(){
}

OUTPUT for DevkitC using RC-1

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xf (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6a8
load:0x403d0000,len:0x2358
SHA-256 comparison failed:
Calculated: 4ab8657f6f5aa80b81c7dd649db3bd64a98999ed7c65acc5a2ab77ce80caf525
Expected: 6babbc7b9ea63e04e0fc89ec224f6268aa3f84392018f73ab33721f768ce2eb6  
Attempting to boot anyway...
entry 0x403ce000

------------------------------------
Flash chip size: 4194304
Partition table:
------------------------------------
App Partition table:
Type: 00 SubType 10 Address 0x010000 Size 0x140000 Encryption 0 Label app0
Type: 00 SubType 11 Address 0x150000 Size 0x140000 Encryption 0 Label app1
Data Partition table:
Type: 01 SubType 02 Address 0x009000 Size 0x005000 Encryption 0 Label nvs
Type: 01 SubType 00 Address 0x00E000 Size 0x002000 Encryption 0 Label otadata
Type: 01 SubType 82 Address 0x290000 Size 0x170000 Encryption 0 Label spiffs

Output for Lolin mini using RC-1

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on COM15  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

------------------------------------
Flash chip size: 4194304
Partition table:
------------------------------------
App Partition table:
Type: 00 SubType 10 Address 0x010000 Size 0x140000 Encryption 0 Label app0   
Type: 00 SubType 11 Address 0x150000 Size 0x140000 Encryption 0 Label app1   
Data Partition table:
Type: 01 SubType 02 Address 0x009000 Size 0x005000 Encryption 0 Label nvs    
Type: 01 SubType 00 Address 0x00E000 Size 0x002000 Encryption 0 Label otadata
Type: 01 SubType 82 Address 0x290000 Size 0x170000 Encryption 0 Label spiffs

So, not sure what's going on. 'Almost' everything else on RC-1 works on these boards, I say almost because I have a project I tried running with these boards on the latest and it uses many of Ard/esp32 libraries and it it all works. Webserver, Ledc, http client, wifi using STA + AP etc. Only the SPIFFS and NVS(Preferences) issues are present ( I didn't try LittleFS though).

If you or anyone has any ideas, please let me know if there's something I could try. The fixes/additions in RC-1 are very helpful, especially the USB/Seria/JTAG support for the Lolin mini which doesn't have a uart chip.

Edit: It's getting past the nvs init and nvs commit functions without error, returning zero and a handle of 1.
Returning ESP_ERR_NVS_NOT_FOUND on the nvs_get_str() function only. If it was a nvs_open_mode_t problem I would think it would error before that?
Tried PR #6585 [IDF release/v4.4], still the same.

46 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions

    ESP32-C3 Preferences: nvs_get_blob len fail: schedule NOT_FOUND · Issue #6572 · espressif/arduino-esp32