ESP32 Upload Code Error
Hi there, i'm a beginner with microcontrollers and recently got my hands on two ESP32 boards by Elegoo. I wanted to make a wireless controller by having one ESP32 read some values from joystick modules and buttons, and send them over to the slave ESP32 to help control some computer movements. As I was working with the Master ESP32 to try and send over ESPNOW protocol, suddenly no code would upload to the ESP32.
I would get two errors, either:
A fatal error occurred: Write failed, the written flash region is empty.
or
A fatal error occurred: MD5 of file does not match data in flash!
I tried searching a lot of websites and videos, but still to no avail. I tried erasing the esp flash and resetting it to factory settings, and even checked the flash id, which all showed up fine. I ran multiple esptool cleanups and even tried flashing the bootloader and partitions manually to the board, but still nothing. I ran these esptool commands:
python -m esptool --chip esp32 --port COM3 --baud 115200 --after hard_reset erase_flash
python -m esptool --port COM15 write_flash_status --non-volatile 0
When i open the serial port, this is all it says:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
It may have been that i did some really bad wiring and damaged the ESP32, but im still really lost in the dark with what to do next. Is the flash corrupted / broken? Is my ESP32 totally cooked? Can i still salvage the ESP32 or was there some hardware damage leaving it totally bricked? I really appreciate any help i can get as i'm still learning! š
53 Replies
I can tell you that yo ur esp is most likely NOT cooked, that just means the code did not upload correctly. Erase the flash and try a simpler code. And, what ide are you using ?
The āinvalid headerā from my experiences means that the code has not been properly uploaded. ESP now is an hard and advanced process, so they are many things that could have gone wrong, and Iām not advanced enough to help you with esp now, so I recommend on both esp try an simpler code š§āš»
iām using Arduino IDE with the ESP32 board manager thing
after the error occurred i just uploaded a simple blink sketch with using the onboard led from gpio pin 2
but it still wouldnāt work
i tried with my other esp32 and it worked perfectly fine with the same wire and exact same setup
Have you tried clearing the cache again using pytool?
Try using an external led if you have any
sorry for the late response, it was getting a bit late for me
ill try that today and see how it goes
by erasing the cache do you mean running the esptool erase flash again? i did
python -m esptool --chip esp32 --port COM4 erase-flash
Yes
ok i just ran that again and tried to upload a blink skech with external led
but it just wont upload
i still get the A fatal error occurred: MD5 of file does not match data in flash!
Try an different language like thonny for micropyrhon
ok ill download and set up micropython
and then see how it goes
uhhh i cant download micropython firmware onto the esp32
it just gives me the same error?
it says
Writing at 0x001a5dcc... (100 %)
Wrote 1734416 bytes (1137583 compressed) at 0x00001000 in 100.4 seconds (effective 138.1 kbit/s)...
File md5: bc509ac9a635ce283c96bba2843d011d
Flash md5: 18c18a9347b2dcd01ac09ea394c1fee4
MD5 of 0xFF is fc048a55a6aa49b11e2b0315f89d144e
A fatal error occurred: MD5 of file does not match data in flash!
Command returned with error code 2
What editor did you use? Thonny works best
Did you just upload the code or install Micropython firmware too?
Can you send me the Micropython code you used ?
i downloaded thonny to try and make a blink code
but while i was trying to download the firmware
i got the error above
i didnt write any code whatsoever
Did you go to interpreter , select the com port and then click esp then select install Micropython firmware?
yeah so i selected the port here

and then i pressed the install micropython

with all of these
Did the firmware install or did it fail?
it wrote to 100% and then failed :(
its still this error unfortunately šš
File md5: bc509ac9a635ce283c96bba2843d011d
Flash md5: 18c18a9347b2dcd01ac09ea394c1fee4
MD5 of 0xFF is fc048a55a6aa49b11e2b0315f89d144e
A fatal error occurred: MD5 of file does not match data in flash!
Signs itās flash hardware damage
⢠Flashing always fails with MD5 mismatch even after erase_flash and lowering baud rate.
⢠Flashing āsucceedsā sometimes but the ESP32 wonāt boot into MicroPython.
⢠Random verification errors with different firmware files, not just one .bin.
⢠The MD5 check shows completely different numbers each time you retry.
Try different usb ports, installing and reinstalling drivers, a different DATA TYPE usb cable.
nooooooo
damn i mightve messed up the wiring bad on my project then
ill try those but if it is hardware damage i think its just cooked
thank you so much for all the help you've given though!!!
Your welcome!
i genuinely appreciate it and its given me a lot of clarity
i cant thank you enough and now i know to make sure to keep an eye on power sources and that lol
but tysm!
I recommend an multimeter, even a cheap 9$ one, it can prevent cooking things easily
But first, make sure even if your cable supports data transfer in the first place, it might be loose or broken
okok ill work on replacing it and getting a better data transfer cable
ill try to scavenge my house to see if i have a multimeter
K
but ill def be considering buying it
https://a.co/d/4lLlr0x this is the one I have
AstroAI Multimeter Tester
The AstroAI multimeter is designed to be safely and accurately used by professionals in a commercial setting or weekend DIYer's that need a little more power utility from their standard digital multimeter. It's easy and safe to operate with advanced features built for measuring seemingly everything.
Itās on sale rn
https://a.co/d/1aqqqdr and this is the cheapest one you can get that is still and decent quality
AstroAI Digital Multimeter - Versatile and Accurate Electrical Tester
AstroAI AM33B Digital Multimeter is the perfect instrument to test & troubleshoot a variety of commercial and household electrical problems.
I donāt know what area your in, these might not be available there
ah yeah im based in canada and ion think the cheaper one is available
maybe if i get a lil bit deeper into microcontrollers ill invest in the one above
otherwise ill check out my nearby electronic stores and etc for cheaper ones
Well there cheap where I live š¤£
š
imma see then
but rip that one esp
K
And btw, in my opinion elegoo boards are not better than normal Esp32s, just more expensive. Just an fyi
oh
okay ill keep that in mind if i ever wanna buy another one
on amazon there was the freenove one but i was like quite a lot more expensive
which is why i got the elegoo one
Just get cheap made ones from china
They work good enough and they like 4 usd each
Prob around 6-7 cad
alibaba and temu here i come
From Amazon
o
But I guess there is no tariffs I ca
almost two week delivery š
Make sure the board you get has soldered pins
lol
yeah i havent learned sodering yet so if it isnt im cooked
Same
Iām beginner too
š
oh what?!!
you seem hella knowledgable on all this stuff
I had an similar problem so I have an solution and I do search
Thank you though š¤
lol
but its nice to know i wasnt alone in this type of scenario
š¤£
is it ok to just leave this post open?
or is it gonna get closed / resolved
You can leave it open
An mod can come an close or
If you need more help just say, with the solutions I sent
Well bye bye random person I found in the internet