How to erase a specific partition? [SOLVED]

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

How to erase a specific partition? [SOLVED]

Postby fly135 » Tue Apr 24, 2018 2:50 pm

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
Last edited by fly135 on Wed Apr 25, 2018 4:25 pm, edited 1 time in total.

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: How to erase a specific partition?

Postby urbanze » Tue Apr 24, 2018 4:07 pm

nvs_flash_erase_partition(const char *part_name)

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: How to erase a specific partition?

Postby fly135 » Tue Apr 24, 2018 4:48 pm

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

chegewara
Posts: 2361
Joined: Wed Jun 14, 2017 9:00 pm

Re: How to erase a specific partition?

Postby chegewara » Wed Apr 25, 2018 3:08 am

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.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: How to erase a specific partition?

Postby fly135 » Wed Apr 25, 2018 3:33 pm

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

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: How to erase a specific partition?

Postby kolban » Wed Apr 25, 2018 4:08 pm

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
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: How to erase a specific partition?

Postby fly135 » Wed Apr 25, 2018 4:23 pm

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
You da man Kolban! That is exactly what I wanted. :D


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 62 guests