Closed fulvioalessio closed 1 year ago
Hi Fulvio,
I tested your corrected code on a node32s and it works as expected for me without any changes, but I suggest you to modify it to follow the instructions in the README for ESP32 processors:
... ESP8266, ESP32 and RISC-V caveat
Since ESP8266, ESP32 and RISC-V processor boards simulate EEPROM using a RAM buffer and FLASH EPROM, they needs same sort of begin call before reading or writing the EEPROM. This code is embedded into the begin method of EEWL. This means that EEWL::begin must be called before any other EEWL method.
Moreover, if multiple instances of EEWL are used and/or if other program parts needs their own EEPROM buffer, an explicit EEPROM begin call must be put in the application before any access to the EEPROM. This must be done defining the symbol EEPROM_PROGRAM_BEGIN before any include involving the EEPROM and with the call EEPROM.begin(
AVR processor boards have a true EEPROM, so they do not need any EEPROM begin and multiple instances of EEWL and/or other program parts using EEPROM do not need any special provision to coexist in the same program. ...
Hi Fabrizio, before your answer I've tried to change at little your library introducing a init(size) method, without working with defines:
` void init(int eepromSize=0) {
#if !defined(EEWL_RAM) && !defined(__AVR__)
if (eepromSize > 0) {
Serial.print("begin ");
Serial.println(eepromSize);
EEPROM.begin(eepromSize);
}
#endif
} `
With processors that need specific initialization, the change could be simple, while on AVR the code remains as it is now. What do you think ?
Thanks, Fulvio
Hi Fulvio, I automated the management of multiple instances for 32 bits CPUs (v. 0.6.0). You can try it to help me in some debug :) .
Fabrizio
Hi Fabrizio, trying with esp32s2 seems to work :)
-- power cycles = 2 power cycles2 = 2
--> reset
power cycles = 3 power cycles2 = 3
Only one thing: I receive these warning compiling under platformio:
Thanks, Fulvio
Hi,
I have some problems with multiple EEWL objects, the same problem occour with arduino nano and esp32.
I've replicated the problem with this code, derived from countPowerCycles:
Here the output: 1st reset:
2nd reset:
3rd reset:
If I try original powerCycles.ino code, the "powerCycles" variable is incremented correctly. I've tried to comment "pC2.begin();", without success.
UPDATE: found an error on code, corrected. With nano the code works, with esp32 the problem persists.