0

ESP32-C3 No NVS storage (Preferences or SPIFFS)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ESP32-C3 No NVS storage (Preferences or SPIFFS)

by EasyEric on Sun Jun 12, 2022 12:08 am

Hel Forum.

I am using the EP32-C3 Qt-Py board and trying to save some data in NVS using either Preferences or SPIFFS.

1. For Preferences, the sketch example does not work on the ESP32-C3. The counter never increments and appears it is never stored (see output following).

ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x4200d05a
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...

2. For SPIFFS, I've successfully installed the uploader plugin tool which works fine on my TTGO T-Display ESP32 based board, but does not work on the ESP32-C3 QT-Py. The QT-Py (notoriously difficult to get into bootloader mode) gives the following error message when trying to up load SPIFFS:

[SPIFFS] data : C:\Users\Keymaker\Documents\Arduino\ESP32SPIFFS\data
[SPIFFS] start : 2686976
[SPIFFS] size : 1472
[SPIFFS] page : 256
[SPIFFS] block : 4096
/gauge_data.txt

[SPIFFS] upload : C:\Users\Keymaker\AppData\Local\Temp\arduino_build_961277/ESP32SPIFFS.spiffs.bin
[SPIFFS] address: 2686976
[SPIFFS] port : COM25
[SPIFFS] speed : 115200
[SPIFFS] mode : dout
[SPIFFS] freq : 80m

esptool.py v3.0-dev

Serial port COM25

Connecting........_____....._____.....

Traceback (most recent call last):

File "esptool.py", line 3682, in <module>

File "esptool.py", line 3675, in _main

File "esptool.py", line 3330, in main

File "esptool.py", line 515, in connect

File "esptool.py", line 492, in _connect_attempt

File "esptool.py", line 431, in sync

File "esptool.py", line 362, in command

File "site-packages\serial\serialutil.py", line 352, in timeout

File "site-packages\serial\serialwin32.py", line 222, in _reconfigure_port

serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: WindowsError(22, 'The device does not recognize the command.')

Failed to execute script esptool

SPIFFS Upload failed!

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


Has anyone successfully used preferences or SPIFFS with this board? If so, what tricks are necessary to get these NVS storage options to work?

Thanks in adavnce!

EasyEric
 
Posts: 4
Joined: Sat Jun 11, 2022 11:39 pm

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by adafruit_support_mike on Sun Jun 12, 2022 7:16 pm

Post the exact code you’re using (between CODE tags please) and we’ll take a look.

The SPIFFS code is written for an external QSPI Flash memory chip, which the QtPy doesn’t have. I’m not sure what Preferences code you’re using, so that may have the same problem.

adafruit_support_mike
 
Posts: 64984
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by EasyEric on Sun Jun 12, 2022 8:00 pm

Thank you for your reply.

If the SPIFFS is for external memory then that makes sense as the QT Py does not have this.

However, the Preferences library uses internal Non-Volatile Storage (NVS) to emulate EEPROM. The code I used was taken from the example for Preferences from the standard ESP32 libraries found here:

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

This code works fine on other ESP32 boards I have including those without external memory. Any ideas? Is this something peculiar to the C3 version of the ESP32 chip and the RISC-V core?

Thanks in advance.

EasyEric
 
Posts: 4
Joined: Sat Jun 11, 2022 11:39 pm

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by adafruit_support_mike on Mon Jun 13, 2022 5:59 pm

Looking through the ESP32-C3 technical manual:

https://espressif.com/sites/default/fil ... ual_en.pdf

the internal RAM is controlled by a Permissions Control sytem that isn’t documented yet. You’ll probably have the best luck talking to the folks in the Espressif forum:

https://www.esp32.com/viewforum.php?f=23

They’ll have the most recent information.

adafruit_support_mike
 
Posts: 64984
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by EasyEric on Mon Jun 13, 2022 6:11 pm

Thank you for the reply.

This issue impacts Flash which is NVS (Non-Volatile Storage) not RAM.

NVS is data that should survive resets and power-ups and is the same memory where your program code resides. The Preferences and EEprom libraries place data in Flash so it can be saved and retrieved on subsequent resets/power-ups. RAM is volatile and is cleared/erased at power-up or reset.

Still, I'll do some research to see if there is a solution. I can't be the only person with a ESP32-C3 that is having this problem. If any other Adafruit members encounter this issue or have a solution please don't hesitate to share.

Regards.

EasyEric
 
Posts: 4
Joined: Sat Jun 11, 2022 11:39 pm

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by adafruit_support_mike on Mon Jun 13, 2022 10:52 pm

The permissions apply to all internal memory. See the datasheet.

adafruit_support_mike
 
Posts: 64984
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by EasyEric on Sat Jun 18, 2022 2:32 pm

I'm still researching this. It appears it is bug in the routine for the flash programming the the ESP32-C3. I've made the support team over at Espressif aware of this.

I also discovered (and confirmed by Espessif) that SPIFFS is not for external memory as was noted previously. SPIFFS uses the internal FLASH memory of the ESP32,

From https://www.tutorialspoint.com/esp32_for_iot/esp32_for_iot_spiffs_storage.htm: "...Think of SPIFFS as a very small SD Card onboard the ESP32 chip itself. By default, about 1.5 MB of the onboard flash is allocated to SPIFFS. "

This makes sense since the Preference and SPIFFS both use internal Flash memory, they would both fail when attempting to store data using NVS (flash).

So for anyone following this thread, the QT Py ESP32-C3, currently, cannot be used in applications that require Preferences (emulated EEPROM) or SPIFFS.

I'll update once a workaround is determined.

EasyEric
 
Posts: 4
Joined: Sat Jun 11, 2022 11:39 pm

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by adafruit_support_mike on Fri Jun 24, 2022 2:50 pm

Thanks for the follow-up!

adafruit_support_mike
 
Posts: 64984
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by drmpf on Mon Jun 27, 2022 11:59 am

I have been using ESP32-C3 RISC V Developer Board - 4 MB SPI Flash - DevKitC-02 ESP32-C3-WROOM-02 (Product ID: 5337) and the Adafruit QT Py ESP32-C3 (Product ID: 5405).

Using ESP32 board support V3.0.2
EEPROM, SPIFFS and LittleFS all work on the ESP32-C3 RISC V Developer Board - 4 MB SPI Flash board.
SPIFFS and LittleFS fail on Adafruit QT Py ESP32-C3. EEPROM test example runs but EEPROM seems to get lost after next upload, and I have not fully tested the EEPROM retention across power cycles.

So it appears Adafruit QT Py ESP32-C3 is not currently usable for any project that requires a file system/storage.
This should be made clear in the product description as the two boards cost about the same
and the V3.0.2 board support is miss-leading in that multiple partition options list SPIFFS sizes which strongly suggest to the uninformed that this board supports SPIFFS
Attachments
partitions.jpg
partitions.jpg (127.57 KiB) Viewed 186 times

drmpf
 
Posts: 22
Joined: Tue Mar 17, 2015 5:04 am

Re: ESP32-C3 No NVS storage (Preferences or SPIFFS)

by drmpf on Wed Jun 29, 2022 1:08 am

P.S. The example sketches used for testing were the ESP32 examples LITTLEFS_test.ino and SPIFFS_Test.ino.

Also Correction to above the ESP32-C3 board that worked was the ESP32-C3 Mini Development Board with embedded flash
NOT the ESP32-C3 WROOM Development Board with SPI flash as mentioned in my previous post.

So should be directly comparable. This suggest the Adafruit QT Py board is really broken.

drmpf
 
Posts: 22
Joined: Tue Mar 17, 2015 5:04 am

Please be positive and constructive with your questions and comments.