Watchy: Failed to connect to ESP32

Hello!

When attempting to upload a sketch to my Watchy I’m receiving an error A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header. I was able to upload sketches previously, however recently I’ve been unable to and getting this message consistently.

Full log output is:

WARNING: library DS3232RTC claims to run on avr architecture(s) and may be incompatible with your current board which runs on esp32 architecture(s).
WARNING: library Rtc_Pcf8563 claims to run on avr architecture(s) and may be incompatible with your current board which runs on esp32 architecture(s).
Sketch uses 1699093 bytes (86%) of program storage space. Maximum is 1966080 bytes.
Global variables use 52244 bytes (15%) of dynamic memory, leaving 275436 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.1
Serial port COM3
Connecting........_____....._____....._____....._____....._____....._____.....____An error occurred while uploading the sketch
_

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

After the message is displayed I do see the unit restart as if the reset pin was being applied (although that’s not stated in the logs anywhere).

Here are the version numbers that I could location based on the Libraries Used page Arduino IDE v1.8.19 on Windows 10 Pro Espressif Systems esp v2.0.2 Adruino_JSON v0.1.0 Adafruit GFX v1.10.13 DS3232RTC v1.3.0 GxEPD2 v1.4.5 Watchy v1.3.3 WiFiManager v2.0.9-beta

I’ve tried the simple things like a different USB cable/port, disconnect/reconnect the battery, try to push without the battery connected, and update outside of the case (I have the aluminum one) but all result in the same issue. Everything else seems to work - I’m able to sync NTP and weather details from WiFi, the vibration motor and motion sensor all seem to be working fine as well.

Does anybody know of a way to resolve this?

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 31 (1 by maintainers)

Most upvoted comments

That works! Neither the USB 3.0 nor the USB 2.0 Port on my desktop PC work, but if I plug my cable into the USB hub integrated into my monitor stand (which is itself plugged into another USB hub plugged into a USB 3.0 port in the back of my PC), it works flawlessly. This goes up there on the list of the weirdest issues I’ve ever encountered.

It works on my desktop machine with the new esptool version 4.5. Erasing with esptool.py erase flash works fine. After that I was able to build and upload.

As a temporary workaround, since the current version of the esp32 core is bundled with 4.2.1, I just replaced (maybe make a backup before) the bundled esptool under ~/.arduino15/packages/esp32/tools/esptool_py/4.2.1 with the current version from a venv environment.

After that I was able to build and upload with arduino-cli (without a previous erase with esptool), e.g.:

arduino-cli compile --clean --board-options Revision=v20,UploadSpeed=115200,EraseFlash=all -b esp32:esp32:watchy ~/Arduino/libraries/Watchy/examples/WatchFaces/7_SEG
arduino-cli upload -b esp32:esp32:watchy -p /dev/ttyUSB0 ~/Arduino/libraries/Watchy/examples/WatchFaces/7_SEG

Workarounds

@walex53 Wow, this is impressive.

I’ve been using a Raspberry on my desk via SSH, which is a bit of a hassle but bearable.

I’m thinking of buying a Raspberry Pi Zero and using it as an adaper.

Back to the Problem

At first I thought it’s related to Windows, but it seems like the problem is related to desktop hardware. I tested my office PC with no luck. I have heard different things like:

Rumour 1: There should be an extra capacitor on the GPIO_0 pin to help pulling it LOW. I don’t think I could do that, it’s way too tiny.

Rumour 2: Desktop PCs are supplying “too much” power which prevents pulling the pin low. If this is the case, maybe a very weak resistor could help? I have no idea, I’m a software guy.

Thought 3: After erasing the flash, flashing works with any PC, right? So as long as there is no code on the watch, it is flashable. Which leads me to believe that there might be a software problem with the bootloader on the watch, preventing it to go into flash mode under certain circumstances.

I don’t know what’s really going on, but maybe these thoughts spark the right idea to someone who knows.

Update

I tested it on my Samsung Laptop (Win10 x64) with interesting results:

It has two different USB ports, one 3.0, one 2.0. The 2.0 port works flawlessly every time. The 3.0 port only works when I did erase_flash on the 2.0 port before.

The 2.0 port is controlled by a Intel(R) 7 Series/C216-Chipsatzfamilie - USB-erweiterter Hostcontroller - 1E26 The 3.0 port is controlled by a Renesas USB 3.0 eXtensible-Hostcontroller – 1.0 (Microsoft)

So this confirms that it is an issue related to USB drivers or hardware. Because I used the same esptool with the same serial driver on the same machine running the same OS.

…maybe getting a cheap USB 2.0 hub is the solution?

@walex53 Thank you so much! You just solved all my isses in one post.

Downgrading DS3232RTC from 2.0 to 1.3 fixed the compile error.

I then went and tried to copy the esptool.py from my Windows machine, but it turned out to be a esptool.exe. I just downloaded the latest source code which contains the esptool.py as well.

Executing python3 esptool.py erase_flash then actually managed to talk to the watch!

After doing that, I was able to flash another watchface using the ArduinoIDE.

Edit: So yeah, that works only once. After that, I have to hook it up to my Raspberry to erase the flash. Very strange. I’ll try my laptop, but it’s a windows machine too so I don’t think it will work.