OTADATA not reset on code upload for ESP32

I am working on doing OTA Updates with my ESP32, I just did a successful test which put the downloaded firmware on OTA_1 and updated the OTADATA partition so that it would boot to OTA_1, but now when I upload code to the ESP32 it gets put to OTA_0 and OTADATA is never reset so it boots into the firmware that was downloaded from the net, and not from the freshly updated code.

So you upload via serial again and it doesn’t boot that firmware? esptool.py erase_flash should resolve it temporarily…

Yes that is correct, how can I modify PIO to do an esptool erase_region call before upload?

Probably through the Advanced Scripting.

This is the sort of stuff you’d want in the script

Import("env", "projenv")
env.AddPreAction("upload", before_upload)
def before_upload(source, target, env):
    print "Performing pre-upload erase..."
    # call esptool erase
    env.Execute("")

I wonder if the problem is a missing bootloader though?

1 Like