Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to connect" #19

Closed
InnovativeIdeas opened this issue Jan 20, 2015 · 46 comments
Closed

"Failed to connect" #19

InnovativeIdeas opened this issue Jan 20, 2015 · 46 comments

Comments

@InnovativeIdeas
Copy link

I used esptools about 2 weeks ago to flash up to the latest Bin images ( from espressif github). in that I went from V0018 0.9.2 to V 020 0.9.4 all worked fine no issues

I now find I cannot communicate with the ESP unit using ESPtools

I m trying CH_PD high, ( direct to 3V3) , pulling GPIO0 low and reseting to enter boot loader mode

I wonder did the boat loader get changed and this is why I can't connect

@pihomeserver
Copy link

Same issue here. Can't get it work :-(

./esptool.py  -p /dev/cu.usbserial write_flash 0x000000 AI-v0.9.5.0\ AT\ Firmware.bin
Connecting...
Traceback (most recent call last):
  File "./esptool.py", line 408, in <module>
    esp.connect()
  File "./esptool.py", line 143, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect

@mizdler
Copy link

mizdler commented Jan 27, 2015

Make sure that you put your device in flash mode.

@pihomeserver
Copy link

GPIO0 is Linked to the ground

@InnovativeIdeas
Copy link
Author

No, theres several issues with esptools/ESP. Ive gone through the software and a logic analyser

The first is that esptools always expects a perfectly formed packet, i.e. it does not throw away characters until it reaches the \0C, hence on some versions , the ESP does not auto baud perfectly and returns a junk character. This gives the an esptools error .

IN other cases the ESP actually boot up in funny baud rate approx 74K. if it doesn't auto baud properly, you will get fail to connect messages,

The ESP boot loader isn't well implemented

@InnovativeIdeas
Copy link
Author

I think everyone on the planet knows about Gpio0 at this stage !

@mizdler
Copy link

mizdler commented Jan 27, 2015

Yeah, but I had the same problem and it turns out that after connecting GPIO0 to ground you must restart the ESP. I mean just unplug it from the power and plug it again.

@InnovativeIdeas
Copy link
Author

Thats what I do all the time, but occasionally I find the ESP does not auto baud correctly and generates framing errors on the serial line, this confuses ESPtools.

I have it working reasonably reliably , I modified esptools to cut down on the sync and also to scan for header rather then just expect it. I'll tidy the code when I get a chance and maybe post it for others, but Im actually writing a native Os/x flash utility at the moment .

@pihomeserver
Copy link

pihomeserver commented Jan 27, 2015

Thanks that's useful

Le 27 janv. 2015 à 14:28, Innovative Ideas notifications@github.com a écrit :

I think everyone on the planet knows about Gpio0 at this stage !


Reply to this email directly or view it on GitHub.

@pihomeserver
Copy link

That is really usefull. I will try this way and check if it works

Le 27 janv. 2015 à 14:31, Mohammad Elahi notifications@github.com a écrit :

Yeah, but I had the same problem and it turns out that after connecting GPIO0 to ground you must restart the ESP. I mean just unplug it from the power and plug it again.


Reply to this email directly or view it on GitHub.

@themadinventor
Copy link
Collaborator

@InnovativeIdeas :

I modified esptools to cut down on the sync and also to scan for header rather then just expect it.

Nice tweak. Scanning for 0xc0 only works during the connect phase; if we lose sync later during a session we'll probably discard the response.
You wouldn't mind sending a PR? Otherwise I'll implement something similar when I get time.

@alesrebec
Copy link

Same issue for me.
Currently my ESP8266 is bricked.

sudo ./esptool.py -p /dev/ttyUSB0 write_flash 0x000000 ../lua/0x00000.bin 
Connecting...
Traceback (most recent call last):
  File "./esptool.py", line 471, in <module>
    esp.connect()
  File "./esptool.py", line 149, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect

Tried with different baud settings too - all returning exception.
GPIO0 on GND. After reset.
Any clues how I can re-flash my ESP?

@alesrebec
Copy link

Ok, found out my problem. Maybe it could solve yours too.
So I tried with a fresh new ESP8266 (they are so cheap that you gotta have at least 5 of them at home) and the new esp was getting the same error.
Well, the problem was in USB UART's GND. I have a different power source for esp's 3.3V and was using only TX/RX for flashing. Forgot to plug UART's GNT on the same GND as esp's.

@themadinventor
Copy link
Collaborator

@alesrebec: Good to hear that you solved it!

It isn't possible*, as far as I can tell, to completely brick the ESP8266. The bootloader resides in ROM and executes before the SPI flash is even initialized.

(The attentive hacker would point out that one could flash an image that specifies an invalid SPI flash clock rate and/or interface width, but looking at the routine at 0x40004644 in ROM, it looks like it'll still use a hard coded configuration 0x5 when booting from UART.)

(* Yeah, it might be possible to trash the OTP ROM containing the MAC address, but not using esptool.)

@nfriedly
Copy link

@alesrebec Thanks! I've been trying to get this to work for like 3 hours before I found that - connecting my ftdi chip's ground to my external power supply's ground fixed it perfectly.

@duslabo
Copy link

duslabo commented Feb 14, 2015

Hi,
Same issue here... Can anybody fixed this issue ? I tried a lot of times, but no luck.

@themadinventor
Copy link
Collaborator

@jeshwanth Did you find a solution? I think I saw you on #esp8266, though a couple of hours too late...

@duslabo
Copy link

duslabo commented Feb 15, 2015

@themadinventor yes found solution.. Thats was the mistake in my circuit :). Forgot to update here... Thank you :)

@jlz3008
Copy link

jlz3008 commented Feb 21, 2015

I solved the problem with a lower speed

jlz@isengard:~$ cp ../../firmware/AI-v0.9.5.0\ AT\ Firmware.bin f.bin
jlz@isengard:~$ ./esptool.py --baud 115200 --port /dev/ttyUSB0 write_flash 0x000000 f.bin 
Connecting...
Traceback (most recent call last):
  File "./esptool.py", line 377, in <module>
    esp.connect()
  File "./esptool.py", line 151, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect
jlz@isengard:~$ ./esptool.py --baud 9600 --port /dev/ttyUSB0 write_flash 0x000000 f.bin 
Connecting...
Erasing flash...
Writing at 0x0007ef00... (100 %)

Leaving...
jlz@isengard:~$

@gSTP
Copy link

gSTP commented Mar 27, 2015

thanks all, problem solved.

all hardware wired up nicely still produced the ugly "failed to connect" error. Just cranked up the external power for arduino nano breakout board to 10V, and that was it:

Connecting...
Erasing flash...
Writing at 0x00000400... (100 %)

Cheers all around :-)

@ColinMiles
Copy link

@alesrebec old discussion just just have to thank you for suggesting connecting the ground of the FTDI to ground of ESP! THANK YOU!! Nowhere had I seen that suggestion other than here.

@nfriedly
Copy link

I'm on a new module (the custom ESP-12E one from electrodragon) and running into this again. It has the Ai Thinker AT command set preinstalled and that works fine; I can interact with it in esplorer and such. But, I can't flash anything new to it.

This build spits out a bit of debug info at 74880 baud when it first boots up and then it switches to 115200 for the "regular" command set. I'm suspecting that this switchover is what's making esptool choke - it fails to connect regardless of what baud I set it to:

Nathans-MBP:esptool nfriedly$ ./esptool.py  -p /dev/cu.SLAB_USBtoUART write_flash 0x00000  ~/Downloads/nodemcu-master-16-modules-2015-07-30-19-07-36-integer.bin 
Connecting...
Traceback (most recent call last):
  File "./esptool.py", line 505, in <module>
    esp.connect()
  File "./esptool.py", line 158, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect

Nathans-MBP:esptool nfriedly$ ./esptool.py -b 74880 -p /dev/cu.SLAB_USBtoUART write_flash 0x00000  ~/Downloads/nodemcu-master-16-modules-2015-07-30-19-07-36-integer.bin 
Connecting...
Traceback (most recent call last):
  File "./esptool.py", line 505, in <module>
    esp.connect()
  File "./esptool.py", line 158, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect

Nathans-MBP:esptool nfriedly$ ./esptool.py -b 115200 -p /dev/cu.SLAB_USBtoUART write_flash 0x00000  ~/Downloads/nodemcu-master-16-modules-2015-07-30-19-07-36-integer.bin 
Connecting...
Traceback (most recent call last):
  File "./esptool.py", line 505, in <module>
    esp.connect()
  File "./esptool.py", line 158, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect

Nathans-MBP:esptool nfriedly$ ./esptool.py -b 9600 -p /dev/cu.SLAB_USBtoUART write_flash 0x00000  ~/Downloads/nodemcu-master-16-modules-2015-07-30-19-07-36-integer.bin 
Connecting...
Traceback (most recent call last):
  File "./esptool.py", line 505, in <module>
    esp.connect()
  File "./esptool.py", line 158, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect
Nathans-MBP:esptool nfriedly$ ./esptool.py -b 1200 -p /dev/cu.SLAB_USBtoUART write_flash 0x00000  ~/Downloads/nodemcu-master-16-modules-2015-07-30-19-07-36-integer.bin 
Connecting...
Traceback (most recent call last):
  File "./esptool.py", line 505, in <module>
    esp.connect()
  File "./esptool.py", line 158, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect

I tried both connection the DTR/RST pins, just pressing the RST/PROG buttons, doing both, etc. Nothing seems to work. Ground is connected correctly and I'm powering the module directly from my USB's 5v line (it has an onboard regulator).

But, like I said, I think the issue is the sudden baud rate switch - @InnovativeIdeas touched on it, but I don't think anyone's explicitly mentioned that it starts at one baud and then switches to another within a second or so.

If it helps, here's what the initial output at 74880 baud looks like:

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 1396, room 16 
tail 4
chksum 0x89
load 0x3ffe8000, len 776, room 4 
tail 4
chksum 0xe8
load 0x3ffe8308, len 540, room 4 
tail 8
chksum 0xc0
csum 0xc0

2nd boot version : 1.4(b1)
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 @ 1000

and then it switches to 115200 and outputs something along these lines:

Ai-Thinker Technology Co. Ltd.

ready
WIFI CONNECTED
WIFI GOT IP

Update: I found a workaround: use https://github.com/nodemcu/nodemcu-flasher to flash NodeMCU onto the module (once) and then it plays nice with esptool.py after that so you can flash anything you want.

The only catch is that it's windows-only for the moment. But, you can use one of the windows 30-day trial vms that MS provides for testing websites in IE. (Believe it or, not, this actually works: I'm on a mac and used a virtualbox image just now. You just have to give the VM access to your usb-uart or whatever you're using.)

Update 2: I think I've just dis-proven my theory about the baud rate switching being the source of the issue. I had a different module, and esp-01 also from electrodragon, with the same build of the Ai Thinker firmware - it gives the exact same output at 74800 and then at 115200, but esptool.py can write to it just fine. So I'm out of ideas about the cause. I'll leave this here since at least the workaround is useful.

@bislinux
Copy link

Just few bullet points to sum up

  1. Connect EN to 3.3v
  2. Connect GPIO0 to GND
  3. Connect GPIO15 to GND to flash
  4. Remember to connect the reference GND to the GND of esp8266
    5.Lastly correctly match the tx and rx lines

To flash the firmware
./esptool.py --baud 115200 --port /dev/ttyUSB0 write_flash 0x000000 ../nodemcu-flasher-master/Resources/Binaries/nodemcu_integer_0.9.5_20150318.bin

hope it helps

@minouye
Copy link

minouye commented Sep 20, 2015

@nfriedly Thanks for the workaround! Using NodeMCU Flasher inside a Windows VM worked for me as well--played nice with esptool after that.

@ToM-Korn
Copy link

I had the same problem...
I had a LED at GPIO2 (with a 1k Resistor) just for testing.
One problem seems to be, that if GPIO2 is not high at the moment of programming it does not work.
Having GPIO2 floating (not connected to anything) solved it. But as some docs say it would be better to have it high (3.3V) -> see here:
http://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations
Note :- GPIO2 It is considered safer to pull it high with a resistor on boot rather than leave it floating to avoid possible chip damage if pin is pulled high by your program but also see http://www.esp8266.com/viewtopic.php?f=6&t=3862&p=22524#p22524.

So I'd recommend:

  1. check if your pins are set like in the table
  2. check if the GND of your FTDI is connected to GND of ESP8266 (otherwise the would have different potentials)
  3. set your baudrate to 115200 (worked fine for me all the time)

@iitca
Copy link

iitca commented Nov 3, 2015

Hi!

I had the same problem. But I solved it by also connecting CH_PD pin to the VCC

@angelvil
Copy link

Hi. I have the same problem, but after to connect gnd to ftdi say: faled to connect. any opinion?
captura

projectgus added a commit that referenced this issue Feb 25, 2016
@projectgus
Copy link
Contributor

Closing this issue as the README now covers most of the likely problems.

Please open a new issue if you've tried the troubleshooting steps in the README and nothing works.

@MuhsinFatih
Copy link

I had been trying to fix this problem with my esp8266 12e for days. I tried a lot of solutions to fix it. Tried esptool, arduino ide, different baud options etc all kinds of stuff. Just now figured out that it was very stupidly simple solution for me. Just plugged it into a windows machine (I had been using a macbook) and it worked with arduino ide with no change on the default esp programming options. In case it helps, i will tell a little about my setup: I have arduino with the processor removed so I use it for its serial pins. esp's rx goes to arduino's rx (with a voltage divider of course) and tx to tx (no divider). I have the reset line of esp connected to 3.3v and a button to short it to gnd (apologies for ignorance, is this called a pullup resistor?). I guess you know the rest of the connections if you're at this stage anyways.
(btw, how did I comment a closed issue? Is this normally allowed? Apologies if I made a mistake)

@projectgus
Copy link
Contributor

Thanks for reporting your bug and providing so much detail.

You didn't make a mistake, there's a known bug with esptool.py when using an Arduino as the serial converter (see #82) and I think you've hit on the same issue.

There's no problem commenting on closed issues, however I think #82 is the correct issue in this case. If you don't mind, please subscribe to that issue (there's a button in the right-hand column) and you'll be notified once there's any update including a fix to test out (hopefully soon.)

@MuhsinFatih
Copy link

Thanks! I subscribed. I will be waiting for the solution. Good luck!

@julr08
Copy link

julr08 commented Apr 13, 2016

Thanks a lot, my problem was the Ground must be the same. the solution for me.

@gourabdg47
Copy link

My blue light wont get off and random characters are showing in the serial monitor, need help ...

@projectgus
Copy link
Contributor

@Blackhalk , please go through the troubleshooting suggestions here: https://github.com/themadinventor/esptool#troubleshooting

@ukrsms
Copy link

ukrsms commented May 27, 2016

reading these issues I hoped I'd find the one which help me, but unfortunately any of them was the one.
But today I returned again to my ESp-12 module and decided to verify signals at RX and TX with oscilloscope. I was surprised to see that at RX pin there was voltage only near 10V for HIGH state. as a result i found that voltage drop is caused by finite input impedance of the RX pin of ESP. The matter is that I used 5V logic USB-UART so I used a resistor divider with two resistor (10k and 20k [see below)]
1
In such a case signal at RX input was very small and ESP didn't response it.
After I replace the bigger resistor with 6.8k and replace the resistors vice versa I forced the ESp to response!
Also I want to add that at the beginning the Module work Ok but stopped to react after an unsuccessful flashing

@MuhsinFatih
Copy link

@ukrsms off topic: man any doesn't mean none. This is mistaught by english teachers 99.999% of the time :D Just as a friendly reminder ;)

@brynnb
Copy link

brynnb commented Jul 17, 2016

Having the same issue as @nfriedly - I have an ESP-12-E and communicating with minicom is working fine, but esptools won't connect. Unfortunately I'm still waiting on my USB/TTL converter so using the NodeMCU flasher isn't an option.

@projectgus
Copy link
Contributor

@brynnb : nfriedly's problem turned out to be the ground connection from the USB/serial converter. How are you connecting the ESP-12-E now if you don't have a USB/TTL converter on hand?

The README has sections on what connections need to be made, and some steps to follow if things aren't working correctly: https://github.com/themadinventor/esptool#entering-the-bootloader

@brynnb
Copy link

brynnb commented Jul 18, 2016

@projectgus I have it wired directly to the GPIO pins of my Raspberry Pi.

Fairly sure I have wiring correct, I will double check in the future using that guide since I didn't see it before. But at a glance it looks to be the same advice I found/followed elsewhere.

@ReinVelt
Copy link

ReinVelt commented Dec 11, 2016

I had the same problems, tried everything and nothing worked.
After i replaced the USB cable everything worked perfectly!

@SteveBaker
Copy link

I've been spending the last 24 hours fighting a "Failed to connect" problem - I had a new batch of ESP 12F's arrive - and when I tried to program one, I got the error. According to the AT-GBV command, it has a newer version of the boot loader than any of my older ESP chips (Dated Dec 2nd 2016!) - and of course I naturally assumed that they broke something! But after trying my best to diagnose it by hacking around in esptools.py (and my Python skills seem to have rusted rather badly - so that didn't go well) - I eventually gave up and decided to try a second board from the same batch...lo and behold, it worked perfectly...so it looks like I had a bad ESP board. Fortunately, at $2 - who gives a damn!

Good news! The Dec 2nd build works OK!

Moral of the story: Before assuming the worst - try another ESP board! :-)

@iampt
Copy link

iampt commented Mar 21, 2019

Flash any firmware to ESP8266 using following steps..

  1. load blank sketch to arduino (without any wiring)
  2. unplug the usb and do this connection
    ESP --> ARDUINO
    GPIO0 -> GND
    GND -> GND
    RX -> RX
    TX -> TX
    3V3/VCC -> 3.3V
    CH_PD/EN -> 3.3V

plug in the usb to the power source.

download the official flasher from this link, unzip and open the app https://drive.google.com/file/d/0B3dUKfqzZnlwVGc1YnFyUjgxelE/view

download the firmware from this link, unzip it and open it in flasher app
www.electrodragon.com/w/File:At_firmware_bin1.54.zip

make sure to check and select accurate com port in flasher
click on download

That's it, you may open the serial monitor now and perform AT commands.

if AT commands are not working then unplug usb from the power source, remove GPIO0 pin from GND and plug in the USB to power source. open serial monitor and recheck the AT commands.

HOPE THIS HELPS. THANK YOU! :)

@aog1971
Copy link

aog1971 commented Apr 21, 2019

Just few bullet points to sum up

  1. Connect EN to 3.3v
  2. Connect GPIO0 to GND
  3. Connect GPIO15 to GND to flash
  4. Remember to connect the reference GND to the GND of esp8266
    5.Lastly correctly match the tx and rx lines

To flash the firmware
./esptool.py --baud 115200 --port /dev/ttyUSB0 write_flash 0x000000 ../nodemcu-flasher-master/Resources/Binaries/nodemcu_integer_0.9.5_20150318.bin

hope it helps

Thanks this has worked for me, doing these steps I could put flash mode and put the firmware

@SirSeko
Copy link

SirSeko commented May 4, 2019

Just few bullet points to sum up

  1. Connect EN to 3.3v
  2. Connect GPIO0 to GND
  3. Connect GPIO15 to GND to flash
  4. Remember to connect the reference GND to the GND of esp8266
    5.Lastly correctly match the tx and rx lines

To flash the firmware
./esptool.py --baud 115200 --port /dev/ttyUSB0 write_flash 0x000000 ../nodemcu-flasher-master/Resources/Binaries/nodemcu_integer_0.9.5_20150318.bin

hope it helps
Thank you!! I´ve been troubleshooting my unit for a month and finally found this solution!

@flaviostutz
Copy link

Thats what I do all the time, but occasionally I find the ESP does not auto baud correctly and generates framing errors on the serial line, this confuses ESPtools.

I have it working reasonably reliably , I modified esptools to cut down on the sync and also to scan for header rather then just expect it. I'll tidy the code when I get a chance and maybe post it for others, but Im actually writing a native Os/x flash utility at the moment .

Have you open sourced it?!

@dimitre
Copy link

dimitre commented Aug 11, 2020

I can always write only once per chip. to write again in the same chip I have to unplug USB or the chip and plug it again. If I don't do that I get the infamous

Connecting........_____....._____....._____....._

@Odissine
Copy link

Odissine commented Oct 4, 2020

I still have the same issue to ... and to avoid buy a usb cable, is there a way to know if a Mini USB cable is for power only or for data too ... I think maybe the problem is here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests