Monday, January 11, 2016
ESP8266 reset and booting
When I got my first esp-01 module, I found there was a lot of mis-information about how to reset and flash the modules. For the esp-01, pulling GPIO0 low while pulsing reset low is the easy and common way to get it to enter the bootloader for flashing. When using modules like the ESP-12 that have most of the available pins broken out, things get a little more complicated.
I noticed the issue when I tried wiring a module for deep sleep mode by connecting GPIO16 to RST. In deep sleep mode only the RTC is running, and instead of an internal software wake-up timer like some other MCUs, the esp8266 has to be woken up by a pulse on RST generated by the RTC on GPIO16. With the GPIO16 to RST connection, I had difficulty resetting the module with a 270 Ohm resistor to ground. The reason is that GPIO16 is not a pull-up, it is in output high mode. The solution is to reboot the module using the EN pin (also labeled CH_PD on some modules) instead of RST. The difference between RST and EN is that bringing EN low powers down the whole chip including the RTC.
I did some additional testing of the chip boot-up by holding RST low and EN high. While in reset, the chip keeps GPIO0, GPIO2, and GPIO15 high with an internal 33K pull-up to Vcc. If reset is then released, the chip will boot in SDIO mode, which is really only good for hooking it to a raspberry pi. ESP-01 modules have GPIO15 connected to ground, but for modules like the ESP-12 it is necessary to pull GPIO15 low during boot.
After booting up, I checked the default state of most of the pins. TX0 is high, which is the UART idle state, while RX0 has a weak pull-up so that it is not floating. GPIO0 has a weak pull-up, GPIO2 is high, GPIO4 is low, GPIO5 is high, and GPIO15 stays low, even with a pull-down resistor.
With ESP-01 modules, I was using my zero-wire auto-reset circuit with DTR connected to GPIO0 in order to flash the modules. For projects that were using GPIO0, this meant having to disconnect the DTR line after flashing. I'm now working on a circuit that doesn't require DTR, and will hold GPIO0 and GPIO15 low for a short while after the module is rebooted by toggling EN.
I haven't found any information that indicates how long GPIO0 and GPIO15 need to be held low in order to enter the bootloader, so I'll need to experiment with the resistor and capacitor values. Using a 15K resistor and 0.1uF capacitor keep GPIO0 and GPIO15 low for about 1ms after startup.
No comments:
Post a Comment