espressif / esptool

Espressif SoC serial bootloader utility
https://docs.espressif.com/projects/esptool
GNU General Public License v2.0
5.6k stars 1.39k forks source link

A fatal error occurred: Failed to write to target RAM (result was 01070000: Operation timed out) (ESPTOOL-725) #908

Closed kymatomo closed 1 year ago

kymatomo commented 1 year ago

Operating System

Windows 10

Esptool Version

v4.5.1

Python Version

Python 3.11.3

Chip Description

ESP-WROOM-32

Device Description

Dev Module on a breadboard.

Hardware Configuration

No response

How is Esptool Run

Arduino IDE, esptool.py, Arduino Cloud

Full Esptool Command Line that Was Run

esptool.py --port COM3 read_flash 0x00000 0x100000 image1M.bin

Esptool Output

esptool.py v4.6.2
Serial port COM3
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting.......
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 54:43:b2:c5:0d:64
Uploading stub...

A fatal error occurred: Failed to write to target RAM (result was 01070000: Operation timed out)

py -m esptool --port COM3 write_flash_status --non-volatile 0

esptool.py v4.6.2
Serial port COM3
Connecting......
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting.......
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 54:43:b2:c5:0d:64
Uploading stub...
Running stub...
Stub running...

A fatal error occurred: Unable to verify flash chip connection (Packet content transfer stopped (received 138 bytes)).

More Information

I first tried it with Arduino IoT Cloud Sketch and I get this

esptool.py v4.2.1
Serial port COM3
Connecting....
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 54:43:b2:c5:0d:64
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00120fff...
Compressed 18912 bytes to 13025...
Writing at 0x00001000... (100 %)
Wrote 18912 bytes (13025 compressed) at 0x00001000 in 0.2 seconds (effective 844.7 kbit/s)...
File md5: e7d5057d627598659b7aa7b697f6cff6
Flash md5: 4ca6a95d1789c3d6317811ab47dfa684
MD5 of 0xFF is 4ca6a95d1789c3d6317811ab47dfa684
A fatal error occurred: MD5 of file does not match data in flash

I open the Full Editor and get the same output. So I tried using an example code in Arduino IDE which is "WiFiScan"

esptool.py v4.5.1
Serial port COM3
Connecting....
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 54:43:b2:c5:0d:64
Uploading stub...

A fatal error occurred: Failed to write to target RAM (result was 01070000: Operation timed out)
Failed uploading: uploading error: exit status 2'

I've tried changing baud rates and doing --no-stub but it doesnt work.

Other Steps to Reproduce

No response

I Have Read the Troubleshooting Guide

radimkarnis commented 1 year ago

Hello @Kymasola,

this issue is usually caused by delays in the UART communication, which can be a result of faulty drivers or the USB-to-UART bridge.

See this similar issue: https://github.com/espressif/esptool/issues/280#issuecomment-907622126

A possibility is to use a configuration file and increase the timeouts used by esptool.

Please try to do this and let me know if that helped. Thanks!

hhartzer commented 9 months ago

I'm getting this error as well with 4.7.0. I tried setting mem_end_rom_timeout = 10, but it still seems to timeout rapidly.

lawrencebensaid commented 4 months ago

Any update on this? I have the same issue. Feels like I've tried everything..

Stan-T889 commented 4 months ago

Uploading stub...

A fatal error occurred: Failed to write to target RAM (result was 01070000: Operation timed out) Failed chip erase: uploading error: exit status 2

The same syndrom in my lab. After updating the CP2104 driver, the result is the same. Doubt that the problem is chip related, due to " ... chip is ESP32-D0WD-V3 (revision v3.1) "

kiler129 commented 3 months ago

@lawrencebensaid @Stan-T889:

If you're on macOS this is most likely issue with WCH CH3xx UART chipset. Either use a different one (e.g. legitimate FTDI, RPi or similar), or if you trust it you can install https://github.com/WCHSoftGroup/ch34xser_macos This isn't a new problem and nothing to do with esptool - https://meshtastic.discourse.group/t/failed-to-write-to-target-ram-result-was-01070000/3874/25