esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

WT32-ETH01 ESPHome OTA update fails silently #5259

Open thargy opened 9 months ago

thargy commented 9 months ago

The problem

When performing an OTA to a WT32-ETH01 it only occasionally succeeds, most of the time it looks like it has succeeded but the firmware has not been updated.

Tried with local pip install and HA AddOn.

Which version of ESPHome has the issue?

2023.11.2, 2023.12.0, 2023.12.1

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

2023.12.3

What platform are you using?

ESP32

Board

WT32-ETH01

Component causing the issue

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

For example, the log during update:

Linking .pioenvs/extractor-fan-controller/firmware.elf
RAM:   [=         ]  10.6% (used 34816 bytes from 327680 bytes)
Flash: [====      ]  35.6% (used 652893 bytes from 1835008 bytes)
Building .pioenvs/extractor-fan-controller/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/extractor-fan-controller/firmware.bin"], [".pioenvs/extractor-fan-controller/firmware.elf"])
Wrote 0xafb90 bytes to file /data/build/extractor-fan-controller/.pioenvs/extractor-fan-controller/firmware-factory.bin, ready to flash to offset 0x0
========================= [SUCCESS] Took 13.95 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.90.91
INFO Uploading /data/build/extractor-fan-controller/.pioenvs/extractor-fan-controller/firmware.bin (654224 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 0.92 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.90.91 using esphome API
INFO Successfully connected to extractor-fan-controller @ 192.168.90.91 in 3.095s
INFO Successful handshake with extractor-fan-controller @ 192.168.90.91 in 0.088s
[15:58:21][I][app:102]: ESPHome version 2023.12.0 compiled on Dec 21 2023, 15:30:04

As you can see, it says it updated, however the compiled timestamp is from 28 minutes earlier (despite the code being changed, etc.). Indeed a log running on another window shows:

[15:56:33][D][ota:151]: Starting OTA Update from 192.168.86.247...
[15:56:33][D][ota:320]: OTA in progress: 0.2%
[15:56:34][D][ota:320]: OTA in progress: 79.6%
[15:56:34][I][ota:353]: OTA update finished!
[15:56:34][I][app:134]: Rebooting safely...
[15:56:34][D][esp32.preferences:114]: Saving 1 preferences to flash...
[15:56:34][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
INFO Processing expected disconnect from ESPHome API for extractor-fan-controller @ 192.168.90.91
WARNING Disconnected from API
INFO Successfully connected to extractor-fan-controller @ 192.168.90.91 in 0.002s
INFO Successful handshake with extractor-fan-controller @ 192.168.90.91 in 0.150s
[15:56:40][D][api.connection:1105]: Home Assistant 2023.12.3 (192.168.86.48): Connected successfully

Again, giving no indication of failure.

Additional information

It appears that disconnecting all the GPIO pins, and only having power supplied to the board allows successful OTA updates. I have also tried booting with GPIO2 tied to ground (as per the spec.) but that didn't resolve the problem.

Worryingly, ESPHome can't seem to detect that the update actually failed.

thargy commented 9 months ago

I have noticed that a successful upload takes about 2-3s, not 0.92s.

thargy commented 9 months ago

After extensive testing, I discovered that the issue seems to be with GPIO12 being in use. According to ESP32 docs on bootloader mode, GPIO12 is used to specify the flash voltage during serial bootloader mode. I am unsure if that is related, but it seems suspicious that perhaps flash updates are failing silently.

I have only seen this on the WT32-ETH01 board, but it may affect other boards, too, so it may need further investigation or a warning added. I have also seen multiple posts of others struggling with OTA on this board.

I still feel this is a bug in ESPHome as it does not detect that the flash does not occur successfully and, instead, reports a successful OTA update.

cosmo88 commented 9 months ago

Can confirm that switching off GPIO12 did allow me to remote update from the ESPHome Dashboard again. This was with a WT32-ETH01 board that I have controlling my Garage Door Opener.

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

thargy commented 5 months ago

Bumping as still an issue.