Unable to flash ESP32

shih91
Posts: 9
Joined: Wed Nov 16, 2016 3:09 am

Unable to flash ESP32

Postby shih91 » Thu Nov 24, 2016 3:03 am

Hey guys,

I am having trouble to flash the ESP32 after updating to the latest esp-idf. After i used "make flash", these 2 errors occur pretty often:

Code: Select all

[b]A fatal error occurred: Failed to write to target RAM (result was 0x1, 0x7, 0x0, 0x0)[/b]
~/esp3/esp-idf/components/esptool_py/Makefile.projbuild:47: recipe for target 'flash' failed
make: *** [flash] Error 2
~/esp3/esp-idf-template# make flash
~/esp3/esp-idf/make/component_common.mk:1: Deprecated feature: No longer necessary to include component_common.mk from ~/esp3/esp-idf-template/main/component.mk
Flashing binaries to serial port /dev/ttyUSB0 (app at offset 0x10000)...
esptool.py v2.0-dev
Connecting...
Uploading stub...
Running stub...
Stub running...
Attaching SPI flash...
Configuring flash size...
Writing at 0x00001000... (100 %) 
[b]A fatal error occurred: Failed to write to target Flash after seq 0 (result was 0xc1, 0x0)[/b]
~/esp3/esp-idf/components/esptool_py/Makefile.projbuild:47: recipe for target 'flash' failed
make: *** [flash] Error 2
Sometimes it will be able to flash... until a few percent before it will hang or shows this error:

Code: Select all

Flashing binaries to serial port /dev/ttyUSB0 (app at offset 0x10000)...
esptool.py v2.0-dev
Connecting...
Uploading stub...
Running stub...
Stub running...
Attaching SPI flash...
Configuring flash size...
Wrote 16384 bytes at 0x00001000 in 1.4 seconds (94.3 kbit/s)...
Hash of data verified.
Writing at 0x00020000... (17 %) 
[b]A fatal error occurred: Failed to write to target Flash after seq 4 (result was 0xc1, 0x0)[/b]
~/esp3/esp-idf/components/esptool_py/Makefile.projbuild:47: recipe for target 'flash' failed
make: *** [flash] Error 2
I just changed to a new ESP32 and did the same thing but same error occurs. It doesn't seem like it is because of the flash memory right? Any idea what did I miss?
Last edited by shih91 on Thu Nov 24, 2016 3:42 am, edited 1 time in total.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Unable to flash ESP32

Postby kolban » Thu Nov 24, 2016 3:26 am

What baud rate are you using to communicate with the ESP32?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

shih91
Posts: 9
Joined: Wed Nov 16, 2016 3:09 am

Re: Unable to flash ESP32

Postby shih91 » Thu Nov 24, 2016 3:41 am

i'm using 115200.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Unable to flash ESP32

Postby kolban » Thu Nov 24, 2016 4:01 am

What is the nature of your physical environment? What kind of "connector" are you using between your PC and your ESP32? Are you running Linux native or in a virtual machine? What distribution of Linux are you running? How long is the cable between your PC and the ESP32? What is the providence (what kind of) ESP32 module are you using? Are there any messages logged to the /var/log files that might indicate any errors or issues?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Unable to flash ESP32

Postby WiFive » Thu Nov 24, 2016 4:15 am

kolban wrote:What is the providence (what kind of) ESP32 module are you using?
Provenance?

shih91
Posts: 9
Joined: Wed Nov 16, 2016 3:09 am

Re: Unable to flash ESP32

Postby shih91 » Thu Nov 24, 2016 4:19 am

Sorry for my lack of information.

I'm using ESP32-Wroom module. I soldered jumper wires directly onto the module and plug the TX and RX jumpers into a FTDI 232H module which i used to flash the ESP32.

I am using a Linux Ubuntu 16.04.1 LTS running on VirtualBox using Windows 10 Education.

I was able to flash the ESP32 previously using the same setup but since after i updated the esp-idf, i could not flash anymore. =/

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Unable to flash ESP32

Postby kolban » Thu Nov 24, 2016 5:04 am

No problems on the information ... worst thing that may happen is the community asks more follow up questions and delay finding a solution ... but we are all learning here and all shooting for the same goals. Not knowing your electronics background ... would you be able to draw a schematic or take an annotated photo of the setup? What is going through my mind is to check that you have a GND line between your USB UART and the GND of the ESP32. I'm also curious on your setup of the EN and GPIO0 pins of the device ... both of which commonly come into play when flashing. For example, no common ground ... something bad would happen, a floating GPIO 0 ... something bad would happen etc etc.

I am also hearing you say "it worked with a previous ESP-IDF but not with the current". That would immediately point to a software configuration issue ... but co-incidences can and do happen so I'd be looking to check that the circuits were good. My experience with switching to newer and newer ESP-IDFs has been very positive. I can't recollect a single regression ... now that doesn't mean that there weren't or won't be in the future (these things happen) but so far so good.

In addition to new levels of the ESP-IDF being laid done, you might also want to check that the "sdkconfig" that you expect is in fact in effect. This is the file generated by running "make menuconfig".

I too am using Ubuntu on VirtualBox on Windows 10. We might also want to look at the VirtualBox settings for USB and make sure that you are using good settings (I'm using default). Also that nothing on the host OS (Windows) might be "tinkering with" USB access ...
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

shih91
Posts: 9
Joined: Wed Nov 16, 2016 3:09 am

Re: Unable to flash ESP32

Postby shih91 » Thu Nov 24, 2016 5:29 am

Thank you so much for the prompt reply.

http://static.sparkfun.com/assets/home_ ... p_bb-2.png

I refered to this hookup guide except that the GPIO0 were connected directly to 3.3V or GND (whenever necessary) instead of using a DIP switch as shown in the picture.

I tried isolating ESP32 and FTDI232H modules together (I was testing with other hardware also). In other words, I connected the 3.3V GND of ESP32 and FTDI232H modules together, but it did not help at all; same problem persists.

I am pretty sure I did not meddle with the sdkconfig file between the time when it worked (about 7 days ago?) and today. I tried cloning ESP-IDF into another folder and copied my application's main.c file over to flash from there too. I also tried changing the flash size and the flash clock speed. Again, nothing works =(

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Unable to flash ESP32

Postby kolban » Thu Nov 24, 2016 5:56 am

The non-deterministic nature of the puzzle makes me think of noise somewhere on the signal lines. You might try some shorter wires/cables. Another thought is the power to the ESP32. We might want to try and place a large value capacitor (say 10uF) between 3.3V and GND as close to the ESP32 as possible. This would give a reservoir to pull from if there is a sudden load on the system.

I also want to make sure that you didn't/don't connect the 3.3V output of the UART anywhere near the ESP32. The UART and the ESP32 must share a common GND but don't bring the 3.3V source from the UART anywhere near the ESP32. Doing that even briefly may result in fatal damage to a component.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

shih91
Posts: 9
Joined: Wed Nov 16, 2016 3:09 am

Re: Unable to flash ESP32

Postby shih91 » Thu Nov 24, 2016 8:07 am

Well, I got it to work already. Turns out it was my USB setting on VirtualBox. I was using USB 2.0 (EHCI) controller. Apparently, it only works with USB 3.0 (xHCI) controller. Hmmm...

Thanks a lot for your help nonetheless!

Do you mind explaining why I should not connect the USB UART's 3.3V to ESP32 though? I was doing that and it appears that ESP32 will go into a reboot loop.

Who is online

Users browsing this forum: Bing [Bot] and 298 guests