ESP IoT pHAT Flashing


I have found some quite interesting firmware that I would like to get onto the ESP IoT pHAT if possible. Here is a link to the firmware:

There is a python utility that can be used to flash the firmware available here:

I have tried it but it does not connect. I suspect this is because the ESP8266 isn’t in a flash-able state which can only be achieved by having the GPIO 0 pin of the ESP8266 grounded when reset.

Can you provide any instructions as to how this can be achieved? or at lease let us know what Pi GPIO pins are mapped to what ESP8266 pins.


Mike :)

Hi Mike! You’re absolutely correct, we’re working on a learning portal article to cover this. :-)

The two pins you’ll need to toggle are:

  • BCM#17 is connected to RESET
  • BCM#27 is connected to GPIO0

Hopefully you know what to do with that information already, if not watch this space for an article!

I have managed to get the ESP ready by executing the following python:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM) # set board mode to Broadcom


GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)

GPIO.output(27, 0)
GPIO.output(17, 1)
GPIO.output(17, 0)

but when I try out the esptool (just trying to get something before I attempt a flash) the following happens:

Maybe I will wait for your instructions ;)

While I was tinkering I used the following command (requires wiringPi to be installed!):

gpio write 2 0; gpio write 0 0; sleep 1; gpio write 0 1; python -p /dev/ttyAMA0 -b 115200 write_flash 0x00 firmware.bin

This will all be wrapped up in some helpers we’re working on longer term!

so you’d pull GPIO 0 down low first then high (with a pause in between)?

@RogueM that command is using wiringPi (which has it’s own pin numbering).

The toggled pin (wiringPi #0) is to reset the ESP8266 and the other pin is to put it into programming mode, the sleep is belt and braces and far longer than should be necessary. :-)

oh, yeah I realise that, I meant that @mikehole is pulling GPIO 17 high then low, rather than the other way around, which is the problem I suspect. And, yeah, I realise it got confusing when I decided to take shortcuts in expressing the pin numbering system ;-)

Bingo! I was leaving the ESP GPIO low (so the light on the board stayed on)

Next step flashing :)

1 Like

Hurrah! What firmware are you going to use?

ESP Link:

It’s on and connected to my WiFi…

Sweet! Let us know how you get on. :-)

If you wanted to do a little write-up of the process we could put it up on the Learning Portal. :-)

Sure will!

Now this is cool, turn the console back on and bingo there it is:

So the bad news is that I can not now get the ESP8266 back into a flashing mode :/ I wanted to try some of my own binaries but each time I try to flash anything it doesn’t connect

Can you paste your full flashing command here and the output?

Just remembered that I turned the console back on to show off the console via the web. So switched it off again and all working.

Apologies for wasting time sure you all have better things to do!

Just glad you figured it out! An easy gotcha that one. :-)

Actually while we are at it do you know what firmware the pHAT comes with? I have tried to get this one but once flashed I can’t get anything out od minicom.

Here is the command used to flash:

gpio write 2 0; gpio write 0 0; sleep 1; gpio write 0 1; python …/esptool/ -p /dev/ttyAMA0 -b 115200 write_flash -fs 32m -ff 80m 0x00000 boot_v1.1.bin 0x1000 user1.bin 0x7C000 esp_init_data_default.bin 0x7E000 blank.bin

this is the firmware info a ESP-IoT pHAT gives me out of the box:

AT version: 8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build: Sep 11 2015 11:48:04

which I ~think~ is this one:

but @jon has to confirm.

If I can find a thread about compiling on Windows I will be rocking :s

Cygwin on Windows should give you the tools?

disclaimer: I am a complete n00b when it comes to the ESP8266, don’t take ~anything~ I say on the subject with any degree of reliability, just suggestions with a possible, if coincidental, value!