adafruit / Adafruit_WebSerial_ESPTool

A Web Serial tool for updating your ESP bootloader.
https://adafruit.github.io/Adafruit_WebSerial_ESPTool/
MIT License
124 stars 57 forks source link

PyPortal no sync to ESP #290

Open mikeysklar opened 1 week ago

mikeysklar commented 1 week ago

Forum issue : PyPortal could be updated with CLI esptool.py (v4.6 or 4.7). Using the 4.8.1 CLI fails as does Web_Serial_ESPtool.

PyPortal ADA# 4116

I was able to reproduce the same behavior as the forum user.

ESP Web Flasher loaded.
Connecting...
Connected successfully.
Try hard reset.
[Object.debug:191] Finished read loop
Error: Couldn't sync to ESP. Try resetting.
dhalbert commented 2 days ago

This works with esptool.py 4.8.1 (testing on a Matrix Portal, but the no_reset is necessary:

$ esptool.py --before no_reset --port /dev/ttyACM1 chip_id
esptool.py v4.8.1
Serial port /dev/ttyACM1
WARNING: Pre-connection option "no_reset" was selected. Connection may fail if the chip is not in bootloader or flasher stub mode.
Connecting......
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP32
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: 7c:9e:bd:dc:c9:24
Uploading stub...
Running stub...
Stub running...
Warning: ESP32 has no Chip ID. Reading MAC instead.
MAC: 7c:9e:bd:dc:c9:24
Hard resetting via RTS pin...

WebSerial ESPTool does not work, and neither does https://espressif.github.io/esptool-js/. https://esp.huhn.me/ appears to work.

They used to work, I believe, so I'm not sure what's going on here.

mikeysklar commented 2 days ago

The esptool.py 4.8.1 part had been user reported. I did not investigate it as 4.6 / 4.7 were behaving as expected.

The WebSerial ESPTool not working is concerning. At least that part is reproducable for all of us. I'm not familiar with how it works, but I'll investigate further and update here.

mikeysklar commented 1 day ago

@dhalbert - I hooked up a PyPortal again to try the NINA-FW passthrough upgrade. The behavior is the same (as expected).

ESP Web Flasher loaded.
Connecting...
Connected successfully.
Try hard reset.
[Object.debug:191] Finished read loop
Error: Couldn't sync to ESP. Try resetting.
Connecting...
Error: Failed to execute 'open' on 'SerialPort': The port is already open.

I opened up the Chrome --> View --> JavaScript Console or cmd-option-J to see if I could see more about the error and javascript commands being run. More errors just confirming the same "port is already open", but there hyperlinks to the javascript code.

Screenshot 2024-10-30 at 3 39 52 PM

I can see the failure to open is happening in this segment of code:

document.addEventListener("DOMContentLoaded", () => {
  butConnect.addEventListener("click", () => {
    clickConnect().catch(async (e) => {
      console.error(e);
      errorMsg(e.message || e);
      if (espStub) {
        await espStub.disconnect();
      }
      toggleUIConnected(false);
    });
  });

Then it error messages since we couldn't grab the serial port.

function errorMsg(text) {
  logMsg('<span class="error-message">Error:</span> ' + text);
  console.error(text);
}

I'll look into why.

mikeysklar commented 1 day ago

The timeouts I see from esptool.js look like an old issue with the baudrate being out of sync. I know using 115k has been the traditional speed used. Could that have changed in the web interfaces?

esptool.js
Serial port WebSerial VendorID 0x239a ProductID 0x8035
Connecting...Debug: _connect_attempt default_reset false
Debug: Timeout
Debug: Sync
Debug: Sync err Error: Timeout
.Debug: Sync
Debug: Sync err Error: Timeout
.Debug: Sync
Debug: Sync err Error: Timeout
.Debug: Sync
Debug: Sync err Error: Timeout
.Debug: Sync
Debug: Sync err Error: Timeout
.Debug: Sync
Debug: Sync err Error: Timeout
.Debug: Sync
Debug: Sync err Error: Timeout
.Debug: _connect_attempt default_reset true
dhalbert commented 1 day ago

It might be worth trying older versions of Chrome from several months back.

I tried several baud rates myself when trying to get it to work.

mikeysklar commented 1 day ago

Sure, I'll try some older browser releases.

On Wed, Oct 30, 2024 at 6:11 PM Dan Halbert @.***> wrote:

It might be worth trying older versions of Chrome from several months back.

I tried several baud rates myself when trying to get it to work.

— Reply to this email directly, view it on GitHub https://github.com/adafruit/Adafruit_WebSerial_ESPTool/issues/290#issuecomment-2448799497, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPFI5AI5T3QRYTQD6VO3LLZ6F7VFAVCNFSM6AAAAABQGVBEIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBYG44TSNBZG4 . You are receiving this because you authored the thread.Message ID: @.***>