Chat freely about anything...

User avatar
By ServerSage
#12620 I'm trying to flash an ESP-01 module using esptool.py, but it keeps returning "Invalid head of packet". I've tried this on 4 computers, used 3 different USB cables, and at both 9600 and 115200 baud rates. It doesn't seem to die at any single point. Sometimes at 0%, sometimes at 45%, sometimes at 56%, etc...

It's hooked up to an FTDI adapter, and am powering it with an external 3.3v power supply capable of supplying 3A. I have it wired as such:

ESP TX -> FTDI RX
ESP RX -> FTDI TX
ESP CHPD -> External Power 3.3v
ESP VCC -> External Power 3.3v
ESP GPIO0 -> External Power GND
ESP GND -> FTDI GND -> External Power GND

I've tried two different firmwares. I'm not sure where the first one came from (I've long since lost the link), but the other is the custom firmware from:

http://goo.gl/ywkTQV

I've redownloaded to make sure it wasn't a bad download.

The first computer was a Mac Pro. Tried with all 3 USB cables (which I use to program Arduino Nanos without a problem).

The second computer was a Macbook Pro. Again, tried with all 3 USB cables.

The third computer was a Windows laptop I borrowed, all 3 USB cables.

The fourth computer was an Ubuntu server. I only tried 1 of the USB cables, but wrote a small bash script to loop trying to program the device over and over to see if it would ever get further than 56% - it didn't.

At this point, I'm stumped. Any ideas, suggestions, assistance, seances, etc... are greatly appreciated. Here is a sample of the output (this is from the ubuntu box after I dropped the module to 9600 baud):

Code: Select allblj@nas:~/bin/esptool$ sudo ./esptool.py --port /dev/ttyUSB0 --baud 9600 write_flash 0x00000 v0952ATFirmware.bin
Connecting...
Erasing flash...
Writing at 0x00039800... (45 %)
Traceback (most recent call last):
  File "./esptool.py", line 536, in <module>
    esp.flash_block(block, seq)
  File "./esptool.py", line 195, in flash_block
    struct.pack('<IIII', len(data), seq, 0, 0)+data, ESPROM.checksum(data))[1] != "\0\0":
  File "./esptool.py", line 106, in command
    raise Exception('Invalid head of packet')
Exception: Invalid head of packet


Thanks!
User avatar
By Maciej
#12979 Hi,

I had the same problem and I spent two days on it.
On the beginning I used RS232 to TTL converter based on FTDI FT232RL IC via USB port. After two days it was the only one suspicious and I decided to use RS232C port which I had on my PCI card inside my PC.

I build simple RS232-TTL converter based on ST232C (or MAX232) circuit. It is working now without any problems. I flashed ESP8266 10 times with success and it works fine now. Remember to add 5V to 3.3V divider on ESP8266_RX pin for safety, but I noticed that ESP is 5V input tolerant circuit (I have no documentation, so it is better to be careful).

Explanation:
I noticed on my oscilloscope that transfer is organized in 1024 bytes packets and after each packet EPS8266 sends acknowledge to the PC. I noticed that after 30..33 packets ESP8266 did not acknowledged received packet and flashing procedure crashed. Probably FT232RL lost some bytes.

Best Regards
Maciej
User avatar
By ServerSage
#13284 Brilliant! Based on your post I figured it might just be the FT232RL that was causing me grief. So, I ordered a CP2102 based converter and it is working perfectly.

I like to live on the edge, so I flashed with an external 3.3v supply, but left the RX/TX at 5v to the converter. Flashed fine, but for those doing so in the future YMMV. It's probably best to level shift or use a voltage divider.

Again, many thanks Maciej!