[SOLVED]Cannot erase flash, ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

[SOLVED]Cannot erase flash, ESP32

Post by dps » Mon Oct 28, 2019 9:48 pm

hello all, new here, and new to uPython and Python in general. I am having an issue erasing the flash of my esp32. It is branded AGOAL ESP32CAM, which is allegedly a pin for pin replica of the AI thinker model, and in the information that i have found on it, it looks to be the WROOM model of esp32 (or esp32s?).

Here is the output of the error:

Code: Select all

esptool --port /dev/ttyUSB0 erase_flash
esptool.py v2.1
Connecting....
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision (unknown 0xa))
Enabling default SPI flash mode...
Erasing flash (this may take a while)...

A fatal error occurred: ESP32 ROM does not support function erase_flash.
now, i CAN flash the micropython bin file to it, and verify show me this:

Code: Select all

esptool --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 /media/dps/secondary/dev/micropython/esp32/esp32spiram-20191025-v1.11-498-gf69ef97f2.bin --verify
esptool.py v2.1
Connecting...
Chip is ESP32D0WDQ6 (revision (unknown 0xa))
Enabling default SPI flash mode...
Configuring flash size...
Auto-detected Flash size: 4MB
Erasing flash...
Compressed 1459424 bytes to 901352...
Took 3.65s to erase flash block
Wrote 1459424 bytes (901352 compressed) at 0x00001000 in 96.5 seconds (effective 121.0 kbit/s)...
Hash of data verified.

Leaving...
Verifying just-written flash...
(This option is deprecated, flash contents are now always read back after flashing.)
Verifying 0x1644e0 (1459424) bytes @ 0x00001000 in flash against /media/dps/secondary/dev/micropython/esp32/esp32spiram-20191025-v1.11-498-gf69ef97f2.bin...
-- verify OK (digest matched)
Hard resetting...
so it seems to actually flash successfully, but then when i reconnect my wires up to the correct pins to access the REPL (GPIO0 and GPIO3), i get this message:

Code: Select all

FAT filesystem appears to be corrupted. If you had important data there, you
may want to make a flash snapshot to try to recover it. Otherwise, perform
factory reprogramming of MicroPython firmware (completely erase flash, followed
by firmware programming).
it just keeps repeating over and over, until i press (keyboard interrupt?) ctrl-c. it then shows me this:

Code: Select all

Traceback (most recent call last):
  File "_boot.py", line 10, in <module>
  File "inisetup.py", line 28, in setup
  File "inisetup.py", line 14, in check_bootsec
  File "inisetup.py", line 25, in fs_corrupted
KeyboardInterrupt: 
MicroPython v1.11-498-gf69ef97f2 on 2019-10-25; ESP32 module (spiram) with ESP32
Type "help()" for more information.
>>> 
any ideas why this would be happening? I am on Ubuntu 18.04.3, if that is of any help
Thanks for reading!
Last edited by dps on Sun Nov 03, 2019 6:14 pm, edited 1 time in total.

rpr
Posts: 99
Joined: Sat Oct 27, 2018 5:17 pm

Re: Cannot erase flash, ESP32

Post by rpr » Tue Oct 29, 2019 12:49 am

Can you add the --chip=esp32 to the erase_flash option?

These are the commands I . usually use:

Code: Select all

esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash

esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32-20190125-v1.10.bin
It is possible that the download of the firmware is corrupted.
Plus, the standard micropython firmware does not support the esp32 camera.

User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

Re: Cannot erase flash, ESP32

Post by dps » Tue Oct 29, 2019 2:16 am

rpr wrote:
Tue Oct 29, 2019 12:49 am
Can you add the --chip=esp32 to the erase_flash option?

These are the commands I . usually use:

Code: Select all

esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash

esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32-20190125-v1.10.bin
It is possible that the download of the firmware is corrupted.
Plus, the standard micropython firmware does not support the esp32 camera.
certainly! give me just a bit and ill try with your recommendations!

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Cannot erase flash, ESP32

Post by Roberthh » Tue Oct 29, 2019 6:28 am

You could try a newer version of esptool.py. e.g. from this place: https://github.com/espressif/esptool

User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

Re: Cannot erase flash, ESP32

Post by dps » Tue Oct 29, 2019 8:41 am

Hey sorry everyone. Something came up last night. Just woke up.
But yeah. Do you think that it could possibly be that I'm not using the .py version of the tool? I'm just using the one that I got from the repos in Ubuntu, by running sudo apt install espool.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Cannot erase flash, ESP32

Post by Roberthh » Tue Oct 29, 2019 8:57 am

The prompt of the program is esptool.py. So it should be the right one, just an older version. One option of the call is flash_mode or -fm. There are five variants (keep, qio,qout,dio,dout). Sometimes a different than the default one has to be used. For any subcommand, you can call a help list, like

esptool.py erase_flash --help

User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

Re: Cannot erase flash, ESP32

Post by dps » Tue Oct 29, 2019 11:49 pm

ah ok, ill try that.
what i meant by the "not the .py" version of the esptool, is that i installed it from the standard ubuntu repos, not using pip. it was there and installed it by running `sudo apt install esptool`.

User avatar
dps
Posts: 51
Joined: Mon Oct 28, 2019 9:37 pm

Re: Cannot erase flash, ESP32

Post by dps » Sun Nov 03, 2019 6:14 pm

rpr wrote:
Tue Oct 29, 2019 12:49 am
Can you add the --chip=esp32 to the erase_flash option?

These are the commands I . usually use:

Code: Select all

esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash

esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32-20190125-v1.10.bin
It is possible that the download of the firmware is corrupted.
Plus, the standard micropython firmware does not support the esp32 camera.
hey, that worked! thank you!
I did however, figure out my troubles with just using esptool in the first place. im a noob at all of this, so i guess thats why. but i wasnt able to just use "esptool.py" at the terminal. come to find out, to be able to do that i needed to install esptool via "pip3" with sudo, not without sudo. it worked like a charm this time.

like i said, i am new to this whole thing, i apologize for this lol. i still am confused on how to even use python on ubuntu, or windows for that matter. ill get it eventually.

thanks again!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [SOLVED]Cannot erase flash, ESP32

Post by jimmo » Sun Nov 03, 2019 11:47 pm

dps wrote:
Sun Nov 03, 2019 6:14 pm
I did however, figure out my troubles with just using esptool in the first place. im a noob at all of this, so i guess thats why. but i wasnt able to just use "esptool.py" at the terminal. come to find out, to be able to do that i needed to install esptool via "pip3" with sudo, not without sudo. it worked like a charm this time.
In general, try to avoid using "sudo pip install" on Linux. The issue is that it can end up conflicting with Python packages installed by your system package manager (e.g. Ubuntu). So for something like esptool, use "apt install esptool".

Alternatively, you can use a Python virtual environment, which lets you make a kind of sandboxed Python installation with its own set of installed packages.

Code: Select all

# Create a directory named venv-esptool
python3 -m venv venv-esptool

# Enter the venv
source venv-esptool/bin/activate

# Now anything you do with pip will be confined to this sandbox. You can install packages without sudo etc.
pip install esptool
esptool --help

# Leave the venv
deactivate
(In future sessions, you just start with the "source" line).

User avatar
rcolistete
Posts: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: [SOLVED]Cannot erase flash, ESP32

Post by rcolistete » Mon Nov 04, 2019 12:03 am

Or create conda environments (install Anaconda).
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

Post Reply