Fix invalid head of packet error

image
image

FQBN: deauther:esp8266:nodemcuv2:wipe=all
Using board 'nodemcuv2' from platform in folder: C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4
Using core 'esp8266' from platform in folder: C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4

Detecting libraries used...
C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/include -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/lwip2/include -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/libc/xtensa-lx106-elf/include -IC:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=160000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10607 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_NODEMCU" -DFLASHMODE_DIO -DESP8266 -DNODEMCU -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4\cores\esp8266 -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4\variants\nodemcu C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0\sketch\Blink.ino.cpp -o nul
Generating function prototypes...
C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/include -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/lwip2/include -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/libc/xtensa-lx106-elf/include -IC:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -ffunction-sections -fdata-sections -fno-exceptions -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=160000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10607 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_NODEMCU" -DFLASHMODE_DIO -DESP8266 -DNODEMCU -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4\cores\esp8266 -IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4\variants\nodemcu C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0\sketch\Blink.ino.cpp -o C:\Users\tranl\AppData\Local\Temp\2894016319\sketch_merged.cpp
C:\Users\tranl\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\tranl\AppData\Local\Temp\2894016319\sketch_merged.cpp
Compiling sketch...
"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\python3\3.7.2-post1/python3" "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/signing.py" --mode header --publickey "C:\Users\tranl\AppData\Local\Temp\.arduinoIDE-unsaved2024815-7560-tjl3pr.ntn1n\Blink/public.key" --out "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/core/Updater_Signing.h"
"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/include" "-IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/lwip2/include" "-IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/core" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++11 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DNONOSDK22x_190703=1 -DF_CPU=160000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10607 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD="ESP8266_NODEMCU"" -DFLASHMODE_DIO -DESP8266 -DNODEMCU "-IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4\cores\esp8266" "-IC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4\variants\nodemcu" "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0\sketch\Blink.ino.cpp" -o "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0\sketch\Blink.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\tranl\AppData\Local\Temp\arduino\cores\760f7aec07b0c57e0390144dcf46b730\core.a
Linking everything together...
"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin/xtensa-lx106-elf-gcc" -CC -E -P -DVTABLES_IN_FLASH "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/ld/eagle.app.v6.common.ld.h" -o "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/local.eagle.app.v6.common.ld"
"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin/xtensa-lx106-elf-gcc" -fno-exceptions -Wl,-Map "-Wl,C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.map" -g -w -Os -nostdlib -Wl,--no-check-sections -u app_entry -u _printf_float -u _scanf_float -Wl,-static "-LC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/lib" "-LC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/lib/NONOSDK22x_190703" "-LC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/ld" "-LC:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sdk/libc/xtensa-lx106-elf/lib" -Teagle.flash.4m1m.ld -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read -o "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.elf" -Wl,--start-group "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0\sketch\Blink.ino.cpp.o" "C:\Users\tranl\AppData\Local\Temp\arduino\cores\760f7aec07b0c57e0390144dcf46b730\core.a" -lhal -lphy -lpp -lnet80211 -llwip2-536-feat -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group "-LC:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0"
"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\python3\3.7.2-post1/python3" "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/elf2bin.py" --eboot "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/bootloaders/eboot/eboot.elf" --app "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.elf" --flash_mode dio --flash_freq 40 --flash_size 4M --path "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin" --out "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.bin"
Creating BIN file "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.bin" using "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/bootloaders/eboot/eboot.elf" and "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.elf"
"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\python3\3.7.2-post1/python3" "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/signing.py" --mode sign --privatekey "C:\Users\tranl\AppData\Local\Temp\.arduinoIDE-unsaved2024815-7560-tjl3pr.ntn1n\Blink/private.key" --bin "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.bin" --out "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.bin.signed" --legacy "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.bin.legacy_sig"
"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\python3\3.7.2-post1/python3" "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/sizes.py" --elf "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.elf" --path "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin"
Executable segment sizes:

IROM : 228624 - code in flash (default or ICACHE_FLASH_ATTR)

IRAM : 26756 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)

DATA : 1248 ) - initialized variables (global, static) in RAM/HEAP

RODATA : 688 ) / 81920 - constants (global, static) in RAM/HEAP

BSS : 24880 ) - zeroed variables (global, static) in RAM/HEAP

"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin/xtensa-lx106-elf-size" -A "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.elf"
Sketch uses 257316 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26816 bytes (32%) of dynamic memory, leaving 55104 bytes for local variables. Maximum is 81920 bytes.
"C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\tools\python3\3.7.2-post1/python3" "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/upload.py" --chip esp8266 --port "COM4" --baud "115200" "" erase_flash --before default_reset --after hard_reset write_flash 0x0 "C:\Users\tranl\AppData\Local\Temp\arduino\sketches\4E163ADCD5C814DB2DA7E9B344E70BF0/Blink.ino.bin"
esptool.py v2.8
Serial port COM4
Traceback (most recent call last):
File "C:\Users\tranl\AppData\Local\Arduino15\packages\deauther\hardware\esp8266\2.7.4/tools/upload.py", line 65, in
esptool.main(cmdline)
File "C:/Users/tranl/AppData/Local/Arduino15/packages/deauther/hardware/esp8266/2.7.4/tools/esptool\esptool.py", line 2889, in main
esp = chip_class(each_port, initial_baud, args.trace)
File "C:/Users/tranl/AppData/Local/Arduino15/packages/deauther/hardware/esp8266/2.7.4/tools/esptool\esptool.py", line 237, in init
self.port = serial.serial_for_url(port)
File "C:/Users/tranl/AppData/Local/Arduino15/packages/deauther/hardware/esp8266/2.7.4/tools/pyserial\serial_init
.py", line 88, in serial_for_url
instance.open()
File "C:/Users/tranl/AppData/Local/Arduino15/packages/deauther/hardware/esp8266/2.7.4/tools/pyserial\serial\serialwin32.py", line 62, in open
raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'COM4': PermissionError(13, 'Access is denied.', None, 5)
Failed uploading: uploading error: exit status 1

I moved your topic to an appropriate forum category @aisa2475 .

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

2 Likes

Works for me.

What are you doing differently?

That last line looks suspicious:

Hi @aisa2475. It appears that you are using both Arduino IDE:

and some other flashing tool:

Only one application can have control over a serial port at a time. When you try to upload a sketch while another application already has control over the board's serial port, it causes uploads to fail with the error you encountered:

Please try this:

  1. Close the other flashing tool
  2. Use Arduino IDE to upload a sketch to your board.

Now reply here on the forum topic to tell us whether the upload was successful this time.

I have deleted your other cross-post @aisa2475 .

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

I don't use 2 apps at the same time

Restart your computer and then try the upload again. In rare occasions, a glitch causes the port to get stuck open. This is one possible cause of the upload error. Restarting your computer restores the port to the normal working state and so fixes that particular cause of the error.

If the upload still fails after restarting your computer, add a reply here on this forum thread to let us know.

I restarted but it didn't work :smiling_face_with_tear:

Please tell us which USB to serial bridge chip your Arduino board has. This is a black chip near the USB socket.

The chip will usually be identified by writing on the top. This might say something like "WCH CH340G" or "SILABS CP2102".

Examples:

WCH CH340

CH340

📷

SparkFun - CC BY-SA 4.0 (cropped)

Silicon Labs CP2102

CP2102

📷

SparkFun - CC BY-SA 4.0 (cropped)


If it isn't clear, alternatively you can provide the link to where you bought the board from and we'll see if we can determine the chip from the product listing.