Page 1 of 1
How to erase a specific partition? [SOLVED]
Posted: Tue Apr 24, 2018 2:50 pm
by fly135
Now that I have OTA working, there are times when I need to boot from the factory partition. Like when I create a new build that crashes before I can OTA a new build. I'd like to be able to erase just the OTADATA partition because I don't want to lose what's in the NVS. I took a look at esptool.py and quickly realized that it might be a lot easier if someone already knew the answer.
John A
Re: How to erase a specific partition?
Posted: Tue Apr 24, 2018 4:07 pm
by urbanze
nvs_flash_erase_partition(const char *part_name)
Re: How to erase a specific partition?
Posted: Tue Apr 24, 2018 4:48 pm
by fly135
Thanks, but I'm talking about erasing it with esptool so that I can bring back the factory partition to burn a new image.
John A
Re: How to erase a specific partition?
Posted: Wed Apr 25, 2018 3:08 am
by chegewara
You can flash to that particular partition with command and use CTRL+C to stop flashing, this should break partition.
Code: Select all
python /d/msys/home/admin/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x100000 /d/vbox/ubuntu/examples/hid/esp32-ota-with-ble-setup/build/bootloader/bootloader.bin
Its just example and better to use make to print this command then change 0x100000 to match your partition start address.
Or use esp32 flash download tool to do that.
Re: How to erase a specific partition?
Posted: Wed Apr 25, 2018 3:33 pm
by fly135
Thanks, I'll check out the flash tool. I haven't used that.
edit: Checked out flash tool. Not obvious that you can erase a specific section of the flash. Looks as though you can just erase the whole flash.
edit: From looking at the make command it appears that I need to make a file that's the size of the OTADATA partition filled with 0xFF. Otherwise it's unclear how to tell it to erase the partition. There is nothing in the make command that says how much to erase.
John A
Re: How to erase a specific partition?
Posted: Wed Apr 25, 2018 4:08 pm
by kolban
Howdy,
Have a look at the following link ... it appears that the esptool subcommand "erase_region" might do the trick:
https://github.com/espressif/esptool#erasing-flash
Re: How to erase a specific partition?
Posted: Wed Apr 25, 2018 4:23 pm
by fly135
You da man Kolban! That is exactly what I wanted.
This is the command I used to erase this partition...
/esp-idf/components/esptool_py/esptool/esptool.py --port com3 erase_region 0xd000 0x2000
otadata, data, ota, 0xd000, 0x2000
John A