-
Notifications
You must be signed in to change notification settings - Fork 7.6k
The Preferences function of ESP32-S3-WROOM-1U-N4R8 in USBHID mode does not work. #11284
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
Please post your complete |
Hi thanks for your follow up, here is my [env:simia]
platform = espressif32
board = waveshare_esp32s3_zero
framework = arduino
lib_deps =
ccccraz/simia_embedded@^0.0.2
mathertel/OneButton@^2.6.1 it is pretty simple. I've just built a simple |
I think you want flash_mode to be dio even when memory_type is qio_opi. This behavior of the flash is a symptom of memory misconfiguration. |
Hi, guys. Although I haven't figured out this problem yet, I fixed my problem by moving all the |
Oh, thank you very much for your advice. I'll do a test quickly. |
Make sure that you aren't losing track of the handle in localizing. IE, don't try to re-use a handle/object from outside, keep the nvs handle (aka, the state) completely internal to the class. |
Hi! If my understanding is correct, I modify my board.json to: {
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-DBOARD_HAS_PSRAM",
"-DARDUINO_ESP32S3_DEV",
"-DARDUINO_USB_CDC_ON_BOOT",
"-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "dio",
"hwids": [
[
"0x303A",
"0x1001"
]
],
"mcu": "esp32s3",
"variant": "esp32s3"
},
} then I create a very sample class: #ifndef TMP_H
#define TMP_H
#include <Preferences.h>
class Tmp
{
private:
public:
Preferences tmp_prefs;
const char *tmp_prefs_name = "tmp-app";
const char *tmp_prefs_key = "tmp";
uint32_t value{0};
Tmp();
void getTmp();
~Tmp() = default;
};
Tmp::Tmp()
{
tmp_prefs.begin(tmp_prefs_name, false);
tmp_prefs.putUInt(tmp_prefs_key, 100);
tmp_prefs.end();
}
inline void Tmp::getTmp()
{
tmp_prefs.begin(tmp_prefs_name, true);
value = tmp_prefs.getUInt(tmp_prefs_key, 10);
tmp_prefs.end();
}
#endif // TMP_H and a main func: #include <Arduino.h>
#include "USB.h"
#include "tmp.h"
USBCDC USBSerial;
Tmp tmp{};
void setup()
{
Serial.begin(115200);
Serial.setDebugOutput(true);
tmp.getTmp();
USBSerial.begin();
USB.begin();
}
void loop()
{
while (true)
{
USBSerial.println(tmp.value);
delay(1000);
}
} The verification logic here is: tmp is written with 100 during initialization, and tmp.getTmp() will modify tmp.value to the value written during initialization. So in theory, I should be able to see 100 in the serial monitor. However, the final result is 60, which is the value I wrote during the last test: As you've just added, in this example, the handle of
|
The entry The boards json is fine as it is. NOT the reason for issues. BUT with your platformio.ini you are not using latest actual Arduino core.
|
Ok cool! I will test it tomorrow morning! thanks for your help! |
Board
ESP32-S3-WROOM-1U-N4R8
Device Description
For reference, below is my board.json configuration, and I believe the flash configuration here should be correct:
I don't know where this problem comes from? Maybe it's the USB? Or I made some stupid mistakes in the code that I didn't notice.
Hardware Configuration
GPIO19, GPIO20 directly used as USB signal lines
Version
latest stable Release (if not listed below)
IDE Name
VScode
Operating System
Windows 11
Flash frequency
80Mhz
PSRAM enabled
yes
Upload speed
460800
Description
I am developing a HID project based on the ESP32S3 using platformIO. Everything is going smoothly. However, today when I tried to use Preferences.h to persist some data, I found that I couldn’t do it.
I found a similar issue at #8429, and later I confirmed that the flash of the ESP32-S3-WROOM-1U-N4R8 I am using is operating in qio mode, so the solution in this issue does not work to me.
Sketch
Debug Message
Other Steps to Reproduce
I'm trying to build a minimal example to reproduce this problem.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: