0
Connections:
RX -> TX
TX -> RX
GND -> GND
VCC -> 3.3v
CH_PD -> 3.3v
GPIO0 -> GND (flash mode)

enter image description here

Click the picture to make it larger/more readable.

I am trying to flash an ESP8266-01 using a Sparkfun FTDI Basic. Above is my diagram. I am using a 16v max in to 3.3v out to handle the drop from my FTDI (5v) to the ESP8266 (3.3v). I am using a logic converter to change the 5v to 3.3v for the Rx/Tx. I have done this successfully (but with spotty results), flashing the ESP8266 with an Arduino Uno. Then I tried to reprogram the ESP8266 with my Arduino Uno and it kept giving me an error that ends with:

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

So I decided to troubleshoot by seeing if the problem was with my Uno, because it is fairly old - and I got an FTDI Basic - with the basic I get a little further - the whole output when I try to upload is:

Archiving built core (caching) in: /var/folders/lv/lj7d61jn61x_8knqdhghk_pc0000gn/T/arduino_cache_244685/core/core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_1M64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____4d67f8743716b2ecc4b09162f2cdb6e3.a
Sketch uses 241193 bytes (25%) of program storage space. Maximum is 958448 bytes.
Global variables use 35476 bytes (43%) of dynamic memory, leaving 46444 bytes for local variables. Maximum is 81920 bytes.
/Users/eamonwhite/Library/Arduino15/packages/esp8266/tools/esptool/0.4.9/esptool -vv -cd ck -cb 115200 -cp /dev/cu.usbserial-AL034FJS -ca 0x00000 -cf /var/folders/lv/lj7d61jn61x_8knqdhghk_pc0000gn/T/arduino_build_545013/esp8266arest.ino.bin 
esptool v0.4.9 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to ck
    setting baudrate from 115200 to 115200
    setting port from /dev/tty.usbserial to /dev/cu.usbserial-AL034FJS
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
opening port /dev/cu.usbserial-AL034FJS at 115200
    tcgetattr
    tcsetattr
    serial open
opening bootloader
resetting board
trying to connect
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
trying to connect
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
An error occurred while uploading the sketch
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
Uploading 245344 bytes from /var/folders/lv/lj7d61jn61x_8knqdhghk_pc0000gn/T/arduino_build_545013/esp8266arest.ino.bin to flash at 0x00000000
    erasing flash
    size: 03be60 address: 000000
    first_sector_index: 0
    total_sector_count: 60
    head_sector_count: 16
    adjusted_sector_count: 44
    erase_size: 02c000
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    setting timeout 15000
    setting timeout 100
    espcomm_send_command: receiving 2 bytes of data
    writing flash
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
closing bootloader
error: espcomm_upload_mem failed

Can anyone explain this line in detail?

warning: espcomm_send_command: wrong direction/command: 0x01 0x03, expected 0x01 0x04

Before, when flashing it with my Uno, it would work well enough. This used to happen, and then I would unplug it and plug it in (reset) and try again, until it eventually worked. However, now it happens every time. I have 4 different ESP8266 that are functional and they all respond the same way, with the error above. This leads me to believe that is something with the circuit, or with my settings, which are:

Board - Generic ESP8266
Flash mode - DIO
Flash freq. - 40hz
CPU freq. - 80hz
Flash size - 1M(64k SPIFFS)
Debug Level - none
Upload Speed - 115200

I have tried messing with the SPIFFS (what are those? packet size?) as well as changing the CPU frequency to 160 Hz, and I tried 80 Hz for the flash frequency.

I used this same system to program the ESP before with an Arduino Uno and I was successful. Why is it so finicky, and what does the response with the 0x01 0x03 instead of 0x01 0x04 trying to say?

0

Instead of using Arduino IDE to upload (I compiled with it), I used esptool standalone. After messing with it for a few minutes...this worked without a hitch:

esptool.py -c esp8266 --port /dev/cu.usbserial-AL034FJS -b 115200 write_flash --flash_freq 40m --flash_size 1MB 0x00000 /var/folders/lv/lj7d61jn61x_8knqdhghk_pc0000gn/T/arduino_build_545013/esp8266arest.ino.bin

I decided to try this after seeing that maybe the esptool that Arduino IDE uses is outdated - it has 0.4.9 where as the latest version is 2.1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.