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
How to erase a specific partition? [SOLVED]
How to erase a specific partition? [SOLVED]
Last edited by fly135 on Wed Apr 25, 2018 4:25 pm, edited 1 time in total.
Re: How to erase a specific partition?
nvs_flash_erase_partition(const char *part_name)
Re: How to erase a specific partition?
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
John A
Re: How to erase a specific partition?
You can flash to that particular partition with command and use CTRL+C to stop flashing, this should break partition.
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.
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
Or use esp32 flash download tool to do that.
Re: How to erase a specific partition?
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
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?
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
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
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: How to erase a specific partition?
You da man Kolban! That is exactly what I wanted.kolban wrote: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
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
Who is online
Users browsing this forum: No registered users and 94 guests