Create backup of the current ESP8266 flash

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bglnelissen
New user
Posts: 3
Joined: 26 Mar 2018, 12:56

Create backup of the current ESP8266 flash

#1 Post by bglnelissen » 06 Apr 2018, 14:38

Hi,

For now I have a NodeMCU 4mb unit which I use for setting-up and tweaking. I run Linux of Mac and prefer commandline utilities. This is my workflow when creating a backup of the current flash memory.

First I calculate the flash size in bytes (which is always 4194304 bytes in my case but might change in the future):

Code: Select all

rombytesize=$(( 1048576 * $(esptool --port /nodemcu flash_id | grep "flash size:" | sed 's/.*\([0-9+]\).*/\1/') 
And then I make a backup of the whole flash memory

Code: Select all

esptool --port /nodemcu read_flash 0x00000 "$rombytesize" backup."$rombytesize"."$(date +%Y%m%d%H%M)".bin 
Now I can use that backup to do a restore in the future on a ESP unit (of the same byte size) using:

Code: Select all

esptool --port /nodemcu write_flash 0x00000 firmwarebackup.bin 
Is this how you guys backup your systems as well?
Is this good practice or am I doing it wrong?

ps. I symlinked esptool to .../ESP8266/esptool-master/esptool.py, and I have symlinked /nodemcu to /dev/ttyblabla
Last edited by bglnelissen on 07 Aug 2018, 20:48, edited 1 time in total.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Create backup of the current ESP8266 flash

#2 Post by grovkillen » 06 Apr 2018, 18:48

I'm using my web dumper, which I created to make screen shots really easy.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: Create backup of the current ESP8266 flash

#3 Post by vader » 06 Apr 2018, 19:59

For what should it be good for :?: What you backup is what you flashed! And the config files are saved under Tools->Flash. All done.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Create backup of the current ESP8266 flash

#4 Post by grovkillen » 06 Apr 2018, 20:20

Nah, you might want to use parts of another unit and need info on how you configured that unit. THEN screenshots are King 8-)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Oxyandy
Normal user
Posts: 95
Joined: 09 Mar 2018, 08:45

Re: Create backup of the current ESP8266 flash

#5 Post by Oxyandy » 07 Apr 2018, 07:44

I like it, I use 'pre-configured' back-ups all the time too..
I setup one ESPeasy Firmware, preconfigured with all my favourite settings
defined to a static IP 192.168.0.200, after flashing I know exactly where to find it http://192.168.0.200
A few minor edits like:
Pump_0 to Pump_8
IP 192.168.0.200 to 192.168.0.208, I always match everything from 0 to 8 as above and it's ready to flash new devices with.
A real timer saver.
I also back-up original firmware from Sonoffs, doesn't take long & then I always have the option to restore the original too.

I also use a Flash.bat as a front-end for esptool.py, drag a firmware to flash onto the .bat file and file name is passed as a parameter

emeyedeejay
New user
Posts: 5
Joined: 18 Aug 2018, 18:06

Re: Create backup of the current ESP8266 flash

#6 Post by emeyedeejay » 18 Aug 2018, 18:13

Found this thread trying to fathom out how to backup a batch of WeMos D1 Minis ... It's a 4MB ESP-12S onboard.

Many posts/articles/how-toos show the flash size in bytes in hex as 0x4000000 but the original post calculates out to 0x4194304.

I understand the calculation due to:
4 MB = 4000000 Bytes (in decimal)
4 MB = 4194304 Bytes (in binary)

But which is correct to use? Are those using 0x4000000 missing the last 194304 bytes in their backups for a 4MB flash?

Code: Select all

python esptool.py --port COM8 read_flash 0x00000 0x4000000 "WeMos D1 Mini b4-e6-xx-xx-xx-xx.bin"
vs

Code: Select all

python esptool.py --port COM8 read_flash 0x00000 0x4194304 "WeMos D1 Mini b4-e6-xx-xx-xx-xx.bin"

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Create backup of the current ESP8266 flash

#7 Post by TD-er » 18 Aug 2018, 21:06

Number starting with "0x" are in hex and those without that prefix should be considered decimal.
So in order to match some power of two, like the size of a flash chip, it is very likely the last digits of the size will be "0" when using HEX notation.
In hex notation it will be 0x400000
in decimal it is 4194304

In your example, "0x4000000" is 67108864 decimal (64M)

emeyedeejay
New user
Posts: 5
Joined: 18 Aug 2018, 18:06

Re: Create backup of the current ESP8266 flash

#8 Post by emeyedeejay » 18 Aug 2018, 23:13

Ahhh! Thanks ... I had an extra 0 which is why my read_flash kept just stopping at 24% and I couldn't fathom out why!

Thanks for the pointer.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 38 guests