Page 1 of 2

[SOLVED]Cannot erase flash, ESP32

Posted: Mon Oct 28, 2019 9:48 pm
by dps
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!

Re: Cannot erase flash, ESP32

Posted: Tue Oct 29, 2019 12:49 am
by rpr
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.

Re: Cannot erase flash, ESP32

Posted: Tue Oct 29, 2019 2:16 am
by dps
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!

Re: Cannot erase flash, ESP32

Posted: Tue Oct 29, 2019 6:28 am
by Roberthh
You could try a newer version of esptool.py. e.g. from this place: https://github.com/espressif/esptool

Re: Cannot erase flash, ESP32

Posted: Tue Oct 29, 2019 8:41 am
by dps
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.

Re: Cannot erase flash, ESP32

Posted: Tue Oct 29, 2019 8:57 am
by Roberthh
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

Re: Cannot erase flash, ESP32

Posted: Tue Oct 29, 2019 11:49 pm
by dps
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`.

Re: Cannot erase flash, ESP32

Posted: Sun Nov 03, 2019 6:14 pm
by dps
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!

Re: [SOLVED]Cannot erase flash, ESP32

Posted: Sun Nov 03, 2019 11:47 pm
by jimmo
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).

Re: [SOLVED]Cannot erase flash, ESP32

Posted: Mon Nov 04, 2019 12:03 am
by rcolistete
Or create conda environments (install Anaconda).