Page 1 of 1

OpenOCD ESP32 - Erase

Posted: Tue Apr 17, 2018 9:33 pm
by fmuller1
Hi all,

I don't know if this is the right section of the forum to post my question, and I apologize in advance if it isn't...
I am using OpenOCD to program my ESP32 Dev Kit. And so far, I seem to do good progress. I am using the openocd_esp32 on the espressif GitHUb (https://github.com/espressif/openocd-esp32).

Now, I am facing an issue when it comes to purely and simply erase the entire flash of the ESP32 using OpenOCD... I've tried a couple of different things (like, for example, -c "esp32 mass_erase 0" like I was used to do with the stm or nordic chips for example); but nothing works... I checked the esp32.c file located in openocd-esp32/src/flash/nor/esp32.c and I've noticed "mass_erase" was implemented unfortunately... But now, I have no idea on how to accomplish a full erase without programming using OpenOCD...

Has anyone an idea on how to do this? It is very important that I use openOCD to do this (because I know that it can be done using the esp_idf with the command make erase_flash; but I must use OpenOCD, so I can't use that other way...)

Thanks!

Re: OpenOCD ESP32 - Erase

Posted: Wed Apr 18, 2018 3:20 am
by ESP_Mahavir
I think it should be possible using `flash erase_sector` command,
flash probe 0
flash erase_sector 0 1 1023
Please note that, sector 0 erase is not supported, protected considering any secure boot related data there. Ref: https://github.com/espressif/openocd-es ... p32.c#L663

Re: OpenOCD ESP32 - Erase

Posted: Wed Apr 18, 2018 8:10 pm
by fmuller1
Hi,

Thanks for your reply.

I've tried.; but it gives me the error:

Code: Select all

invalid subcommand "erase_sector"
This is the exact command I am running, if anyone knows what might be wrong...?

Code: Select all

/usr/local/esp/openocd/bin/openocd -s /usr/local/esp/openocd/share/openocd/scripts \
-f interface/ftdi/jtag_esp32.cfg \
-f target/esp32.cfg \
-c "flash erase_sector 0x1000 exit"
Many thanks!

Re: OpenOCD ESP32 - Erase

Posted: Thu Apr 19, 2018 6:29 am
by ESP_Alexey
fmuller1 wrote:Hi,

Thanks for your reply.

I've tried.; but it gives me the error:

Code: Select all

invalid subcommand "erase_sector"
This is the exact command I am running, if anyone knows what might be wrong...?

Code: Select all

/usr/local/esp/openocd/bin/openocd -s /usr/local/esp/openocd/share/openocd/scripts \
-f interface/ftdi/jtag_esp32.cfg \
-f target/esp32.cfg \
-c "flash erase_sector 0x1000 exit"
Many thanks!
Hi,

You need to run openocd with the following command:

Code: Select all

/usr/local/esp/openocd/bin/openocd -s /usr/local/esp/openocd/share/openocd/scripts \
-f interface/ftdi/jtag_esp32.cfg \
-f target/esp32.cfg \
-c "init; reset halt; flash erase_address 0x1000 4096; exit"
Please, note that 'flash erase_address' and 'flash erase_sector' expect different arguments.
For more information on available OpenOCD flash commands and their parameters please, see http://openocd.org/doc/html/Flash-Comma ... ngcommands

Re: OpenOCD ESP32 - Erase

Posted: Thu Apr 19, 2018 5:28 pm
by fmuller1
Great! This command works like a charm!

Thanks to both for your help!

Re: OpenOCD ESP32 - Erase

Posted: Fri Apr 20, 2018 2:38 pm
by hamishcunningham
Apologies for hijacking, but might you share which device you're using to talk to the ESP over?
(I'd like to get OpenOCD to work with my Adafruit Feather, and understand that I need an adapter
to connect to the JTAG. Would you recommend the one you're using?)

Thanks!

Hamish

Re: OpenOCD ESP32 - Erase

Posted: Sat Apr 21, 2018 6:02 pm
by fmuller1
Hi Hamish,

I am using FT2232H Mini Module to program the ESP32 using openocd_esp32 and the JTAG pins.
Works great for me! But I am using the ESP32-DevKitC, and I am not familiar with the Arduino Feather; so I am unsure of its pin breakout...

Hope that helps!

Re: OpenOCD ESP32 - Erase

Posted: Mon Apr 23, 2018 8:51 am
by hamishcunningham
Thank you!

Re: OpenOCD ESP32 - Erase

Posted: Fri Apr 27, 2018 2:47 am
by meowsqueak
I've also had JTAG debug/flash programming success on the ESP32 with this one:

http://www.ftdichip.com/Support/Documen ... _CABLE.PDF

It's based on the FTDI FT232H device.