Sonoff erase flash?

1,757 views
Skip to first unread message

Bernard T

unread,
Mar 13, 2017, 6:39:27 AM3/13/17
to SonoffUsers
Anyone know of a way to erase the flash on the board, It looks like it is only overwritten when uploading sketches. If you upload a different sketch to the esp, then load the sonoff sketch again, the details ie config/settings remain intact. So you can't do a fresh/clean install to remove unwanted settings passwords etc.

Unless I'm missing something?

David Lang

unread,
Mar 13, 2017, 6:43:28 AM3/13/17
to Bernard T, SonoffUsers
yep, you are missing the well commented, but easy to overlook CFG_HOLDER
variable in user_config.h

if this changes, the firmware will decide the prior config contents are
corrupted and will overwrite them with what's defined in user_config.h.

Also, you can hold the button down for 4 seconds and it will replace the config
data with the compiled in defaults.

trust me, you are far from the only person to miss this :-)

In addition, you can also write a file containing 1M of 0s to the file, but
that's not needed if you use one of these other options.

David Lang

Bernard T

unread,
Mar 13, 2017, 8:56:33 AM3/13/17
to SonoffUsers
Thanks, I spent hours trying to flash with all sorts of sketches just in hope it would overwrite it, but it always comes back ha ha, I'll try pressing the button for 4 seconds when I get it out of the bin :-)
We live to learn.

Don Willingham

unread,
Mar 15, 2017, 12:32:55 PM3/15/17
to SonoffUsers
The esptool (https://github.com/espressif/esptool) has an erase_flash option. I had a path to the older branch to work around it, see https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/pull/290. I would have missed the ability of holding down the button for 4 seconds. I have some sonoff's installed where it's not easy to press the button. So at some point I may add a checkbox to the upload form to force a clear to defaults.

David Lang

unread,
Mar 15, 2017, 1:09:12 PM3/15/17
to Don Willingham, SonoffUsers
you can also change CFG_HOLDER to a different value and that will make it
consider the existing config corrupt and replace it.

preserving the config across updates is usually a good thing. you don't want to
have it do an OTA update and then have to physically touch every device to get
it online again.

Motster

unread,
Apr 10, 2017, 12:37:08 PM4/10/17
to SonoffUsers
HA HA. You spent hours trying to figure out this. This is too funny so. lol

As it took me days to figure this out.. till this day.. right now in fact.  Glad i found this post.

Joe Palazzolo

unread,
Apr 11, 2017, 10:26:41 PM4/11/17
to SonoffUsers, don.wil...@gmail.com, da...@lang.hm
Thanks David - that's one mystery solved for me, too!

To Minh

unread,
May 18, 2017, 11:27:50 AM5/18/17
to SonoffUsers, bernard...@gmail.com, da...@lang.hm
I still recommend Write 1Mbs blank file if you decided to flash again, especially if you switch from many different ROM (espeasy, espurna...)
I also spent days to figure it out, used to replace memory chip because i thought it die, but actually i haven't completely erase the ROM.

Minh.
Reply all
Reply to author
Forward
0 new messages