Esp32Platform reinitializing EEPROM multiple times causing it to forget staged EEPROM changes#196
Conversation
|
this was already discussed and adressed here: ESP (not only ESP32) Plattform should also be fixed. |
|
Ah, ok, good to know. |
…times causing it to forget staged EEPROM changes
|
Changed the check for the EEPROM initialization to a null pointer check. |
|
hmmmm. wouldn't you think using the arg size is the better option (KNX_FLASH_SIZE could also be undef) ? |
|
Merged. The argument can be changed with a different PR as this one fixes a critical issue for esp* |
|
You're right. I only noticed this after the next PR. Sorry. |
For the ESP32, you cannot call EEPROM.begin(size) multiple times, and get the same data buffer back. Each call re-creates the in-memory data array mirror of the flash contents. The ESP32 arduino library the code is clearing EEPROM emulation data array is here;
https://github.com/espressif/arduino-esp32/blob/02c3ec01cca90d3b84398791656599d8cb3bb668/libraries/EEPROM/src/EEPROM.cpp#L128
The result is that when loading a program from ETS doesn't work because it calls Esp32Platform::getEepromBuffer() several times (calling EEPROM.begin(size)), causing it for forget all previously changed bytes.
Ideally we should could use the .length() to determine if the EEPROM was initialized properly.
However this was broken until quite recently espressif/arduino-esp32#5775 (requiring v2.0.1+), therefore I just put a simple guard around the begin.