Git Product home page Git Product logo

adafruit_webserial_esptool's Introduction

Adafruit WebSerial ESPTool

JavaScript package to install firmware on ESP devices via the browser using WebSerial.

Used by

Local development

Origin

This project was originally written by Melissa LeBlanc-Williams. Nabu Casa ported the code over to TypeScript and in March 2022 took over maintenance from Adafruit. In July 2022, the Nabucasa stopped maintaining the project in favor of an official, but very early release of Espressif's esptool-js. Due to the instability of the tool, Adafruit updated their fork with Nabucasa's changes in November 2022 and took over maintenance once again.

A live copy of the tool is hosted here: https://adafruit.github.io/Adafruit_WebSerial_ESPTool/

adafruit_webserial_esptool's People

Contributors

balloob avatar bramkragten avatar conradopoole avatar dependabot[bot] avatar dhalbert avatar foamyguy avatar infosecredd avatar jason2866 avatar ladyada avatar lazyzero avatar liux-pro avatar lorennorman avatar makermelissa avatar robdobsn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_webserial_esptool's Issues

Failure with old chrome version on Linux

I used chromium 83.0.4103.116-1~deb10u3 because it is packaged on debian stable. However, I ran into an error after selecting the port and speed:

Adafruit WebSerial ESPTool loaded.
Connecting...
Error: Failed to execute 'open' on 'SerialPort': required member baudrate is undefined

I didn't find any good references for this error, though other people have encountered it in various contexts, like https://stackoverflow.com/questions/64378562/web-serial-api-uncaught-in-promise-domexception-failed-to-open-serial-port and http://forum.espruino.com/comments/15634527/

oh, maybe:

Thanks @AkosLukacs - I was on Chrome 85 and it looks like Chrome Version 86 has broken Web Serial (they randomly renamed baudrate to baudRate!).

so in this case it would be a compatibility problem with old chrome versions since presumably you are using the new/correct baudRate. If that's the case, this can probably be closed as unsupported. However, maybe a version check is still worth adding?

Fix ESP32 and ESP32-C3 at higher speeds

I think a little restructuring so the commandCheck(), command(), and getResponse() are changed to be the same as esptool.py might be enough to fix this. However, it might be more involved.

Problem with running stub on various ESP32-S3 boards

After a discussion on #help-with-circuitpython, Dan suggested I file an issue here. Anyhow, I'm getting the error message below when I try to connect to 3 different ESP32-S3 boards. Same error happens with two different USB cables, using two different macs, with different versions of macOS and Chrome. The boards I tried are Adafruit Feather TFT ESP32-S3, Adafruit QT Py ESP32-S3 (8 flash / 0 psram), and Adafruit QT Py ESP32-S3 (4 flash / 2 psram).

This is the error:

ESP Web Flasher loaded.
Connecting...
Connected successfully.
Try hard reset.
Chip type ESP32-S3
Connected to ESP32-S3
MAC Address: [redacted]
Uploading stub...
Running stub...
[Object.debug:191] Finished read loop
Error: Invalid head of packet (0x47)

screenshots:
invalid-head-of-packet-0x47

js-console-screenshot

Using the nodemcu reset mechanism

Hi,

is it possible to use the nodemcu auto-reset mechanism, that uses RTS and DTR, also in this WebSerial API? Would be nice to use this tool also with boards that don't have the reset and boot buttons.

Best Christian

Fix changing baudrate

Thanks for the great efforts put into this project. Great to finally see Web Serial support so this is possible ๐Ÿ‘

Hardware:

  • ESP WROOM 32
  • CH3400 Serial IC
  • Macbook Late 2013

Software:

  • Version 89.0.4389.114 (Official Build) (x86_64)
  • macOS Big Sur 11.2.3

Output:

Adafruit WebSerial ESPTool loaded.
Connecting...
Connected successfully.
Try to reset.
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Attempting to change baud rate to 460800...
Timed out after 3000 milliseconds
Error: Didn't get enough status bytes

Cannot load NVM binary at overlapping address range

This error came in through our support channel.


when trying to setup a huzza esp32 board. the flashing steps 1-6 complete. after the board is reset (power removed and plugged back in) it give the following error
"Error: Software loader is resident at 0x400BE000-0x400BED68. Can't load binary at overlapping address range 0x400BE000-0x400BED68. Try changing the binary loading address."

here is the log



Install Adafruit.io WipperSnapper for ESP32
Dark Mode
Adafruit WebSerial ESPTool loaded.
Connecting...
Connected successfully.
Try to reset.
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Connected to ESP32
MAC Address: 94:B9:7E:6B:15:E4
Uploading stub...
Running stub...
Stub is now running...
Writing data with filesize: 17168
Erase size 17168, blocks 2, block size 16384, offset 0x4096, encrypted no
50%...
100%...
Took 3007ms to write 17168 bytes
Writing data with filesize: 3072
Erase size 3072, blocks 1, block size 16384, offset 0x32768, encrypted no
Took 1438ms to write 3072 bytes
Writing data with filesize: 8192
Erase size 8192, blocks 1, block size 16384, offset 0x57344, encrypted no
Took 1430ms to write 8192 bytes
Writing data with filesize: 952112
Erase size 952112, blocks 59, block size 16384, offset 0x65536, encrypted no
1%...
3%...
5%...
6%...
8%...
10%...
11%...
13%...
15%...
16%...
18%...
20%...
22%...
23%...
25%...
27%...
28%...
30%...
32%...
33%...
35%...
37%...
38%...
40%...
42%...
44%...
45%...
47%...
49%...
50%...
52%...
54%...
55%...
57%...
59%...
61%...
62%...
64%...
66%...
67%...
69%...
71%...
72%...
74%...
76%...
77%...
79%...
81%...
83%...
84%...
86%...
88%...
89%...
91%...
93%...
94%...
96%...
98%...
100%...
Took 86932ms to write 952112 bytes
Creating NVS binary
Writing data with filesize: 12288
Erase size 12288, blocks 1, block size 16384, offset 0x9000, encrypted no
Took 1430ms to write 12288 bytes
To run the new firmware, please reset your device.
Connecting...
Connected successfully.
Try to reset.
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Connected to ESP32
MAC Address: 94:B9:7E:6B:15:E4
Uploading stub...
Error: Software loader is resident at 0x400BE000-0x400BED68. Can't load binary at overlapping address range 0x400BE000-0x400BED68. Try changing the binary loading address.```

Unable to connect to Adafruit QTPY ESP32-C3

The Adafruit QTPY ESP32-C3 enumerates on the WebSerial ESPTool:
image

However, it does not connect, the output log is as follows...

Adafruit WebSerial ESPTool loaded.
Connecting...
Connected successfully.
Try to reset.
Performing sync...
Error: Couldn't sync to ESP. Try resetting.

Related PR, #22

ESPTool believe it is connected after `port.open(...)` failure

Relevant bits of the connect() and connected() methods:

  async connect() {
    // - Request a port and open a connection.
    port = await navigator.serial.requestPort();

    // - Wait for the port to open.toggleUIConnected
    if (this.getChromeVersion() < 86) {
      await port.open({ baudrate: ESP_ROM_BAUD });
    } else {
      await port.open({ baudRate: ESP_ROM_BAUD });
    }

    // ...rest of method
  }

  connected() {
    if (port) {
      return true;
    }
    return false;
  }

port gets assigned then port.open() gets called, but we aren't catching failures in port.open(), such as the one a user will get when they select the wrong Serial device to connect to: Failed to open serial port.

The connected() method then merely checks if port is set, which it is, even though the connection actually failed. Quick repro in the console, we expect the last line to be false:

Screen Shot 2022-03-30 at 11 07 32 AM

One quick fix is a try/catch around those open calls which ensures port = null before rethrowing. I'll open a PR to this effect shortly!

ESP32 upgrade ESptool error

trying to update pyportal esp32 following the "Upgrade All-in-One ESP32 AirLift Firmware" I get an error: Error: SlipReadError: Timed out waiting for packet header.
I get error when using Windows 10 version on dell xp 8500 machine or on my laptop Dell using windows 11 latest., and chrome.
Version 115.0.57
thrid try of esp download
esp32 upgrade
90.102 (Official Build) (6

Add/fix C6 support

It looks like C6 support was added in a previous pull request, however connecting the ESP32-C6 Feather fails with this:

ESP Web Flasher loaded.
Connecting...
Connected successfully.
Try hard reset.
[Object.debug:191] Finished read loop
Error: Unknown Chip: Hex: 0x2ce0806f Number: 752910447

The board can be programmed with espressif's tool, but it would be nice to be able to use the Adafruit tool with upcoming C6 boards.

Garbage after flashing generic ESP8266

Hi guys. Congratulations and thanks for Adafruit_WebSerial_ESPTool - this makes flashing ESP devices much more easier and accessible for beginners in a wide variety of environments!

I have tried to flash some ESP32 (not S2) generic boards with MicroPython firmware. All worked "nice and easy" and I quickly got MicroPython running on the boards!

My problem is with ESP8266. I have tried to flash MicroPython and CircuitPython to some ESP8266 models, and all "failed". By "failed" I mean that the Adafruit_WebSerial_ESPTool did flash the board, but when I reset the ESP8266 module, I only get continuous garbage coming from the serial port to the terminal (tried several speeds).

Here are some tests I did:

TEST 1 (works)
(with generic ESP32 / Adafruit ESPTool)

curl -LO https://github.com/nos86/micropython/releases/download/esp32-can-driver-v2/firmware.bin

On Google Chrome, select 0x1000 and click program:

Adafruit WebSerial ESPTool loaded.
Connecting...
Connected successfully.
Try to reset.
Readloop started
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Connected to ESP32
MAC Address: 24:6F:28:A1:B7:60
Uploading stub...
Running stub...
Stub is now running...
Writing data with filesize:1179600
Erase size 1179600, blocks 2304, block size 512, offset 0x1000, encrypted no
Took 126453ms to write 1179600 bytes
To run the new firmware, please reset your device.

Works at first try! :-)

By the way, if I use esptool.py, I have the output, which is consistent with the Adafruit_WebSerial_ESPTool:

Compressed 1179600 bytes to 743239...
Took 3.49s to erase flash block
Wrote 1179600 bytes (743239 compressed) at 0x00001000 in 22.9 seconds (effective 411.4 kbit/s)...
Hash of data verified.


TEST 2
(Generic ESP8266 / Adafruit ESPTool)

Connecting...
Connected successfully.
Try to reset.
Readloop started
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 3000 milliseconds
Error: Didn't get enough status bytes

After reloading the webpage, works:

Adafruit WebSerial ESPTool loaded.
Connecting...
Connected successfully.
Try to reset.
Readloop started
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Connected to ESP8266EX
MAC Address: C8:2B:96:2F:43:40
Uploading stub...
Running stub...
Stub is now running...
Writing data with filesize:632064
Erase size 632064, blocks 1235, block size 512, offset 0x0000, encrypted no
Took 67159ms to write 632064 bytes
To run the new firmware, please reset your device.

After resetting, garbage is continuously sent over the serial and LED blinks randomly.


TEST 3, with Generic ESP8266 / Adafruit ESPTool:

Tried to change baud rate to 460800. Chrome freezes when clicking connect, causing CPU usage to go to 100%


TEST 4, with Wemos D1 mini ESP8266 / Adafruit ESPTool:

Adafruit WebSerial ESPTool loaded.
Connecting...
Connected successfully.
Try to reset.
Readloop started
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Timed out after 100 milliseconds
Connected to ESP8266EX
MAC Address: 2C:F4:32:3C:E5:75
Uploading stub...
Running stub...
Stub is now running...
Writing data with filesize:632064
Erase size 632064, blocks 1235, block size 512, offset 0x0000, encrypted no
Took 68114ms to write 632064 bytes
To run the new firmware, please reset your device.

After resetting, garbage is continuously sent over the serial and LED blinks randomly.

BUT...
If I flash the same file with esptool.py, it works (see below)!

esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash --flash_size=detect -fm dio 0 *bin

Erasing flash...
esptool.py v1.3
Connecting....
Running Cesanta flasher stub...
Erasing flash (this may take a while)...
Erase took 10.0 seconds
esptool.py v1.3
Connecting....
Auto-detected Flash size: 32m
Running Cesanta flasher stub...
Flash params set to 0x0240
Wrote 634880 bytes at 0x0 in 55.1 seconds (92.2 kbit/s)...
Leaving...

Note that with ESP32, the bytes written are equal on esptool.py and WebSerialESP_Tool (1179600) while for ESP8266 they differ (632064 versus 634880).

Maybe I am doing something wrong, so any help / hint is welcome.

By the way, I am one of the authors of BIPES project, which allows quick and easy block based programming using serial or webrepl for MicroPython and CircuitPython. We want to allow users to flash CircuitPython or MicroPython firmwares easily and then use BIPES to program / monitor / interact with the board all from the browser.

http://bipes.net.br/beta2/ui/

Thanks for your time and best regards!

Rafael

script/build not running on TypeScript 4.9.3

See error log from #44. It seems to be related to using TypeScript 4.9.

Error: node_modules/@types/node/globals.d.ts(341,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'AbortSignal' must be of type '{ new (): AbortSignal; prototype: AbortSignal; abort(reason?: any): AbortSignal; timeout(milliseconds: number): AbortSignal; }', but here has type '{ new (): AbortSignal; prototype: AbortSignal; }'.
Error: Process completed with exit code 2.

According to microsoft/TypeScript#51567, a little housekeeping may be all that is required.

Import error for esp32s3

Hi, this seemed like the best place to report this.

Error: Failed to fetch dynamically imported module: https://adafruit.github.io/Adafruit_WebSerial_ESPTool/js/modules/esp32s3-b0a5f517.js

When trying to follow https://learn.adafruit.com/adafruit-qt-py-esp32-s3/factory-reset, I got the above error.

I got things working with the python esptool, but all 3 of my ESP32-S3's that I just got seem to be missing the UF2 bootloader out of the box. Absolutely could not get them to appear as QTPYS3BOOT drive before factory reset, no trouble afterward.

Update actions to upload a package to a CDN

This is how it was being done by @NabuCasa and after some trial and error, it would probably be best to restore that, but under our control. By the way, great job with all of the setup work. It really is the right way to go. Here's why I didn't do it initially.

When I updated here, I attempted to host the package on GitHub, my goal was to try and have the package hosted here as to not mess around with having an Adafruit NPM account similar to how we did https://github.com/adafruit/ble-file-transfer-js. Additionally, there was a second step of updating what version the web client was pointed to. However, with TypeScript, the source needs to be compiled. Currently the GitHub actions is compiling and uploading the compiled files to gitHub pages on any new push, which makes updates here very easy. However, it also removes versioning. It also makes linking to the node package externally more difficult.

While we could certainly link to the compiled GitHub files directly, it wouldn't be able to go through a CDN like unpkg.com, which is what the WipperSnapper Firmware uploader is currently using (https://github.com/adafruit/WipperSnapper_Firmware_Uploader/blob/main/js/script.js#L6). As such, I haven't felt comfortable linking it to this repo, which means potential loss of control.

Another thing that this affects is something that @tannewt and I have discussed a bit, which is adding automatic firmware deployment to circuitpython.org for ESP32-based devices. This would make it much easier for the user and having the ESPTool as an NPM package would be perfect for making the process easier.

So the steps to fix this are:

  • Figure out if we have or who controls an Adafruit NPM Account
  • Get the credentials or at least some kind of token that we can use for GitHub Actions
  • Update GitHub Actions to upload to account
  • Publish to NPM
  • Update the source files in this repo to load the new NPM Package
  • Test that everything is working
  • Update the WipperSnapper_Firmware_Uploader repo to make use of the new NPM Package (or at least create an issue) plus any ancillary related tasks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.