Can't flash my ESP32 - Not beginner

rdson@esp
Posts: 10
Joined: Wed Jun 15, 2022 8:41 am

Can't flash my ESP32 - Not beginner

Postby rdson@esp » Wed Jul 31, 2024 6:23 am

Hello there

After a break of a couple of months I came back to do firmware developement and big surprise can't flash my ESP32. At least on my desktop. Still works on my laptop.
So:
- I rather think it is not a hardware issue since it works on my laptop.
- It is not a USB HUB in between.
- Tried different cables.
- I CAN connect to my board with Putty and Hterm and interract with the ESP32 at 115200 baud (on the desktop)
- I reinstalled Windows 11 fresh (!...)
- Tried the two last versions of FTDI's virtual com port driver (have an FTDI FT231XQ chip)

Nothing helps... it keeps saying it can't connect to the ESP32 on my desktop
This is the error message:

esptool.py v4.8.dev4
Serial port COM3
Connecting......................................

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x1B): Possible serial noise or corruption.
For troubleshooting steps visit: https://docs.espressif.com/projects/esp ... oting.html

* The terminal process "C:\Users\Tech\.espressif\python_env\idf5.3_py3.11_env\Scripts\python.exe 'C:\Users\Tech\esp\v5.3\esp-idf\components\esptool_py\esptool\esptool.py', '-p', 'COM3', '-b', '460800', '--before', 'default_reset', '--after', 'hard_reset', '--chip', 'esp32', 'write_flash', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', '2MB', '0x1000', 'bootloader/bootloader.bin', '0x10000', 'SOFI_TEST_2.bin', '0x8000', 'partition_table/partition-table.bin'" terminated with exit code: 2.


Something wrong at ESP-IDF eco system?
Any hint how I could identify where the issue could be?
Lost 3 days now ^^

Thanks and best regards.

EDIT:
- Visual Studio Code 1.91.1
- ESP-IDF VSC extension 1.8.0
- ESP-IDF 4.4.8 and 5.3 (firmware is based on 4.4.8 but also tried the 5.3 with the hello world)

User avatar
ESP_Roland
Posts: 261
Joined: Tue Oct 09, 2018 10:28 am

Re: Can't flash my ESP32 - Not beginner

Postby ESP_Roland » Wed Jul 31, 2024 6:58 am

> I CAN connect to my board with Putty and Hterm and interract with the ESP32 at 115200 baud (on the desktop)

Could you share the logs from there?

There is a "--trace" command line argument for esptool. Could you use it and capture the log into a file? (it will be long)

You can try to push the boot button and hold it while you start flashing. Does this help? If you don't have a boot button then you can pull down GPIO0.

rdson@esp
Posts: 10
Joined: Wed Jun 15, 2022 8:41 am

Re: Can't flash my ESP32 - Not beginner

Postby rdson@esp » Wed Jul 31, 2024 7:46 am

Hi Roland

Thanks for helping!
So, yeah pulling GPIO0 low manually helps a little but not entirely.
Note: it's my own hardware, used the transitor scheme to handle RTS/DTR and RST from UART chip as on the ESP32 demo boards.
It goes a bit further but still doesn't succeed:

esptool.py v4.8.dev4
Serial port COM3
Connecting....
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 94:e6:86:4c:2e:bc
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
WARNING: Failed to communicate with the flash chip, read/write operations will fail. Try checking the chip connections or removing any other hardware connected to IOs.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00007fff...
Flash will be erased from 0x00010000 to 0x0003bfff...
Flash will be erased from 0x00008000 to 0x00008fff...
SHA digest in image updated
Compressed 26752 bytes to 16352...
Writing at 0x00001000... (100 %)
A fatal error occurred: Serial data stream stopped: Possible serial noise or corruption.

* The terminal process "C:\Users\Tech\.espressif\python_env\idf5.3_py3.11_env\Scripts\python.exe 'C:\Users\Tech\esp\v5.3\esp-idf\components\esptool_py\esptool\esptool.py', '-p', 'COM3', '-b', '460800', '--before', 'default_reset', '--after', 'hard_reset', '--chip', 'esp32', 'write_flash', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', '2MB', '0x1000', 'bootloader/bootloader.bin', '0x10000', 'SOFI_TEST_2.bin', '0x8000', 'partition_table/partition-table.bin'" terminated with exit code: 2.



How do I - or better where do I - set the --trace? That is the part of ESP-IDF I get lost. Is it some config file I can access from Visual Studio Code or do I need to go command line (which I'm not used to so would take me some time to learn a bit)

User avatar
ESP_Roland
Posts: 261
Joined: Tue Oct 09, 2018 10:28 am

Re: Can't flash my ESP32 - Not beginner

Postby ESP_Roland » Wed Jul 31, 2024 10:49 am

The trace option can only be used when esptool is invoked directly. The command with all the necessary arguments can be copied from the error message, the part starting with "The terminal process ...", and the "--trace" option added after "esptool.py". But at this point I don't think it would reveal anything new.

Both errors indicate that the ESP is not sending serial data anymore. There could be many reasons. Eg. Windows driver update since last time it worked, USB cable issue, unstable power supply. Do you have a logic analyzer or oscilloscope to debug this? The question is what happened to the ESP32? Did it get reseted during flashing? Did the port disappeared for a short period of time? If the transfer was just delayed then timeouts can be increased through the configuration file (https://docs.espressif.com/projects/esp ... -file.html).

rdson@esp
Posts: 10
Joined: Wed Jun 15, 2022 8:41 am

Re: Can't flash my ESP32 - Not beginner

Postby rdson@esp » Mon Sep 30, 2024 9:02 pm

After having been busy otherwise I came back on this issue.
So: excat same hardware (same board, same USB cable) just doesn't work on my desptop anymore but perfectly does on my laptop.
Same Windows 11, same FTDI driver, same VSC, same ESP IDF...

I can communicate with my board from the desktop using hterm and interact (getting printf infos, navigating through the board menu), I can even trigger a reset from hterm hitting the RTS button, that works...

And actually, I can programm the board from the desktop, if, after engaging a flash process from VSC, then hitting the physical reset button on my board (just needs to be while the flash process tries to make it)...

Maybe some fancy deep down config somewhere in the tremendous amount of config files of a project / ESP IDF?
If not, I need to give up and see with a new desktop...

rdson@esp
Posts: 10
Joined: Wed Jun 15, 2022 8:41 am

Re: Can't flash my ESP32 - Not beginner

Postby rdson@esp » Fri Oct 04, 2024 4:04 pm

Well, new Desktop arrived, it works perfectly.
Damned, those mysterious bugs no one would ever find.....

Who is online

Users browsing this forum: Bing [Bot] and 286 guests