Fix “MD5 of file does not match data in flash!”
The upload finished but the check after writing failed, so the flash content is wrong. Usually power, flash mode or a counterfeit/worn flash chip.
Community draft — report a mistake
What you see
Writing at 0x00010000... (100 %)
Wrote 291888 bytes (162102 compressed) at 0x00010000 in 4.1 seconds (effective 568.5 kbit/s)...
A fatal error occurred: MD5 of file does not match data in flash!
Failed uploading: uploading error: exit status 2Writing at 0x00010000... (100 %) Wrote 291888 bytes (162102 compressed) at 0x00010000 in 4.1 seconds (effective 568.5 kbit/s)... A fatal error occurred: MD5 of file does not match data in flash! Failed uploading: uploading error: exit status 2
This is the safety check doing its job: the firmware was written, but what is now in flash does not match the file. Do not ignore it — a board running half-correct firmware behaves unpredictably.
Our browser flasher runs the same MD5 check on every part it writes.
Quick fix — try in order
- 1
Retry at 115200 baud
A corrupted transfer at high speed can still pass packet checks but write wrong data.
- 2
Erase the whole flash, then upload
Tools → Erase All Flash Before Sketch Upload → Enabled, or tick “Erase all flash first” in our flasher.
- 3
Set Flash Mode to DIO
Tools → Flash Mode → DIO. Some boards with slower flash chips fail in QIO.
- 4
Check the power supply
Writing flash draws extra current. Use a good cable and a PC port, or 5 V on VIN.
- 5
Suspect the flash chip
If it fails at the same address every time, the flash chip may be worn out or counterfeit.
Why it happens
What does the MD5 check do?
After writing, esptool asks the chip to compute an MD5 hash of the flash region and compares it with the file. A mismatch means the bytes in flash are not the bytes that were sent.
Wrong flash size setting
Telling the tool the flash is 4 MB when it is 2 MB can wrap writes around and corrupt data.
Unstable power
Flash writes are the most power-hungry part of an upload; a brownout mid-write corrupts the page being written.
Board-specific notes
ESP8266: Many cheap ESP-01/ESP-12 modules have 1 MB or 4 MB flash; match Tools → Flash Size to the module.
Did this fix it?
Thanks — that helps us keep this page right.