Unable to upload ESP32 code - Invalid head of packet (0x1B)

deepakt
Posts: 24
Joined: Tue Feb 26, 2019 12:23 pm

Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby deepakt » Tue Mar 05, 2019 7:43 pm

So I built a prototype board for my circuit and installed the ESP32 board in my Arduino IDE as well. Connected the board, drivers get installed (Silicon labs CP210X USB to UART Bridge). I select ESP32 WROOM board and select the correct port.

Code gets compiled successfully. But when I try to upload the code, the IDE shows it is trying to connect to (Connecting ....._____....._____) and then i get the below error:

A fatal error as occurred. Failed to connect to ESP32: Invalid head of packet (0x1B)

Logs are as below:

"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\esp32-hal-time.c.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\esp32-hal-timer.c.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\esp32-hal-touch.c.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\esp32-hal-uart.c.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\libb64\\cdecode.c.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\libb64\\cencode.c.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\main.cpp.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\stdlib_noniso.c.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\wiring_pulse.c.o"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-ar" cru "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\wiring_shift.c.o"
Archiving built core (caching) in: C:\Users\Deepak\AppData\Local\Temp\arduino_cache_741343\core\core_f49bb90ee4eac19be0815af55bde9b20.a
Linking everything together...
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-gcc" -nostdlib "-LC:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.1/tools/sdk/lib" "-LC:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.1/tools/sdk/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -u __cxa_guard_dummy -u __cxx_fatal_exception -Wl,--start-group "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\sketch\\PowerMeter.ino.cpp.o" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\libraries\\SPI\\SPI.cpp.o" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647\\core\\core.a" -lgcc -lopenssl -lbtdm_app -lfatfs -lwps -lcoexist -lwear_levelling -lesp_http_client -lprotobuf-c -lhal -lnewlib -ldriver -lbootloader_support -lpp -lfreemodbus -lmesh -lsmartconfig -ljsmn -lwpa -lethernet -lphy -lfrmn -lapp_trace -lfr_coefficients -lconsole -lulp -lwpa_supplicant -lfreertos -lbt -lmicro-ecc -lesp32-camera -lcxx -lxtensa-debug-module -ltcp_transport -lmdns -lvfs -lmtmn -lesp_ringbuf -lsoc -lcore -lfb_gfx -lsdmmc -llibsodium -lcoap -ltcpip_adapter -lprotocomm -lesp_event -limage_util -lc_nano -lesp-tls -lasio -lrtc -lspi_flash -lwpa2 -lwifi_provisioning -lesp32 -lface_recognition -lapp_update -lnghttp -lspiffs -lface_detection -lunity -lesp_https_server -lespnow -lnvs_flash -lesp_adc_cal -llog -ldl_lib -lsmartconfig_ack -lexpat -lfd_coefficients -lm -lmqtt -lc -lheap -lmbedtls -llwip -lnet80211 -lesp_http_server -lpthread -ljson -lesp_https_ota -lstdc++ -Wl,--end-group -Wl,-EL -o "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647/PowerMeter.ino.elf"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.1/tools/gen_esp32part.exe" -q "C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\1.0.1/tools/partitions/default.csv" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647/PowerMeter.ino.partitions.bin"
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\esptool_py\\2.6.0/esptool.exe" --chip esp32 elf2image --flash_mode dio --flash_freq 80m --flash_size 4MB -o "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647/PowerMeter.ino.bin" "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647/PowerMeter.ino.elf"
esptool.py v2.6-beta1

Using library SPI at version 1.0 in folder: C:\Users\Deepak\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.1\libraries\SPI
"C:\\Users\\Deepak\\AppData\\Local\\Arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-size" -A "C:\\Users\\Deepak\\AppData\\Local\\Temp\\arduino_build_430647/PowerMeter.ino.elf"
Sketch uses 249472 bytes (19%) of program storage space. Maximum is 1310720 bytes.
Global variables use 13628 bytes (4%) of dynamic memory, leaving 314052 bytes for local variables. Maximum is 327680 bytes.
C:\Users\Deepak\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.0/esptool.exe --chip esp32 --port COM24 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\Deepak\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.1/tools/partitions/boot_app0.bin 0x1000 C:\Users\Deepak\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.1/tools/sdk/bin/bootloader_qio_80m.bin 0x10000 C:\Users\Deepak\AppData\Local\Temp\arduino_build_430647/PowerMeter.ino.bin 0x8000 C:\Users\Deepak\AppData\Local\Temp\arduino_build_430647/PowerMeter.ino.partitions.bin
esptool.py v2.6-beta1
Serial port COM24
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x1B)
A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x1B)

I did a search but I couldn't find anything with this above error.

Any idea what might be wrong? I'm on Arduino 1.8.8 IDE.

Regards,
Deepak

Yuvaraj1867
Posts: 63
Joined: Wed Mar 06, 2019 4:39 am
Contact:

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby Yuvaraj1867 » Wed Mar 06, 2019 5:15 am

Hi

Once you are getting "Connecting........___"
Press and Hold "PROG or BOOT" button first, then Press and hold "RST or EN" Button second,
wait for couple of second.
Now release "RST or EN" Button first, then release "PROG or BOOT" button.

Now ESP32 will enter into to flash mode.

Hope you know how to connect this two switches with ESP32 Module.

karansoi
Posts: 9
Joined: Tue Jul 31, 2018 5:25 pm

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby karansoi » Wed Mar 06, 2019 5:30 am

During the upload process after the compile keep the GPIO0 pin connected to ground.
Try this.

karansoi
Posts: 9
Joined: Tue Jul 31, 2018 5:25 pm

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby karansoi » Wed Mar 06, 2019 6:22 am

Yuvaraj1867 wrote:
Wed Mar 06, 2019 5:15 am
Hi

Once you are getting "Connecting........___"
Press and Hold "PROG or BOOT" button first, then Press and hold "RST or EN" Button second,
wait for couple of second.
Now release "RST or EN" Button first, then release "PROG or BOOT" button.

Now ESP32 will enter into to flash mode.

Hope you know how to connect this two switches with ESP32 Module.
If your board has two buttons, They may be marked Reset/RST and EN/BOOT.
You can try connecting a 10 MFD 16V electrolytic capacitor from the EN pin to ground. This may obviate the need to juggle with these two buttons.
Temporary connection from GPIO0 to GND along with the capacitor on enable pin worked for me.
BTW my board is a LOLIN D32 which has only the RESET button. It has mosfets in its circuitry that are supposed to pull GPIO0 to ground during upload of code. (On my board these mosfets may not be working, no way to ascertain, however the workaround is getting my code on the board).

deepakt
Posts: 24
Joined: Tue Feb 26, 2019 12:23 pm

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby deepakt » Wed Mar 06, 2019 8:44 am

Thankyou gentlemen.

I have a WROOM32 board (Not LoLin). I tried the below:

1. Pressing boot button as soon as I click on Upload on the IDE
2. Pressing the "BOOT" button when I see "Connecting ..." on the Arduino IDE
3. I connected a 100nf capacitor across the BOOT button (with difficulty) as per https://github.com/espressif/arduino-esp32/issues/333
4. When I see "Connect", I press BOOT and then EN, wait for 3 seconds, release EN and then release BOOT.
5. Connected a 10uF/10V capacitor across EN and GND and followed the procedure for BOOT pin (not EN this time)

Everytime I get the same Timeout error as shown in the attached image.

I tried it with another board and it worked. I'm just not convinced that the board which is giving me problems is gone bad. Any ideas what could be wrong? Might be I can install a separate FTDI breakout to make it functional again.

Regards,
Deepak
Attachments
ESP32_timeout.jpg
ESP32_timeout.jpg (129.56 KiB) Viewed 27998 times

karansoi
Posts: 9
Joined: Tue Jul 31, 2018 5:25 pm

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby karansoi » Wed Mar 06, 2019 11:56 am

Hi Deepak,
Try keeping GPIO0 tied to GND during the compile and upload duration.

idahowalker
Posts: 166
Joined: Wed Aug 01, 2018 12:06 pm

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby idahowalker » Wed Mar 06, 2019 4:44 pm

Ever since I switched to using a powered hub between the ESP32 and the computer, I have not had to hold down the thing do buttons. Also, you will find that when the ESP32 or some other circuit puts more then 5V+ on the 5V line, that more than 5 volts is not fed into the connected computer.

My opinion, do yourself and the host computer a favor, by putting a powered hub between the ESP32 and the host computer.

Also, ESP32's blow quicker than a fuse.

deepakt
Posts: 24
Joined: Tue Feb 26, 2019 12:23 pm

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby deepakt » Wed Mar 06, 2019 6:50 pm

Thanks idahowalker. Will try powered USB hub and see if that helps.

Thabks karansoi. I have the 30 pin version of the WROOM32 dev board which doesn't seem to have a breakout for GPIO0, which prevents me from forcefully connecting it to the ground.

I am not sure if the BOOT button is connected to GPIO0 or not.

Anyone has any ideas to breakout GPIO pin from the board that i have?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby ESP_Angus » Thu Mar 07, 2019 2:23 am

idahowalker wrote:
Wed Mar 06, 2019 4:44 pm
Also, ESP32's blow quicker than a fuse.
This isn't something we're aware of. What development boards are you buying? Are you in the habit of exceeding the specifications (voltage, etc) on a regular basis?

***

To get more hints about what might be going wrong with the device, try opening a Windows Command Prompt and running esptool.exe directly with the --trace option. Something like this should work:

Code: Select all

C:\Users\Deepak\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.0/esptool.exe --chip esp32 --port COM24 --trace flash_id
This command will print every bit of serial interaction between esptool and the development board.

idahowalker
Posts: 166
Joined: Wed Aug 01, 2018 12:06 pm

Re: Unable to upload ESP32 code - Invalid head of packet (0x1B)

Postby idahowalker » Thu Mar 07, 2019 3:36 am

ESP_Angus wrote:
Thu Mar 07, 2019 2:23 am
idahowalker wrote:
Wed Mar 06, 2019 4:44 pm
Also, ESP32's blow quicker than a fuse.
This isn't something we're aware of. What development boards are you buying? Are you in the habit of exceeding the specifications (voltage, etc) on a regular basis?
All three times I have blown a ESP32 board has been my fault. The boards I have bought that I have blown up are the HiLetgo ESP-WROOM-32 ESP32 ESP-32S boards. The boards, I find, are sensitive to input rail voltage levels. By using a well regulated and filtered power source with a crowbar circuit, I have not experienced any more damaged boards.

I experienced the board loses whiles experimenting with different configurations. My fault.

It would be real nice, I know cost, if the ESP32 boards did not feed power to/through a connected USB device and into a host computer or, have a more common recommendation made to connect the ESP32 to a host computer through a powered USB hub.

Who is online

Users browsing this forum: No registered users and 37 guests