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?