Completely format or erase ESP8266 flash memory

posted in: Internet of Things (IoT) | 70

I was having trouble figuring out why some random strings keep appearing at the UART (default port) after the system boots and starts executing my code. For example, I have 2 modules and when I burn the same program to both of them – they look for different access points to connect to and I did not even program either of that! All I did was LCD interface related coding only. This made me feel that some part of the flash that is not erased is responsible for this. If you have similar issues, here is how you may erase ESP8266 flash completely.

Programmer used

The programmer I used here was the one provided by Espressif Systems on their downloads page. More specifically, it is the ESP flash tool v.2.3, which you may download from Espressif Systems.

The issue with this version of the tool is that it just does not have a “erase flash” option. I guess I could use the command line interface to erase a specific range, but what I found more convenient was to just have a blank file that can be put into any location to effectively erase that range. For having blank flash blocks, you usually just need a blank.bin provided by Espressif Systems. Then program it into the area you want to erase.

But the blank binary is 4K in size only! So I created a larger version of it (1 MB or 8 Mbit). You can make your own too, you just need a file that contains 0xFF inside it. The size of the file will determine the length of flash area that will be erased.

Erase ESP8266 flash memory

To erase a 1MB range with this blank_1M.bin file, just download the file and set it for uploading to wherever you want it to be written.

In this case, I want 0x000000 to 0x100000 to be erased, so here is what I put into the Flash Download tool:

Erase ESP8266 flash memory completely
If you want to erase entire flash, for example of an ESP-12 E module, which has a 4MB flash memory chip, you need to upload the blank_1MB.bin file to 0x000000, 0x100000, 0x200000 and 0x300000. This will put 0xFF in the range 0x000000-0x3FFFFF. Which is same as clearing the entire flash!

By the way, this is what the ESP8266 prints out when booting if all of the internal memory is clean:

Output on booting ESP8266 with clean formatted flash


Now enjoy a brand new, “clean” memory free from saved information from previous sessions! If you have anything to say, or need a custom sized blank.bin, do leave a comment below…

Download blank_1MB.bin (ZIP)



70 Responses

  1. Charlie BART

    hey man,
    where can i find this blank_1m.bin file?
    i’m getting tired of this esp12 not working…

    • pratik

      Hello Charlie,
      I have fixed the post and added a button to download the file at the end of the article.
      Let me know if it solved your problem… 🙂

      – Pratik

    • joe

      my password does not work anymore. do I need to factory reset esp8266 ?
      Thank you.

      • pratik

        Yes, you should do that. Or just set a new password if you are using the ESP8266 in AP mode, using AT commands.

  2. Karol

    Hi Pratik,
    Why do you have such baud rate (74880)? What default baud rate esp communicates at after flash erase?

    • pratik

      After flash erase, the baud rate is 74880 if you are using a 26MHz crystal. For 40MHz crystal, I think baud rate is 115200

  3. Peter Scargill

    Hi there

    I tried this – the problem is – it looks like it is wiping the entire 4MBYTE but if you look at the address bar, at least on the current version – it is actually repeatedly wiping the first meg.

    Using the tool that Espressif supply I appear to have had more luck with this – and it works in a second.

    C:\Espressif\utils> -p COM3 -b 115200 erase_flash

    • pratik

      You could make a combined BIN of all to suit your flash. 🙂
      And you’re right, the command will work as well.

    • tgd

      I couldn’t get the overwrite to work, but worked a charm. Many thanks!

  4. Peter Scargill

    Ok, so I have a new problem – oh KAROL – 78k is the baud rate set by Expressif for power up debug – sadly there is no way to control this – you can have any baud you like in your own software – but at powerup – 78k – you have to wonder what they were thinking of because most terminals can’t DO 78k!!! I wrote my own.

    Ok, so my new problem – when I was messing with SDK 1.54 and getting no-where I noted I could not write to the LAST 1 Meg in the 4 meg block. I could write slightly LESS than that. I dismissed it when I found the esptool.

    But – I have a board now which will NOT do anything other than complain about system parameter error – turns out this is in the TOP of the 4th MEG – and I THINK the reason I’m having difficulty is because that last block is write protected.. so the ESPTOOL appears to wipe everything EXCEPT that write protected bit…. I simply can’t get past this – I wonder if there is a tool or a flag to ensure the ENTIRE 4MB is wiped – including any write protected areas??!!!?!?

    • pratik

      I wouldn’t know the reason for this for sure. The flash chips do come with write protection and usually that is OTP. So if that gets programmed by mistake, you’re stuck permanently. This used to be a major issue with memory cards as well. You can just lock the card by mistake and then you can never erase it again.
      I’d just recommend using completely Espressif solutions for ESP8266. The other tools are made without accurate knowledge of the hardware employed and will usually do more harm than good.

  5. Bob Green

    Regarding the 74880 baud rate. Coolterm can use any baud rate that you set in an INI file. I set up a baud rate of 74880 and its works really well.
    either find a file called baudrates.ini or make it in a text editor then inside it simply put 74880. That baud rate will then appear in the baud rate selection drop down list. Easy and coolterm is a really good package and free!

    • pratik

      I use RealTerm on Windows 10. 🙂
      74880 is fine as long as the USB-UARt converter and the terminal software both support it.

  6. Bob Green

    Pratik, my point was that the information spewed out at power, baud rate 74880, can be viewed in Coolterm. This enables the user to see what is being output and this can help in debugging. The USB-UART converter can be a factor but the variety of converters I have all work even the FTDI clones!

  7. Bob Green

    Pratik, further to Peter’s point about erasing the whole 4M can you clarify something for me please. In my simple mind I would assume that if the BIN file erases 1M then it would start at zero and write 0xFF to each location. The location would be incremented by 1 and then the write occurs again until the 1M boundary is reached.
    Therefore even though you set the address to 0x100000 it still starts at zero. OR does it start at the address set and then increment to the next boundary.
    In other words why does the counter at the bottom of the screen not display according to the base address set?

    • Peter Scargill

      In the end the only tool I could reliably assure myself I’d wiped the whole lot – was/is esptool.exe – well under Windows anyway. so for example:

      esptool.exe -p COM3 -b 115200 erase_flash

      That has been so successful, along with ensuring that I re-flash the radio information at the very top of memory along with my code – that I’m no longer having issues. I’ve added this as an option in Eclipse – in the makefile.

      $(ESPTOOL) -p $(ESPPORT) -b $(ESPBAUD) erase_flash

      • Bob Green

        Peter, Thanks for the reply I was aware the method you use works and I have used too, so we have a good tool! My question was really trying to understand Pratik’s approach better. It does seem to erase the first 1M Ok and has helped me sort out a few ESP’s that were malfunctioning. I use the Expressif flash tool and so it is quiet easy to Pratik’s 1M erase BIN within that tool.

        • pratik

          Hello Bob,
          Sticking to Espressif official tools guarantees that your design doesn’t become obsolete or incompatible suddenly. That’s why I wrote this making use of official flash tool.
          As for BIN files, they are just data bytes. Unlike HEX files, they do not contain any address information. Therefore you have to supply an offset where the file contents are written to. Thats why dumping blank files all over the flash range acts as erase operation. Also, simply erasing a block doesn’t mean it is working. Writing 0xFF can cause failure on faulty sectors and actually point out potential faulty sectors when programming some chips.

          • Bob Green

            Pratik, thanks for your explanations, very helpful. A number of people have commented on various sites that erasing the flash has enabled their new code to run as expected. I appreciate that erasing the flash doesn’t necessarily mean it is working or, if faulty, that it will be repaired. None the less it is a useful thing to try if one is experiencing problems with loading or executing code.
            I’ll look forward to more postings from you.

          • pratik

            I have this small startup and consultancy idea that will help people get their IoT designs up and running. The website should have a lot of new content at
            Do check on there from time to time for detailed info and code samples for ESP8266. And of course I post here as well 🙂

  8. Chandra MDE

    I recently played with ESP8266 and use erase_flash to erase the flash. I am using linux. Thanks for your great post and discussion.

  9. Atiq

    I want to earse the whole esp 8266 memory cause i forgot its password so i want to fully erase it

  10. Mohsin

    bro… i hav one prob.. is that… my esp 8266 has been set in the default baudrate by mistake to use the serial command AT+UART_DEF=30200,8,1,0,0 … & NOW i hav forget that baud rate so how can i communicate with that… & now how i can reset my module ???

    • pratik

      You should flash the “blank.bin” files again to the module. That will erase the saved baud rate and all user settings such as Wifi passwords, etc as well.


    That link is not working, did you erase flash using esptool? Can you provide more detail about what you have done or are you having problems with a basic wifi example sketch?

    • pratik

      Oh! I will recheck the links.
      I had issues like reconnection to weird non-existent APs and fatal exceptions often.

  12. Faizan Gull

    Hi. I am gonna share some experience about nodemcmu esp8266 12e. When i upload the code its working fine but when i cycle the power cable its all empty seems like this. Few expert says on their site that pull up the GPIO pins with Ground etc. I did all. But problem stay was there. After that red you this artical i did this like flash the nodemcu build up file etc. But don’t fix the problem. Than start thinking to the problem. I just change the code and D8 as an output in my skatch previously. I set as low at initial time. And rest as free for hardware. And problem is solved. Now every time its booting and connecting to wifi work fine. I just share my experience. Don’t know much about in this feild. I am civil engineer basically.

    • pratik

      Thank you for the information, I’m sure people will find it useful. ESP8266 boot issues are common and usually hard to solve.
      BTW, If you want to contribute articles for the community via you are welcome to!

      • Peter Scargill

        Oh and – GPIO0 should be pulled up – unless you are programming – in which case pull to ground – before reset…

        So GPIO0 and 2 should be held high with resistors – GPIO15 should be held LOW with a resistor. If they are used as inputs – make sure whatever is driving them to not conflict with the above on power up.

        I generally use 2k7 resistors. CH_PD and RESET should also be held high with resistors – of course – depending on which board you are using – these may already be present.

    • Peter Scargill

      “ESP8266 issues are common” – we need to be careful with that phrase as they are only common when something is wrong – otherwise the ESP8266 is reliable.

      So- things that might be wrong:

      Power: Ensure you have adequate power – usually an FTDI is not good enough – this can be the difference between utter reliability – and power up issues and occasional failure.

      Watchdog: Don’t go for lengthy delays – depending on what you are using – the watchdog could time out.

      Lots of discussions re: ESP8266 at the blog – – search for ESP8266

      • pratik

        Agreed. “ESP8266 issues are common” because it is an RF SoC. All RF SoCs are very sensitive. Even the number of vias under the QFN thermal pad can make a difference. And unfortunately, modules like the ESP-01 are classic examples of poor RF design. But hey, you can’t complain about $2 WiFi module. 😀

        • Peter Scargill

          Well, you can complain about an ESP-01 WIFI module at $2 when for the same money you can get the ESP-12 🙂

          The original ESP-01 is now no longer supported – due to the 512K Flash (which can be replaced but it’s messy) – Espressif have issued warnings about this and in my own code I’ve now gone past the 512K for code – having finally grasped how to shift things around I’m all set up to use up to 1 Meg (minus a 4k block) – which leaves 1 meg for OTA and nearly 2 meg for general data storage – once I figure out how to move my font arrays up outside of the first 2 megs I’ll have more space than I can possibly use – but that does entail totally abandoning support for boards with less than 4 Meg.

          • pratik

            The AT command set does not work for small flash sizes. But the SDK should still work well on small flash sizes. The ESP8285 has 1MB integrated flash though, so at least you can be sure Espressif will not shoot beyond that and kill their own chip. 😛

  13. gaurav

    hey pratik i am facing an serious issue with my esp8266-01 module as i power it on it just automatically becomes access point, i have flashed its ram several times but same thing is happening please reply me asap
    contact 9717661304

    • pratik

      Hi Gaurav, it is happening because you are setting your ESP to access point mode. If you do not configure it properly, it will create a default AP.
      Please use my new forum at
      I set that up so I can reply faster!

  14. Amith

    hi everyone
    i am using esp8266-01, in this i am storing some data in a file(SPIFFS).
    Now the problem is how to erase the contentents of that particular file? or should i overwrite on existing data?

  15. Asad

    hello every one!
    i m using esp8266 ESP-12 my problem is no matter what i do esp response as rst cause 2 (some times 1) bootmode (3,0) and some time different numbers in bracket.
    i have tested many configurations and still no use, code uploading is fine, rst issue is also with a blank sketch.
    i m using arduino ide for code and using arduino mega as serial communication with esp any help in this matter??

  16. yusuf

    hii mister, i have project used nodeMCU, it can’t connect this wifi to my channel thingspeak. how fix this?

  17. David

    Hello Pratik!
    I´m using a NodeMCU Dev Kit V3 from Doit which runs with a ESP8266 E-12E. I tried to flash it with your blank binary file, but the NodeMCU Firmware programmer (flasher) just gives me this error in the log:
    Note:Serial port connected.
    Note:Begin find ESP8266.
    Note:ESP8266 ACK success.
    Note:ESP8266 ACK success.
    Error:Set ESP8266 Address timeout.
    I´ve tripple-checked the COM-Port and all other settings (baud-rate and so on), but nothing seems to work… could you give me any suggestions what I might have done wrong? My PC is running on Windows 10, 64-bit system. Thank you very much!

  18. wifi


    Project: ESP8266-12F standalone application using Arduino:

    >Can I flash the binary file generated from arduino IDE of ESP8266-12F using the ESP8266 flashing tool?
    >What address I should follow.

  19. connor beynon

    Is there a Bin file for a 4mb flash? I don’t get how you can flash four 1mb files and using the 4mb file would just plain and simple just be easier for me.

  20. Maaz Younis

    Hi, I am having a problem with flashing the firmware in ESP8266. GPIO0 is at ground when I upload the firmware. I have done this couple of times but from past few days I am unable to flash the firmware. I get the this at serial monitor if I restart the chip

    “ets Jan 8 2013,rst cause:2, boot mode:(5,7)

    waiting for host”

    I have tried different ESP8266 but they are behaving in the same manner. Actually ESP doesn’t connects to flasher. Can anyone please help me out.

    • pratik

      I think you should check the state of GPIO2 and GPIO15 as well. They are not in the correct levels during boot, and that’s why you get this issue.

  21. locnguyen

    my situation is ESP8266 automatically create an access point even i do not code that, and i figured out that i have code it to create an access point before and chosse 1M flash memory, but now i chosse 512k so the old code cant be deleted. so let me now if it work for you .

  22. Giovanni

    Great work. I’ ve similar problem with a Parrot ck5050 bt module. After a crash during bluetooth firmware update, module lost his function.with uart conn. I can’t load firmware from parot app. And so copy “send” firmware from TeraTerm, but every startup i see a new bt com port.. now 4 com port.what can i do for erase all memory and reload .plf file?? Ideas?

  23. Frank Häfele

    Hello Pratik,

    I have some Problems when flashing an ESP8266 (ESP12-E) mith 4 MB Flash.
    When I flash the chip I get always a checksum error when boot the chip.
    I does not now how to solve the Problem.
    Does a complete flash_erase help?
    Or how do I check if the flash is the Problem or anything else?
    Or ist the flashmode wrong? –> I use Qio for the 4 MB Flash

  24. Saurabh

    When I am uploading promagram to my nodemcu on serial monitor it shows
    ets Jan8 2013,rat cause:4, boot mode :(3,6)
    wdt reset
    Load 0x0410f000,Len 1384 room 16
    tail 8
    Etc etc…….
    How to solve this problem please help

  25. Berhan

    Hey Pratik Panda;
    I am having issue with my ground pin. my esp does not seem to respond and I checked pins with multimeters and when I give 3,3 V, I am measuring 0,8 V from ground pin. Is it normal.
    Thanks in advance

    • pratik

      Ground must be 0V. Please read about star grounding topology, you will know how to do the wiring then. You must keep ground wire really short for stable operation.

  26. Md shams tabrez

    hi prateek
    i successfully erase the firmware .and after that i compile the Arduino IDE code once for checking it ,erase are successfully or not .then i show me code will be uploaded with firmware .can you explain it how it possible in this manner .

  27. Steph

    Hello everybody,

    I installed an awesome ESPEasy on my board (ESP8266), but I have to change to a “basic code”. I tried to flash my ESP8266 with this trick, but my ESP8266 is available on wireless network , though anything is inavailable on this (Just an IP address, No web page).
    Somebody can I help me with my problem ?

  28. Debashish Kumar

    I have esp 12 e and want to use 3MB for sketch.
    Or pls suggest how data like ayyay [ 1,2,5,…… ] can be stored in Spiffs and read from spiffs and execute them.

  29. KaAsun Nimantha

    Hello patrik,
    I made my own custom ESP8266 board and the flash I used was W25Q32.
    Obviously the Flash is empty and my device only responds to 74880 baud rate (Gives correct reset cause and boot mode correctly).

    But my device doesn’t respond to any flash downloading tool. I can’t upload anything to my board.
    Basically any tool doesn’t recognize the MAC and can’t flash a code.
    (All chips are new and bought from mouser)

    Do you know a method to fix this?

  30. Rishav Bhattacharya

    Hello I accidentally erased all flash in an ESP12e using arduino. Now for a new code every time it’s showing sync failed. Even tried the flash tools provided by expressif.
    At starting also at 74880 baud, the boot mode is not showing.
    Please tell me how to restore the booting flash?

  31. D Sharath

    how can i flash back the original esp8266 12E firmware back to it.
    Can you tell me how to flash the files and where to get them.

  32. Cristian Moise

    Hello! I bought an ESP 8266 -01 wifi relay whit a preloaded software. Of course the flickering LED relay board showed up right the way but this is not my concern. I built up my own flashing programmer and pressing the reset button I got by Putty the info that I have wrote down.
    SDK version:0.9.2
    mode : sta(18:fe:34:0c:73:54) + softAP(1a:fe:34:0c:73:54)
    add if0
    add if1
    dhcp server start:(ip:,mask:,gw:
    bcn 100

    I am not sure what software is already installed but I presume the AT communication is not working as the firmware was erased.
    I want to erase/re-flash the ESP8266 using ESP8266 IDF AT Bin (Latest)2020 or older but I am not sure that is going work.
    Should be 2 steps: one is erasing and second flashing AT bin.
    As I am new in this microchips and programing word I need some advice, please!

Leave a Reply

Your email address will not be published. Required fields are marked *