Ouroboros
Ouroboros

Reputation: 1524

How to retrieve the flashed binary in ESP8266

I was able to flash a micropython binary which I'd cross compiled some 6 months ago, and it was working fine. It was built from master branch at that point of time, and I did not save the code, nor the binary.

Today, when I again compiled, the binary is having problem at a point. So I want to revert back to the old binary, only problem is I'm not sure what commitID/build the master was at at that point of time ~6 months ago when my compiled binary which works fine was created.

I do have an ESP which has that binary flashed into it. So I was thinking if there is a way to retrieve the binary from the ESP?

Please let me know if this can be done somehow via ampy, etc.. Or suggest me some workaround. I'm already trying to find out the approximate commit around that time, and would cross compile again, which I'm not sure if would work as expected.

Upvotes: 3

Views: 4634

Answers (4)

baba andrei
baba andrei

Reputation: 1

hi guys one surprise today... i just opened one esp8266 esp 12e and Read flash in programer.. 16mb.... after i try to read by phyton esp tool... 16 mb to... not 4mb how is putting in datasheet.... so for full backup.... programer only.... there will be a lot of sensitivo info too... ssid... wifi paswords... accounts paswords entere too.. so for full backup hardware only..

Upvotes: 0

I reduced the speed of reading the flash memory of my esp8266 460800 for "46080" I took a zero. and successful

My system is a windows 10

C:\Users\POSITIVO\Downloads\esptool-master\esptool-master>esptool.py -p COM6 -b 46080 read_flash 0 0x400000 flash_contents3.bin
esptool.py v3.0-dev
Serial port COM6
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 2c:3a:e8:42:b9:f7
Uploading stub...
Running stub...
Stub running...
4194304 (100 %)
4194304 (100 %)
Read 4194304 bytes at 0x0 in 937.7 seconds (35.8 kbit/s)...
Hard resetting via RTS pin...

Upvotes: 0

geo mil
geo mil

Reputation: 11

For reading the firmware as a BIN file For reading the firmware as a BIN file you need FIRST to connect correct the FTDI with the pins on the IR module

FTDI to IR Module as follows

FTDI 3.3 V    to  IR 3.3 V,
FTDI GND      to  IR GND,
FTDI GND      to  IR IO0 (flash mode - IMPORTANT otherwise it will not work),
FTDI RX       to  IR TXD,
FTDI TX       to  IR RXD

Then run the command (if the COM port is 5 and the name to extract the bin is flash-contents, otherwise you replace them to match your COM and the name you wish to have) – important the baud rate to be 9600

esptool.py -p COM5 -b 9600 read_flash 0 0x200000 flash_contents.bin

Below is the outcome for me (running under python 3.10.2 on windows 11):

  PS F:\> esptool.py -p COM5 -b 9600 read_flash 0 0x200000 flash_contents.bin
  esptool.py v3.2
  Serial port COM5
  Connecting....
  Detecting chip type... Unsupported detection protocol, switching and trying 
  again...
  Connecting...
  Detecting chip type... ESP8266
  Chip is ESP8266EX
  Features: WiFi
  Crystal is 26MHz
  MAC: 10:52:1c:f8:b7:c7
  Stub is already running. No upload is necessary.
 2097152 (100 %)
 2097152 (100 %)
 Read 2097152 bytes at 0x0 in 2215.2 seconds (7.6 kbit/s)...
 Hard resetting via RTS pin...
 PS F:\>

Remember the esptool.py -p COM5 -b 9600 read_flash 0 0x200000 flash_contents.bin is for 2MB memory

but it is well run with esptool.py -p COM5 -b 9600 read_flash 0 0x100000 flash_contents.bin for 1MB memory as it was in my IR Module

Upvotes: 1

Marcel Stör
Marcel Stör

Reputation: 23555

Regardless of which firmware you loaded onto your ESP8266 module (NodeMCU, MicroPython, Arduino, etc.) you can use esptool.py to dump the flash content to a file like so:

./esptool.py -p PORT -b 460800 read_flash 0 0x200000 flash_contents.bin

read_flash is the command, 0x200000 the argument for the upper memory bound (2MB).

Upvotes: 4

Related Questions