-->
Page 1 of 2

Programming Mode Behavior

PostPosted: Tue Oct 06, 2015 1:16 am
by JohnSL
I'm trying to understand how the programming circuit works for the NodeMCU Devkit, as documented here:

https://github.com/esp8266/Arduino/issu ... -122993574

When entering programming mode, it does the following:

GPIO0 low, RST high for 0.75ms
GPIO0 high, RST high for 0.75ms
GPIO0 high, RST low for 0.75ms
then both back to high.

How does this work? I thought you needed to have both GPIO0 and RST low at the same time in order to enter programming mode. But clearly the above works (I attached a scope and verified that it's working this way). How does it cause the ESP to enter programming mode?

Re: Programming Mode Behavior

PostPosted: Tue Oct 06, 2015 10:07 am
by dkinzer
JohnSL wrote: I thought you needed to have both GPIO0 and RST low at the same time in order to enter programming mode.
Not quite. As long as RST is low the device does nothing - it is being held in reset. The "magic" happens when the device begins executing when it examines the state of the GPIO0, GPIO2 and GPIO15 pins. Depending on the state of those pins it enters one of several different modes.

You mentioned a scope trace attachment but I didn't find one. I suspect that you might be confusing the logic states of DTR/RTS and those of GPIO0/RST.

Re: Programming Mode Behavior

PostPosted: Tue Oct 06, 2015 11:36 pm
by JohnSL
I attached a scope to the circuit board. But, since you asked, I've enclosed a screen capture:
DS1Z_QuickPrint1.png

Yellow is RST and cyan is GPIO0. So GPIO0 goes low for about 0.75ms, followed by both being high for 0.75ms, followed by RST low for 0.75ms. From your description, it would seem like the low RST should appear before (and perhaps during) the low GPIO0. I know when I was using an ESP-01, I would make sure I had both buttons down before releasing either one.

Re: Programming Mode Behavior

PostPosted: Wed Oct 07, 2015 12:28 am
by JohnSL
I was looking closer at the blue LED when it programs, and realized I probably needed to look at a longer timespan. So here is a new capture that shows two pulses:

GPIO0 RST Longer.png


It looks like the second pulse, on the right side of the screen, is what places it into programming mode as both RST and GPIO0 are low for a short while. Given the circuit, I wasn't sure how this could happen, so I took another look at the input pins, DTR and RTS:

DTR RTS Longer.png


Does anyone know the difference between the first two pulses (on the left side) and the next set (near the middle of the screen)? It looks like it's the second set of pulses that puts the chip into programming mode. In other words, what is the reason for the first vs second set of pulses?