{"id":126840,"date":"2023-03-02T15:25:55","date_gmt":"2023-03-02T15:25:55","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=126840"},"modified":"2023-07-27T16:01:29","modified_gmt":"2023-07-27T16:01:29","slug":"esp32-erase-flash-memory","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-erase-flash-memory\/","title":{"rendered":"ESP32: Erase Flash Memory (Factory Reset)"},"content":{"rendered":"\n<p>This is a quick guide showing how to erase the ESP32 flash memory to restore it to its original state. This might be useful if you want to delete any changes made to the firmware or configuration settings; if the system is crashing constantly and you can&#8217;t upload new code; to clear data that is no longer needed, and other applications. We&#8217;ll use a tool called <strong>esptool<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-erase-flash-factory-reset.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Erase Flash Memory Factory Reset esptool.py firmware\" class=\"wp-image-126852\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-erase-flash-factory-reset.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-erase-flash-factory-reset.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-erase-flash-factory-reset.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-erase-flash-factory-reset.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Installing esptool.py<\/h2>\n\n\n\n<p>To perform an ESP32 factory reset, we&#8217;ll use <a href=\"https:\/\/pypi.org\/project\/esptool\/\" target=\"_blank\" rel=\"noopener\" title=\"\">esptool<\/a>, which is &#8220;<em>a Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips.<\/em>&#8220;<\/p>\n\n\n\n<p>To install esptool, you need Python 3.7 or newer installed on your system. You can download and install Python at the following link (make sure you download the right package for your system):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Download Python<\/a><\/li>\n<\/ul>\n\n\n\n<p>With Python 3 installed, open a Terminal window and install the latest stable esptool.py release with pip:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install esptool<\/pre>\n\n\n\n<p><strong>Note:<\/strong> with some Python installations that command may not work and you&#8217;ll receive an error. If that&#8217;s the case, try to install esptool.py with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">pip3 install esptool<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">python -m pip install esptool<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">pip2 install esptool<\/span><\/li>\n<\/ul>\n\n\n\n<p><em><span class=\"rnthl rntliteral\">Setuptools<\/span> <\/em>is also a requirement that is not available on all systems by default. You can install it with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install setuptools<\/pre>\n\n\n\n<p>After installing, you will have esptool.py installed into the default Python executables directory and you should be able to run it with the command <span class=\"rnthl rntliteral\">esptool<\/span>. In your Terminal window, run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python -m esptool<\/pre>\n\n\n\n<p>If it was installed properly, it should display a similar message (regardless of your operating system):<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"745\" height=\"951\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/esptool-arguments.png?resize=745%2C951&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"esptool utility\" class=\"wp-image-126844\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/esptool-arguments.png?w=745&amp;quality=100&amp;strip=all&amp;ssl=1 745w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/esptool-arguments.png?resize=235%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 235w\" sizes=\"(max-width: 745px) 100vw, 745px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Erasing the ESP32 Flash<\/h2>\n\n\n\n<p>Follow the next steps to erase the ESP32 flash:<\/p>\n\n\n\n<p><strong>1) <\/strong>Connect the ESP32 to your computer;<\/p>\n\n\n\n<p><strong>2) <\/strong>Open a Terminal window on your computer;<\/p>\n\n\n\n<p><strong>3)<\/strong> Hold the ESP32 BOOT button;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-BOOT-button.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 BOOT button\" class=\"wp-image-126846\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-BOOT-button.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-BOOT-button.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p><strong>4)<\/strong> <span style=\"font-size: revert;\">Copy the following command to your terminal window and press Enter (continue holding the BOOT button).<\/span><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">python -m esptool --chip esp32 erase_flash<\/pre>\n\n\n\n<p><strong>5)<\/strong> When the &#8220;<strong>Erasing<\/strong>&#8221; process begins, you can release the &#8220;<strong>BOOT\/FLASH<\/strong>&#8221; button. After a few seconds, the ESP32 flash memory will be erased.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"745\" height=\"362\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/esptool-erase-flash.png?resize=745%2C362&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 erase flash esptool\" class=\"wp-image-126845\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/esptool-erase-flash.png?w=745&amp;quality=100&amp;strip=all&amp;ssl=1 745w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/esptool-erase-flash.png?resize=300%2C146&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 745px) 100vw, 745px\" \/><\/figure><\/div>\n\n\n<p><strong>Note: <\/strong>if after the &#8220;<strong>Connecting &#8230;<\/strong>&#8221; message you keep seeing new dots appearing, it means that your ESP32 is not in flashing mode. You need to repeat all the steps described earlier and hold the &#8220;<strong>BOOT\/FLASH<\/strong>&#8221; button again to ensure that your ESP32 goes into flashing mode and completes the erasing process successfully.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<p>If you encounter a permission error while trying to run the esptool command, open the command prompt as a administrator (or as sudo on Linux).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"487\" height=\"111\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/cmd_run_as_admin.png?resize=487%2C111&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"run commands as an administrator command prompt\" class=\"wp-image-133764\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/cmd_run_as_admin.png?w=487&amp;quality=100&amp;strip=all&amp;ssl=1 487w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/cmd_run_as_admin.png?resize=300%2C68&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>This was a quick guide showing you how to erase the ESP32 flash to perform a factory reset. We hope this tutorial is useful.<\/p>\n\n\n\n<p>If you\u2019re using an ESP8266 board, you can follow the instructions in the following tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-nodemcu-erase-flash-memory\/\">ESP8266 NodeMCU: Erase Flash Memory (Factory Reset)<\/a><\/li>\n<\/ul>\n\n\n\n<p>If you would like to learn more about the ESP32 board and IoT, make sure you take a look at our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/build-web-servers-esp32-esp8266-ebook\/\">Build Web Servers with ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/firebase-esp32-esp8266-ebook\/\">Firebase Web App with ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">Free ESP32 Projects and Tutorials<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a quick guide showing how to erase the ESP32 flash memory to restore it to its original state. This might be useful if you want to delete any &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32: Erase Flash Memory (Factory Reset)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-erase-flash-memory\/#more-126840\" aria-label=\"Read more about ESP32: Erase Flash Memory (Factory Reset)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":126852,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[281,276,277,299,264],"tags":[],"class_list":["post-126840","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32-project","category-esp32","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/02\/ESP32-erase-flash-factory-reset.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/126840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=126840"}],"version-history":[{"count":11,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/126840\/revisions"}],"predecessor-version":[{"id":133769,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/126840\/revisions\/133769"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/126852"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=126840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=126840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=126840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}