Flashing ESP8266

Recently I got a very cool device – a tiny ESP8266 development board from Olimex (MOD-WIFI-ESP8266-DEV).  Why is it cool? Because it’s basically a micro-controller with embedded WiFi capabilities and TCP/IP stack which you can access via AT commands but it’s not the main coolness, the main coolness is that you can write entire program and upload it into the chip using Arduino Core or Sming if you like C or other platforms like Smart.js if you prefer JavaScript or NodeMCU for Lua. In such program you don’t need to use AT commands at all, instead you can open a TCP/IP socket directly and connect to a server or, actually, create your own small Web server. This chip is a highly integrated SoC which includes Tensilica’s L106 32-bit core processor, SRAM, power management unit, and a number of interfaces – I2C, SPI, SDIO and a number of free GPIO pins. And you can get it less than £2!

P1000453

The Bad

For flashing the board, uploading my programs and data I also bought USB/RS232 adapter with 3.3V support. This one:

P1000454

It looks pretty slick and contains a chip which looks like a USB to RS232 converter from FTDI. I connected it to my Windows 10 machine and it was recognized as  FT232R USB UART and the driver was downloaded and installed correctly.

In order to experiment with the device I did the following:

  • Installed ESP8266 platform from Arduino Core for ESP8266
  • Installed ESP8266 SPIFFS (flash file system) tool as described here
  • Cloned Arduino Core for ESP8266 repository in order to get access to the examples

The first example I used (it was HelloServer) worked like a charm. I just opened it in Arduino app, compiled and flashed to the device – no problem. Then I stared to play with the next one (FSBrowser) which requires SPIFFS. It’s a quite solid example of a more or less proper Web-server with a main page in a form of a htm file, JavaScript files and even a favicon. I compiled and flashed the program – worked, I started to upload the file system image prepared by mkspiffs automatically by using Tools->ESP8266 Sketch Data Upload menu item and the flashing process started interrupting in random times with this message:

Uploading 1028096 bytes from to flash at 0x00100000
............warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_DATA) failed
warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04
error: espcomm_upload_mem failed
SPIFFS Upload failed!

After some experimenting with the flashing utility (esptool) I found out that I can actually upload compiled program (not a SPIFFS image) into the same memory area 0x00100000 without a problem (!) and it made me thinking that there must be some difference in the files content. I checked the files and found out that the file produced by mkspiffs contains a lot of sequential 0xFFs (11111111). I forcefully replaced them with 0xAAs (10101010) just for sake of the experiment and tried to upload the file. It worked!

Initially I assumed that the there is a RS232 timer synchronization problem in ESP8266, but then I searched the Web and it seemed like I’m not alone having this problem, it’s quite common and tends to appear on Windows platforms. It looks like the driver starts sending 0x00 instead of 0xFF at random moments when it recognizes a fake FTDI chip! And indeed, my chip has date-code 1412-G which is, according to this report, fake.

The Good

After ordering a bit more other (a bit more expensive than the first one) USB to RS232 adapters, I started thinking what I can use to flash my ESP8266 while I’m waiting for the new (and hopefully genuine) adapters to come. I decided to try my Arduino UNO even though it doesn’t have 3.3V support. Yes, I know, it’s not recommended and you can burn your ESP8266 chip, but I couldn’t wait.

So, I connected the reset pin to the ground putting all the pins in the high-impedance state and effectively disconnecting the micro-controller from the board (some pins do have other connections though, like pin #13). I also connected:

  • Ground Arduino <-> Ground Olimex ESP
  • TX Arduino pin #1 <-> Olimex ESP pad 3/GPIO1
  • RX Arduino pin #0 <-> Olimex ESP pad 4/GPIO3.

P1000460

Everything worked and I was manged to upload the SPIFFS image and the program without a problem.

The Ugly

You can try to do the same, but be aware that using Arduino UNO (or similar board) for programming ESP8266 is risky and you can potentially damage both devices.

You may also like...

4 Responses

  1. Rudsom says:

    I solved the flashing upload problem by removing the USB device driver and reinstalling maneger with the website of FTDI driver http://www.ftdichip.com/Drivers/VCP.htm.
    I use Windows 10.

    • Sergey Anisimov says:

      Yeah, I tried that, didn’t help in my case. I downloaded the driver in the assumption that the originally installed one was outdated, nope, it wasn’t.

  2. Horacio says:

    This solved my problem. Thks!

Leave a Reply

Your email address will not be published. Required fields are marked *