Hi everyone, I’m having a strange problem with NVS on my ESP32-S3 (16MB Flash) running ESPHome (ESP-IDF) and I need advice from experts on Memory Mapping
Problem: I performed an OTA firmware update. The OTA process was successful, and the device booted to the correct new version. HOWEVER, all WiFi credentials (SSID/Password) stored in NVS were lost, causing the device to fall into Fallback AP mode. Strangely, the NVS data I saved myself (custom key/value) is still there; only the system WiFi is gone
Partition configuration: I suspect the problem is that my partitions.csv file doesn’t have any spaces (gaps)
# Name, Type, SubType, Offset, Size, Flags
otadata, data, ota, 0x9000, 0x2000,
phy_init, data, phy, 0xb000, 0x1000,
app0, app, ota_0, 0x10000, 0x400000,
app1, app, ota_1, 0x410000,0x400000,
nvs, data, nvs, 0x820000,0x6d000,
app1 (OTA Partition): Terminates at address 0xF90000.
nvs: Starts immediately at address 0xF90000.
Hypothesis: From what I’ve researched, it seems to be due to the Flash erase mechanism (4KB sector erase). When the OTA erases the App partition to write new code, it accidentally erases the first sector of the NVS (because they are close together), damaging the NVS Wifi header.
Question: Is it mandatory to leave a gap (e.g., 64KB) between the App partition and the NVS partition to avoid this error? Or is there another cause?
Thanks everyone!