I'm trying to flash a program to ESP-WROOM-32. When I run make flash, I get the following error. I tried this with 3 different ESP-32s and I get the same error. Also, when I try make erase_flash I get the same error:

fatal: not a git repository (or any of the parent directories): .git
Toolchain path: /home/me/esp/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc
Toolchain version: esp-2020r3-49-gd5524c1
Compiler version: 8.4.0
Python requirements from /opt/esp8266-rtos-sdk/requirements.txt are satisfied.
fatal: not a git repository (or any of the parent directories): .git
App "test" version: 85cf410
Flashing binaries to serial port /dev/ttyUSB0 (app at offset 0x10000)...
esptool.py v2.4.0
Chip is ESP8266EX
Features: WiFi
MAC: **:**:**:**:**:**
Uploading stub...
Running stub...

A fatal error occurred: Invalid head of packet (0x46)
make: *** [/opt/esp8266-rtos-sdk/components/esptool_py/Makefile.projbuild:76: flash] Error 2

Baud rate: 115200 (tried higher ones in serial flasher config, same issue)

EDIT: I tried flashing a program from examples using Arduino IDE and it worked fine. So, it just seems to fail when using the ESP-IDF.


1 Answer 1


The problem was caused by me using the old RTOS SDK, which I used with ESP-01, with ESP-32. It seems that the project structure and build tools have changed quite a bit now. I used the ESP-IDF to build and flash the program and now it's working.

  • \$\begingroup\$ kovac - Hi, Thanks for coming back with an answer to your question. In order to effectively mark the topic as solved, please consider "áccepting" your choice of the best answer i.e. click the "tick mark" next to an answer to make it green - either your answer (which can be áccepted after 2023-05-30 @ 08.52 UTC i.e. 48 hrs after the question was asked) or another answer, if one is written (which can be accepted any time). That shows you don't need more help & future readers can quickly see the confirmed solution. Thanks. \$\endgroup\$
    – SamGibson
    May 29, 2023 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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