OpenOCD ESP32 - Erase

fmuller1
Posts: 4
Joined: Thu Nov 16, 2017 10:07 pm

OpenOCD ESP32 - Erase

Postby fmuller1 » Tue Apr 17, 2018 9:33 pm

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!

ESP_Mahavir
Posts: 190
Joined: Wed Jan 24, 2018 6:51 am

Re: OpenOCD ESP32 - Erase

Postby ESP_Mahavir » Wed Apr 18, 2018 3:20 am

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

fmuller1
Posts: 4
Joined: Thu Nov 16, 2017 10:07 pm

Re: OpenOCD ESP32 - Erase

Postby fmuller1 » Wed Apr 18, 2018 8:10 pm

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!

ESP_Alexey
Posts: 24
Joined: Fri Dec 02, 2016 8:55 pm

Re: OpenOCD ESP32 - Erase

Postby ESP_Alexey » Thu Apr 19, 2018 6:29 am

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

fmuller1
Posts: 4
Joined: Thu Nov 16, 2017 10:07 pm

Re: OpenOCD ESP32 - Erase

Postby fmuller1 » Thu Apr 19, 2018 5:28 pm

Great! This command works like a charm!

Thanks to both for your help!

hamishcunningham
Posts: 11
Joined: Mon Jun 05, 2017 7:50 pm

Re: OpenOCD ESP32 - Erase

Postby hamishcunningham » Fri Apr 20, 2018 2:38 pm

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

fmuller1
Posts: 4
Joined: Thu Nov 16, 2017 10:07 pm

Re: OpenOCD ESP32 - Erase

Postby fmuller1 » Sat Apr 21, 2018 6:02 pm

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!

hamishcunningham
Posts: 11
Joined: Mon Jun 05, 2017 7:50 pm

Re: OpenOCD ESP32 - Erase

Postby hamishcunningham » Mon Apr 23, 2018 8:51 am

Thank you!

meowsqueak
Posts: 151
Joined: Thu Jun 15, 2017 4:54 am
Location: New Zealand

Re: OpenOCD ESP32 - Erase

Postby meowsqueak » Fri Apr 27, 2018 2:47 am

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.

Who is online

Users browsing this forum: No registered users and 380 guests