Automatically erase or repair NVS partition if corrupt
Jaguar doesn't behave very well if the NVS partition becomes corrupt. We've seen it fail in the flash_kv_init primitive, so maybe we can catch that error and clear the NVS partition? Maybe that is too much, but let's consider it.
My guess would be that somehow the NVS partition has become corrupt. Maybe Jaguar needs to handle that and erase the partition? Or maybe it should report it in a nicer way so it is possible for the user to erase the flash manually.
Originally posted by @kasperl in https://github.com/toitlang/toit/issues/458#issuecomment-1041179543
In the meantime here are work-arounds to get into a good state again:
According to https://esp32.com/viewtopic.php?t=15530 calling idp.py -p PORT_NUMBER erase_flash should erase the NVS Flash.
Alternatively one could write the following Arduino program and run it:
#include <nvs_flash.h>
void setup() {
nvs_flash_erase();
}
void loop() {
delay(3000);
}