From charlesreid1

Firmware Issues

I have had zero luck communicating with the ESP8266 chip. I can't even get the LEDs on the board to light up.

The solution [1] is to reflash the firmware with the AT command binary image. This will, I guess, get the chip to accept AT commands on the serial RX/TX pins.

Downloading AT Firmware Image

Using this guide from Dave Vandenbout at Xess.com [2], which covers reflashing the ESP8266, I downloaded the AT Command firmware binary image, which was version 0.9.2.2.

Link to firmware binary on Google Drive (warning: may disappear at some point) is here: https://drive.google.com/file/d/0B3dUKfqzZnlwdUJUc2hkZDUyVjA/view?usp=sharing

File name of zipped-up binary image is ESP8266_AT_V00180902_02_baudrate watchdog added.zip

Esptool Flashing Software

In the Xess.com guide, Dave uses the Espressif-provided flash program, which is a Windows executable. Fortunately, I am blessed enough not to have any Windows computers, and will not touch it with a ten foot pole. I used the Python/PySerial-based esptool.py from themadinventor on Github [3] instead.

Downloading

You can download esptool from Github: https://github.com/themadinventor/esptool

Installing

You can install esptool manually using python setup.py build && python setup.py install. This will require the Pyserial library.

Alternatively, you can install it using pip: pip install esptool

Using

The basic usage of esptool is as follows:

$ esptool.py -h
usage: esptool [-h] [--port PORT] [--baud BAUD]
               {load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash,verify_flash,erase_flash,version}
               ...

esptool.py v1.1 - ESP8266 ROM Bootloader Utility

positional arguments:
  {load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash,verify_flash,erase_flash,version}
                        Run esptool {command} -h for additional help
    load_ram            Download an image to RAM and execute
    dump_mem            Dump arbitrary memory to disk
    read_mem            Read arbitrary memory location
    write_mem           Read-modify-write to arbitrary memory location
    write_flash         Write a binary blob to flash
    run                 Run application code in flash
    image_info          Dump headers from an application image
    make_image          Create an application image from binary files
    elf2image           Create an application image from ELF file
    read_mac            Read MAC address from OTP ROM
    chip_id             Read Chip ID from OTP ROM
    flash_id            Read SPI flash manufacturer and device ID
    read_flash          Read SPI flash content
    verify_flash        Verify a binary blob against flash
    erase_flash         Perform Chip Erase on SPI flash
    version             Print esptool version

optional arguments:
  -h, --help            show this help message and exit
  --port PORT, -p PORT  Serial port device
  --baud BAUD, -b BAUD  Serial port baud rate used when flashing/reading

I don't understand the difference between the memory and the flash (I think the flash is where it boots from, the memory contains the various instructions it can execute once it starts up), but we want to write an AT Commands firmware binary image to the flash on the chip.

This means we will be using write_flash:

$ esptool.py write_flash -h
usage: esptool write_flash [-h] [--flash_freq {40m,26m,20m,80m}]
                           [--flash_mode {qio,qout,dio,dout}]
                           [--flash_size {4m,2m,8m,16m,32m,16m-c1,32m-c1,32m-c2}]
                           [--no-progress] [--verify]
                           <address> <filename> [<address> <filename> ...]

positional arguments:
  <address> <filename>  Address followed by binary filename, separated by
                        space

optional arguments:
  -h, --help            show this help message and exit
  --flash_freq {40m,26m,20m,80m}, -ff {40m,26m,20m,80m}
                        SPI Flash frequency
  --flash_mode {qio,qout,dio,dout}, -fm {qio,qout,dio,dout}
                        SPI Flash mode
  --flash_size {4m,2m,8m,16m,32m,16m-c1,32m-c1,32m-c2}, -fs {4m,2m,8m,16m,32m,16m-c1,32m-c1,32m-c2}
                        SPI Flash size in Mbit
  --no-progress, -p     Suppress progress output
  --verify              Verify just-written data (only necessary if very
                        cautious, data is already CRCed

Circuit for Flashing ESP8266

Flashing the ESP8266 requires connecting various pins in particular sequences. We can do this by setting up a circuit on a breadboard to enable us to flash the chip. We should (I hope, fingers crossed) only have to do that once.

To flash the board, we must reset the ESP8266 board (using the RST reset pin), while holding the GPIO0 pin low.

We must use 2.2K pullup resistors for the chip-select and reset pins to keep the ESP8266 enabled.

Two buttons, for program and reset, will be provided so we can pull the GPIO0 and RST pins to ground.

Procedure

Set up the breadboard. It's a bit complicated, so be patient and double-check your work.

ESP8266 Reflashing Schematic.png

ESP8266 Reflashing BreadboardPic.jpg

Now plug it in. You should see the serial device show up in /dev/tty.usbserial. You're set to flash.

Enter the flash programming mode by holding down the PROG button and then pressing and releasing the RESET button.

Now actually flash the board with esptool.py:

$ esptool.py write_flash 0x00000 v0.9.2.2\ AT\ Firmware.bin

esptool.py v1.1
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/esptool.py", line 1233, in <module>
    main()
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/esptool.py", line 1142, in main
    esp = ESPROM(args.port, initial_baud)
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/esptool.py", line 71, in __init__
    self._port = serial.Serial(port)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/serial/serialutil.py", line 182, in __init__
    self.open()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/serial/serialposix.py", line 247, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'

This error comes from the fact that my USB serial device was appearing as /dev/tty.usbserial, not as /dev/ttyUSB0. Simple fix:

$ sudo ln -fs /dev/tty.usbserial /dev/ttyUSB0

Now try again:

$ esptool.py write_flash 0x00000 v0.9.2.2\ AT\ Firmware.bin
esptool.py v1.1
Connecting...

A fatal error occurred: Failed to connect to ESP8266

Well crap.


Connection Errors

Apparently no commands work, because the ESP chip does not show up anywhere at all:

$ esptool.py chip_id
esptool.py v1.1
Connecting...

A fatal error occurred: Failed to connect to ESP8266

Nothing.

I tried holding down the program button then pushing the reset button, and let them go and tried the command again. Nothing.

I tried holding down the program button then pushing the reset button, then running the command while they were both pushed down. Nothing.

I tried holding just the program button down while I ran the command. Nothing.

I tried holding just the reset button down. Nothing.

Maybe my chips are all bunk.

Flags