-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Preferences getString fails even when provided default value on one particular board?! #11319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Maybe it can't read the flash. If you set logging to verbose (-DCORE_DEBUG_LEVEL=5) you should get more info. |
It can read flash. For instance I have boot counter that is stored in NVS, when it boot it reads it, adds 1, and stores it back. That works, the number is increasing. Debug info reads: rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) CPU0 reset reason: (0x0C) Software reset CPU When uploading esptool prints: chip_id prints: |
You've got a lot of places that are calling nvs_get_str, it would be helpful if you pin down which of those is throwing the error. |
My bad ... Function works. I had some other problem with the board and the last message I saw in the terminal was from preferences library, so I assumed it was causing problems. My apologies. |
Board
GOOUUU-ESP32
Device Description
It is development board bought from Aliexpress with ESP32 "classic" MCU on it.
Name of the board printed on the PCB is "GOOUUU-ESP32" (38-pin).
Nothing special on the board, no LCD, no card slot, nothing.
Hardware Configuration
Nothing is attached
Version
latest stable Release (if not listed below)
IDE Name
VSCode + PlatformIO
Operating System
Fedora Linux 41
Flash frequency
not sure, default for the board
PSRAM enabled
yes
Upload speed
921600
Description
Same code to access values stored in NVS memory works on numerous different development boards and MCUs (ESP8266, ESP32 classic, ESP32C3, etc.) but fails on this one particular development board (also based on ESP32 classic).
Name of the board printed on the PCB is "GOOUUU-ESP32" (38-pin).
At first run (or until some values are created in NVS), they, obviously, don't exist.
So to read the string value from NVS I used preferences.getString function with the default value of String("").
I would then check if string I got back was "" and if it was I would provide some default value or whatever.
On multiple development boards that worked just fine but on this one I get an error:
"[ 49][E][Preferences.cpp:483] getString(): nvs_get_str len fail: deviceName NOT_FOUND".
It is true that the key "deviceName" doesn't exist yet, but why function does not simply return the default value of String("")?
Sketch
Debug Message
Other Steps to Reproduce
Getting string value (or the default one) from NVS that doesn't yet exist by calling Preferences.getString with default value works on these boards, to name the few:
Everything else, the code, IDE, tool chain is the same.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: