How to erase the application directly from... itself?

delamoure
Posts: 5
Joined: Tue Nov 26, 2019 10:12 am

How to erase the application directly from... itself?

Postby delamoure » Tue Nov 26, 2019 10:18 am

Hi there.
Friends, can anybody advice me how to do the application that is able to erase itself in the ESP32-WROOM-32 flash memory, or (and this is better) can bring the ESP32-WROOM-32 to the its default factory state.
I don't ask for a solution, but asking for the advice how is better to do that. And is it possible at all?

ESP_Sprite
Posts: 9769
Joined: Thu Nov 26, 2015 4:08 am

Re: How to erase the application directly from... itself?

Postby ESP_Sprite » Wed Nov 27, 2019 7:56 am

That's a bit of a strange question; what's your end goal with this?

delamoure
Posts: 5
Joined: Tue Nov 26, 2019 10:12 am

Re: How to erase the application directly from... itself?

Postby delamoure » Wed Nov 27, 2019 9:06 am

Why is strange? The goal of this is quite simple.
On some assembled devices I run my own test software. But my customer wants to get the devices (esp32 firmware) in the state like "from factory".
I don't want to disassemble all mechanical parts and erase esp32 by pc connection, because is better to push some key and erase all to the initial state using my firmware. And also don't want to discuss with my customer.
Seems like SPI Flash API is enough for this task. Am I right?

ESP_Sprite
Posts: 9769
Joined: Thu Nov 26, 2015 4:08 am

Re: How to erase the application directly from... itself?

Postby ESP_Sprite » Thu Nov 28, 2019 4:36 am

Well, it's a bit strange that your customers insist on a certain firmware in the flash, especially because 'from the factory' code isn't always useful or up-to-date. Anyway, you could try to use the SPI flash routines, but note that there is a pretty large chance that will fail: the ESP32 executes code directly from flash (via XIP) and erasing the flash would erase your running program as well. You can try to work around this by putting relevant routines in IRAM instead, but I'm not sure if it's possible to put enough code in IRAM to do what you need to do.

delamoure
Posts: 5
Joined: Tue Nov 26, 2019 10:12 am

Re: How to erase the application directly from... itself?

Postby delamoure » Thu Nov 28, 2019 8:50 am

Can you please tell me, Core 0 is APP_CPU or PRO_CPU?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: How to erase the application directly from... itself?

Postby WiFive » Thu Nov 28, 2019 9:10 am

Flash erase commands are already in iram and chip erase is a single command so I don't see why not. It doesn't get you back to factory firmware though. Also doesn't really make sense that the customer will then have to disassemble the devices to flash them.

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

Re: How to erase the application directly from... itself?

Postby chegewara » Thu Nov 28, 2019 11:55 am

Maybe its some misunderstanding here, what exactly "factory reset" means? Is it reset to state esp32 module is leaving factory or your device is leaving factory and is sent to client?

delamoure
Posts: 5
Joined: Tue Nov 26, 2019 10:12 am

Re: How to erase the application directly from... itself?

Postby delamoure » Thu Nov 28, 2019 12:02 pm

The buffers are disabled for both cores. Interrupts also disabled. I working from IRAM now. Most of all I'll try to easy write to the SPI via registers. Because spi_flash functions are not working now for some reason. As for customers... When we have "stupid" task we have to do it like any other task. Thanks alot for answers :)

p.s. Now the task is to erase application in the ESP32 flash.

Who is online

Users browsing this forum: Baidu [Spider], REEASD, snutw_ and 145 guests