Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 S2 Mini / Adafruit ESPTool #515

Open
TobiasPSP opened this issue Jul 10, 2024 · 9 comments
Open

ESP32 S2 Mini / Adafruit ESPTool #515

TobiasPSP opened this issue Jul 10, 2024 · 9 comments

Comments

@TobiasPSP
Copy link

ESP32 S2 Mini uses dual UART USB and changes active USB port when switching to firmware upload mode. ESP Web Tool breaks with this board:

Connecting via Web Serial works well, selection menu shows "ESP32-S2" (when in firmware upload mode), else "TinyUSB".

"Prepare for First Use" and "INSTALL" both raise "Failed to initialize" after a few seconds of spinning wheel.

Browser-based "Adafruit ESPTool" (https://adafruit.github.io/Adafruit_WebSerial_ESPTool/) works like a charm. Apparently, this tool correctly handles the S2 Mini.

I'd like to either

a) understand how "Prepare For First Use" works and where the ESP Web Tools gets the four bin files that are mentioned in its manifest so I can use the Adafruit tool to provision S2 Mini with these files in the same way that "Prepare For First Use" would do if it worked correctly with S2 Mini.
b) better yet, get the ESP Web Tools to work with S2 Mini by adopting the technique used by Adafruit ESPTool

I cannot create ESPHome configuration and download its firmware, then upload with the Adafruit tool (which does works beautifully) since I need to provision 100s of boards. I need a generic reusable firmware that triggers "ADOPT" in ESPHome.

Any help or suggestion greatly appreciated. Many thanks.

@EmileSpecialProducts
Copy link

EmileSpecialProducts commented Oct 2, 2024

This is linked to the #375 and esptool-js issue.
I have same problem that the 10.0.1 will not work on the WEMOS LOLIN S2.
But will work on the 8.0.6 version.
You can find my project Turtle-ESP-mouse-jiggler
This also has a script for platformIO to create the Bin files.

Consol log output:

ESP Web Tools 10.0.1 by Nabu Casa; https://esphome.github.io/esp-web-tools/
install-dialog-BWZCBYvU.js?module:477 Initializing Improv Serial
install-dialog-BWZCBYvU.js?module:477 Starting read loop
install-dialog-BWZCBYvU.js?module:477 Writing to stream: [0x49, 0x4D, 0x50, 0x52, 0x4F, 0x56, 0x01, 0x03, 0x02, 0x02, 0x00, 0xE5, 0x0A]
install-dialog-BWZCBYvU.js?module:477 Finished read loop
install-dialog-BWZCBYvU.js?module:807 Improv initialization failed. Error: Improv Wi-Fi Serial not detected
    at install-dialog-BWZCBYvU.js?module:477:1355
_initialize @ install-dialog-BWZCBYvU.js?module:807
await in _initialize
firstUpdated @ install-dialog-BWZCBYvU.js?module:807
_$AE @ styles-ChWDJ3ue.js?module:1
performUpdate @ styles-ChWDJ3ue.js?module:1
scheduleUpdate @ styles-ChWDJ3ue.js?module:1
_$ET @ styles-ChWDJ3ue.js?module:1
await in _$ET
requestUpdate @ styles-ChWDJ3ue.js?module:1
_$Ev @ styles-ChWDJ3ue.js?module:1
A @ styles-ChWDJ3ue.js?module:1
lt @ styles-ChWDJ3ue.js?module:1
Vs @ install-dialog-BWZCBYvU.js?module:477
e @ install-button.js?module:1
await in e
(anonymous) @ install-button.js?module:1Understand this error
install-dialog-BWZCBYvU.js?module:477 esptool.js
install-dialog-BWZCBYvU.js?module:477 Serial port WebSerial VendorID 0x303a ProductID 0x2
install-dialog-BWZCBYvU.js?module:477 Connecting...
install-dialog-BWZCBYvU.js?module:477 .
install-dialog-BWZCBYvU.js?module:477 

install-dialog-BWZCBYvU.js?module:477 Detecting chip type... 
install-dialog-BWZCBYvU.js?module:477 ESP32-S2
install-dialog-BWZCBYvU.js?module:477 Chip is ESP32-S2FH32
install-dialog-BWZCBYvU.js?module:477 Features: Wi-Fi,Embedded 4MB Flash
install-dialog-BWZCBYvU.js?module:477 Crystal is 40MHz
install-dialog-BWZCBYvU.js?module:477 MAC: 80:65:99:eb:74:06
install-dialog-BWZCBYvU.js?module:477 Uploading stub...
install-dialog-BWZCBYvU.js?module:807 Error: Timeout
    at Cs.read (install-dialog-BWZCBYvU.js?module:477:67134)
    at async qs.readPacket (install-dialog-BWZCBYvU.js?module:477:106260)
    at async qs.checkCommand (install-dialog-BWZCBYvU.js?module:477:111107)
    at async qs.memBlock (install-dialog-BWZCBYvU.js?module:477:111799)
    at async qs.runStub (install-dialog-BWZCBYvU.js?module:477:119077)
    at async qs.main (install-dialog-BWZCBYvU.js?module:477:120783)
    at async install-dialog-BWZCBYvU.js?module:807:3522
(anonymous) @ install-dialog-BWZCBYvU.js?module:807
await in (anonymous)
_confirmInstall @ install-dialog-BWZCBYvU.js?module:807
await in _confirmInstall
handleEvent @ styles-ChWDJ3ue.js?module:1Understand this error
install-dialog-BWZCBYvU.js?module:807 Uncaught (in promise) InvalidStateError: Failed to execute 'open' on 'SerialPort': The port is already open.
    at install-dialog-BWZCBYvU.js?module:807:6548
(anonymous) @ install-dialog-BWZCBYvU.js?module:807
setTimeout
(anonymous) @ install-dialog-BWZCBYvU.js?module:89
_e @ install-dialog-BWZCBYvU.js?module:89
(anonymous) @ install-dialog-BWZCBYvU.js?module:807
n @ install-dialog-BWZCBYvU.js?module:807
(anonymous) @ install-dialog-BWZCBYvU.js?module:807
await in (anonymous)
_confirmInstall @ install-dialog-BWZCBYvU.js?module:807
await in _confirmInstall
handleEvent @ styles-ChWDJ3ue.js?module:1Understand this error

Consollog output of Version 8.0.6

Try hard reset.
connect-f67814ca.js?module:488 Chip type ESP32-S2
connect-f67814ca.js?module:488 Uploading stub...
connect-f67814ca.js?module:488 Running stub...
connect-f67814ca.js?module:488 Stub is now running...
connect-f67814ca.js?module:488 Detecting Flash Size
connect-f67814ca.js?module:488 FlashId: 0x164020
connect-f67814ca.js?module:488 Flash Manufacturer: 20
connect-f67814ca.js?module:488 Flash Device: 4016
connect-f67814ca.js?module:488 Auto-detected Flash size: 4MB
connect-f67814ca.js?module:488 Image header, Magic=0xE9, FlashMode=0x02, FlashSizeFreq=0x20
connect-f67814ca.js?module:488 Writing data with filesize: 13648. Compressed Size: 9597
connect-f67814ca.js?module:488 Took 81ms to write 9597 bytes
connect-f67814ca.js?module:488 Erase size 0, blocks 0, block size 0x4000, offset 0x0000, encrypted no
connect-f67814ca.js?module:488 Image header, Magic=0xAA, FlashMode=0x01, FlashSizeFreq=0x02
connect-f67814ca.js?module:488 Writing data with filesize: 3072. Compressed Size: 146
connect-f67814ca.js?module:488 Took 13ms to write 146 bytes
connect-f67814ca.js?module:488 Erase size 0, blocks 0, block size 0x4000, offset 0x0000, encrypted no
connect-f67814ca.js?module:488 Image header, Magic=0x01, FlashMode=0x00, FlashSizeFreq=0x00
connect-f67814ca.js?module:488 Writing data with filesize: 8192. Compressed Size: 47
connect-f67814ca.js?module:488 Took 12ms to write 47 bytes
connect-f67814ca.js?module:488 Erase size 0, blocks 0, block size 0x4000, offset 0x0000, encrypted no
connect-f67814ca.js?module:488 Image header, Magic=0xE9, FlashMode=0x02, FlashSizeFreq=0x20
connect-f67814ca.js?module:488 Writing data with filesize: 279376. Compressed Size: 161665
connect-f67814ca.js?module:488 Took 2611ms to write 161665 bytes
connect-f67814ca.js?module:488 Erase size 0, blocks 0, block size 0x4000, offset 0x0000, encrypted no
connect-f67814ca.js?module:488 DISCONNECT
connect-f67814ca.js?module:488 Finished read loop
connect-f67814ca.js?module:488 HARD RESET
connect-f67814ca.js?module:488 Try hard reset.
connect-f67814ca.js?module:488 Initializing Improv Serial
connect-f67814ca.js?module:488 Starting read loop
connect-f67814ca.js?module:488 Writing to stream: [0x49, 0x4D, 0x50, 0x52, 0x4F, 0x56, 0x01, 0x03, 0x02, 0x02, 0x00, 0xE5, 0x0A]
connect-f67814ca.js?module:488 Finished read loop

@spuder
Copy link
Contributor

spuder commented Nov 3, 2024

Thank you for your workaround. I've also confirmed that I'm unable to flash any Wemos D1 Mini S2 using version 9.x or 10.x of esp-web-tools.

Downgrading to 8.0.6 is a good workaround.

@HanYangZhao
Copy link

HanYangZhao commented Dec 6, 2024

@spuder I'm having the same issue. How did you get the downgrade to work? I ran the server locally with version 8.0.6 but the web page keeps saying :

The demo is not available because your browser does not support Web Serial. Open this page in Google Chrome or Microsoft Edge instead.

even if I'm using Chrome or edge

EDIT : I did fix it, that was a issue with typescript. However with my Wemos Lolin S2 mini ESP32-S2 board on version 8.0.6 it simply says that your ESP32-S2 board is not supported

@spuder
Copy link
Contributor

spuder commented Dec 6, 2024

You can see my working 0.8.6 code here. It is a Jekyll site

https://github.com/spuder/OpenSpool/blob/main/docs/index.md

@EmileSpecialProducts
Copy link

However with my Wemos Lolin S2 mini ESP32-S2 board on version 8.0.6 it simply says that your ESP32-S2 board is not supported

You can test the S2 board upload using this link
And you can see what i have done at this loaction

@damz
Copy link

damz commented Dec 8, 2024

For tracking, this is related to the block size in USB-OTG mode: the ESP32-S2 and ESP32-S3 using the internal USB-OTG serial adapter accept only smaller block sizes.

This was relatively silently fixed last week (but not released yet) via espressif/esptool-js@3a01130, which added the missing postConnect for the ESP32-S2.

@damz
Copy link

damz commented Dec 8, 2024

I confirmed that flashing an WEMOS LOLIN S2 works with espressif/esptool-js@3a01130. There is only one small code change required:

--- a/src/flash.ts
+++ b/src/flash.ts
@@ -74,7 +74,7 @@ export const flash = async (
 
   chipFamily = esploader.chip.CHIP_NAME as any;
 
-  if (!esploader.chip.ROM_TEXT) {
+  if (!esploader.chip) {
     fireStateEvent({
       state: FlashStateType.ERROR,
       message: `Chip ${chipFamily} is not supported`,

(But this whole block probably needs to be removed: as far as I can tell esptool-js never returned from esploader.main() without raising an exception if the chip is not supported, so this whole block is dead code.)

@EmileSpecialProducts
Copy link

damz
This issue is worked on by the ESPTool-JS team.
And is resoved, but a release still has to be made.
Then the ESP-Web-tool can be upgraded.

@The1Percent
Copy link

Any idea when a release is coming? There are a lot of S2 minis waiting to be flashed at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants