esp32tool 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apple-touch-icon.png +0 -0
- package/css/style.css +47 -35
- package/dist/const.js +1 -1
- package/dist/esp_loader.d.ts +35 -0
- package/dist/esp_loader.js +201 -68
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/util.d.ts +4 -0
- package/dist/util.js +8 -0
- package/dist/web/index.js +1 -1
- package/icons/icon-128.png +0 -0
- package/icons/icon-144.png +0 -0
- package/icons/icon-152.png +0 -0
- package/icons/icon-192.png +0 -0
- package/icons/icon-384.png +0 -0
- package/icons/icon-512.png +0 -0
- package/icons/icon-72.png +0 -0
- package/icons/icon-96.png +0 -0
- package/js/console.js +12 -2
- package/js/modules/esptool.js +1 -1
- package/js/script.js +300 -285
- package/js/util/console-color.js +2 -1
- package/js/webusb-serial.js +42 -7
- package/package.cli.json +1 -1
- package/package.json +11 -5
- package/screenshots/desktop.png +0 -0
- package/screenshots/mobile.png +0 -0
- package/src/const.ts +1 -1
- package/src/esp_loader.ts +227 -73
- package/src/index.ts +3 -0
- package/src/util.ts +9 -0
- package/sw.js +1 -1
- package/script/build +0 -12
- package/script/develop +0 -17
package/js/util/console-color.js
CHANGED
|
@@ -199,10 +199,11 @@ export const coloredConsoleStyles = `
|
|
|
199
199
|
padding: 16px;
|
|
200
200
|
overflow: auto;
|
|
201
201
|
line-height: 1.45;
|
|
202
|
-
border-radius:
|
|
202
|
+
border-radius: 0;
|
|
203
203
|
white-space: pre-wrap;
|
|
204
204
|
overflow-wrap: break-word;
|
|
205
205
|
color: #ddd;
|
|
206
|
+
min-height: 0;
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
.log-bold {
|
package/js/webusb-serial.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* WebUSBSerial - Web Serial API-like wrapper for WebUSB
|
|
3
3
|
* Provides a familiar interface for serial communication over USB on Android
|
|
4
4
|
*
|
|
5
|
-
* This enables
|
|
5
|
+
* This enables to work on Android devices where Web Serial API
|
|
6
6
|
* is not available but WebUSB is supported.
|
|
7
7
|
*
|
|
8
|
-
* IMPORTANT: For Android
|
|
8
|
+
* IMPORTANT: For Android compatibility, this class uses smaller transfer sizes
|
|
9
9
|
* to prevent SLIP synchronization errors. The maxTransferSize is set to 64 bytes
|
|
10
10
|
* (or endpoint packetSize if smaller) to ensure SLIP frames don't get split.
|
|
11
11
|
*/
|
|
@@ -24,7 +24,7 @@ class WebUSBSerial {
|
|
|
24
24
|
'close': [],
|
|
25
25
|
'disconnect': []
|
|
26
26
|
};
|
|
27
|
-
// Transfer size optimized for WebUSB on Android
|
|
27
|
+
// Transfer size optimized for WebUSB on Android
|
|
28
28
|
// CRITICAL: blockSize = (maxTransferSize - 2) / 2
|
|
29
29
|
// Set to 64 bytes for maximum compatibility with all USB-Serial adapters
|
|
30
30
|
// With 64 bytes: blockSize = (64-2)/2 = 31 bytes per SLIP packet
|
|
@@ -587,7 +587,7 @@ class WebUSBSerial {
|
|
|
587
587
|
*/
|
|
588
588
|
async setSignals(signals) {
|
|
589
589
|
// Serialize all control transfers through a queue
|
|
590
|
-
// This is CRITICAL for CP2102
|
|
590
|
+
// This is CRITICAL for CP2102 - parallel commands cause hangs
|
|
591
591
|
this._commandQueue = this._commandQueue.then(async () => {
|
|
592
592
|
if (!this.device) {
|
|
593
593
|
throw new Error('Device not open');
|
|
@@ -803,8 +803,6 @@ class WebUSBSerial {
|
|
|
803
803
|
// CH340 (WCH VID: 0x1a86, but not CH343 PID: 0x55d3)
|
|
804
804
|
else if (vid === 0x1a86 && pid !== 0x55d3) {
|
|
805
805
|
// CH340 baudrate calculation (from Linux kernel driver)
|
|
806
|
-
// CH341_BAUDBASE_FACTOR = 1532620800
|
|
807
|
-
// CH341_BAUDBASE_DIVMAX = 3
|
|
808
806
|
const CH341_BAUDBASE_FACTOR = 1532620800;
|
|
809
807
|
const CH341_BAUDBASE_DIVMAX = 3;
|
|
810
808
|
|
|
@@ -875,11 +873,22 @@ class WebUSBSerial {
|
|
|
875
873
|
try {
|
|
876
874
|
while (this._readLoopRunning && this.device) {
|
|
877
875
|
try {
|
|
876
|
+
// CRITICAL: Check backpressure before reading more data
|
|
877
|
+
// If desiredSize is 0 or negative, the consumer can't keep up
|
|
878
|
+
// Wait for the consumer to drain the buffer before reading more
|
|
879
|
+
if (controller.desiredSize !== null && controller.desiredSize <= 0) {
|
|
880
|
+
// Consumer is backlogged - wait before reading more
|
|
881
|
+
await new Promise(r => setTimeout(r, 10));
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
|
|
878
885
|
const result = await this.device.transferIn(this.endpointIn, this.maxTransferSize);
|
|
879
886
|
|
|
880
887
|
if (result.status === 'ok') {
|
|
881
888
|
controller.enqueue(new Uint8Array(result.data.buffer, result.data.byteOffset, result.data.byteLength));
|
|
882
|
-
//
|
|
889
|
+
// Small delay to allow consumer to process data
|
|
890
|
+
// This prevents overwhelming the TextDecoderStream on Android
|
|
891
|
+
await new Promise(r => setTimeout(r, 1));
|
|
883
892
|
continue;
|
|
884
893
|
} else if (result.status === 'stall') {
|
|
885
894
|
await this.device.clearHalt('in', this.endpointIn);
|
|
@@ -933,6 +942,26 @@ class WebUSBSerial {
|
|
|
933
942
|
});
|
|
934
943
|
}
|
|
935
944
|
|
|
945
|
+
/**
|
|
946
|
+
* Recreate streams without closing the port
|
|
947
|
+
* Useful after hardware reset or when switching to console mode
|
|
948
|
+
* This stops the current read loop and creates fresh streams
|
|
949
|
+
*/
|
|
950
|
+
recreateStreams() {
|
|
951
|
+
// Stop the current read loop
|
|
952
|
+
this._readLoopRunning = false;
|
|
953
|
+
|
|
954
|
+
// Wait a bit for the read loop to finish
|
|
955
|
+
// The ReadableStream will close itself when _readLoopRunning becomes false
|
|
956
|
+
return new Promise((resolve) => {
|
|
957
|
+
setTimeout(() => {
|
|
958
|
+
// Create new streams
|
|
959
|
+
this._createStreams();
|
|
960
|
+
resolve();
|
|
961
|
+
}, 100);
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
|
|
936
965
|
_cleanup() {
|
|
937
966
|
this._readLoopRunning = false;
|
|
938
967
|
if (this._usbDisconnectHandler) {
|
|
@@ -1013,5 +1042,11 @@ async function requestSerialPort(forceNew = false) {
|
|
|
1013
1042
|
throw new Error('Neither Web Serial API nor WebUSB is supported in this browser');
|
|
1014
1043
|
}
|
|
1015
1044
|
|
|
1045
|
+
// Also set on globalThis for non-module usage (e.g., dynamic script loading)
|
|
1046
|
+
if (typeof globalThis !== 'undefined') {
|
|
1047
|
+
globalThis.WebUSBSerial = WebUSBSerial;
|
|
1048
|
+
globalThis.requestSerialPort = requestSerialPort;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1016
1051
|
// Export as ES modules
|
|
1017
1052
|
export { WebUSBSerial, requestSerialPort };
|
package/package.cli.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esp32tool",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Flash & Read ESP devices using WebSerial, Electron, and also Android mobile via WebUSB",
|
|
6
6
|
"main": "electron/main.cjs",
|
|
@@ -25,12 +25,17 @@
|
|
|
25
25
|
"build:binary": "node build-single-binary.cjs",
|
|
26
26
|
"build:cli-electron": "node build-electron-cli.cjs",
|
|
27
27
|
"format": "npm exec -- prettier --write src",
|
|
28
|
-
"
|
|
28
|
+
"dev:clean": "node -e \"const fs=require('fs'); fs.rmSync('dist',{recursive:true,force:true});\"",
|
|
29
|
+
"dev:tsc-once": "tsc",
|
|
30
|
+
"dev:tsc": "tsc --watch",
|
|
31
|
+
"dev:rollup": "rollup -c --watch",
|
|
32
|
+
"dev:serve": "serve -p 5004",
|
|
33
|
+
"develop": "npm run dev:clean && npm run dev:tsc-once && npm-run-all --parallel dev:serve dev:tsc dev:rollup",
|
|
29
34
|
"lint": "eslint src/",
|
|
30
35
|
"lintAndFix": "eslint src/ --fix",
|
|
31
36
|
"start": "electron-forge start",
|
|
32
37
|
"package": "electron-forge package",
|
|
33
|
-
"make": "electron-forge make",
|
|
38
|
+
"make": "node -e \"const fs=require('fs'); fs.rmSync('out',{recursive:true,force:true});\" && electron-forge make",
|
|
34
39
|
"publish": "electron-forge publish",
|
|
35
40
|
"generate-icons": "./generate-icons.sh",
|
|
36
41
|
"test-pwa": "npx serve . -p 5004"
|
|
@@ -59,11 +64,12 @@
|
|
|
59
64
|
"eslint": "^9.39.2",
|
|
60
65
|
"eslint-config-prettier": "^10.1.8",
|
|
61
66
|
"eslint-plugin-prettier": "^5.5.4",
|
|
67
|
+
"npm-run-all": "^4.1.5",
|
|
62
68
|
"prettier": "^3.8.1",
|
|
63
|
-
"rollup": "^4.
|
|
69
|
+
"rollup": "^4.57.0",
|
|
64
70
|
"serve": "^14.2.4",
|
|
65
71
|
"typescript": "^5.7.3",
|
|
66
|
-
"typescript-eslint": "^8.
|
|
72
|
+
"typescript-eslint": "^8.54.0"
|
|
67
73
|
},
|
|
68
74
|
"dependencies": {
|
|
69
75
|
"pako": "^2.1.0",
|
package/screenshots/desktop.png
CHANGED
|
Binary file
|
package/screenshots/mobile.png
CHANGED
|
Binary file
|
package/src/const.ts
CHANGED
|
@@ -155,7 +155,7 @@ export const ESP32S3_UARTDEV_BUF_NO_USB_JTAG_SERIAL = 4; // The above var when U
|
|
|
155
155
|
|
|
156
156
|
export const ESP32C2_SPI_REG_BASE = 0x60002000;
|
|
157
157
|
export const ESP32C2_BASEFUSEADDR = 0x60008800;
|
|
158
|
-
export const ESP32C2_MACFUSEADDR =
|
|
158
|
+
export const ESP32C2_MACFUSEADDR = ESP32C2_BASEFUSEADDR + 0x040;
|
|
159
159
|
export const ESP32C2_SPI_USR_OFFS = 0x18;
|
|
160
160
|
export const ESP32C2_SPI_USR1_OFFS = 0x1c;
|
|
161
161
|
export const ESP32C2_SPI_USR2_OFFS = 0x20;
|