ESP32-C3 Preferences and NVS storage not work

EasyEric
Posts: 3
Joined: Mon Jun 13, 2022 11:26 pm

ESP32-C3 Preferences and NVS storage not work

Postby EasyEric » Mon Jun 13, 2022 11:46 pm

Hello,

I have a Adafruit QT Py ESP32-C3 development board. I am trying to save data between resets by using flash (NVS) to store data.

Using the ESP Preferences library example ( https://github.com/espressif/arduino-es ... ounter.ino) I get the following output:

Code: Select all

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x403816f2
SPIWP:0xee
mode:DOUT, clock div:1
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6ac
load:0x403d0000,len:0x2464
SHA-256 comparison failed:
Calculated: ae4b6389c51bca37025d68f98f30f6e4b83b375cef091401f27fa9596bdb9ddf
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x403ce000

Current counter value: 1
Restarting in 10 seconds...
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x403816f2
SPIWP:0xee
mode:DOUT, clock div:1
load:0x3fcd6100,len:0x38c
load:0x403ce000,len:0x6ac
load:0x403d0000,len:0x2464
SHA-256 comparison failed:
Calculated: ae4b6389c51bca37025d68f98f30f6e4b83b375cef091401f27fa9596bdb9ddf
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x403ce000

Current counter value: 1
Restarting in 10 seconds...
As you can see, the counter should increase on each successive reboot but it does not. This sketch works on the other standard ESP32 boards I have. Is this something peculiar to the C3 version of the ESP32 chip and the RISC-V core?

Please help! I need to store data for the project i am working on.

Thanks!

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32-C3 Preferences and NVS storage not work

Postby lbernstone » Tue Jun 14, 2022 5:55 am

I think there is an issue with the double speed flash modes in v2.0.3. Is there a reason you can't set the flash mode to QIO?

EasyEric
Posts: 3
Joined: Mon Jun 13, 2022 11:26 pm

Re: ESP32-C3 Preferences and NVS storage not work

Postby EasyEric » Tue Jun 14, 2022 11:53 am

Setting the Flash mode to QIO worked!

Just out of curiosity What is the difference between DOUT and QIO?

Thank you so much. I've been searching the web for days looking for a solution. It is people like you that make these forums so valuable.

Regards.

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32-C3 Preferences and NVS storage not work

Postby lbernstone » Tue Jun 14, 2022 6:49 pm

First hit on Google. https://www.totalphase.com/blog/2020/05 ... -quad-spi/
If you use dual, you can recover 2 gpio for use, but cut the transfer rate to the flash (and psram if you have it) in half.
Note that your problem is a bug. I have reported it so that DIO will work in the next version.

EasyEric
Posts: 3
Joined: Mon Jun 13, 2022 11:26 pm

Re: ESP32-C3 Preferences and NVS storage not work

Postby EasyEric » Tue Jun 14, 2022 8:28 pm

It's definitely a bug.

I've discovered that it is hit or miss using the QIO mode. Sometimes it works, others, it goes into a recurring reset mode where the chip continually resets itself. To get out of that mode, I have to remove and re-apply power, put the board in bootloader mode and then upload using DOUT. So I may not have made real progress.

I'll experiment with flash modes and flash frequencies to see if I can find something workable.

Once again thanks for your help. Please feel free to post any updates you find or techniques you can suggest.

Regards.

Who is online

Users browsing this forum: No registered users and 55 guests