esp32tool 1.1.8 → 1.2.0
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/.nojekyll +0 -0
- package/README.md +100 -6
- package/apple-touch-icon.png +0 -0
- package/build-electron-cli.cjs +177 -0
- package/build-single-binary.cjs +295 -0
- package/css/light.css +11 -0
- package/css/style.css +225 -35
- package/dist/cli.d.ts +17 -0
- package/dist/cli.js +458 -0
- package/dist/esp_loader.d.ts +129 -21
- package/dist/esp_loader.js +1227 -222
- package/dist/index.d.ts +2 -1
- package/dist/index.js +37 -4
- package/dist/node-usb-adapter.d.ts +47 -0
- package/dist/node-usb-adapter.js +725 -0
- package/dist/stubs/index.d.ts +1 -2
- package/dist/stubs/index.js +4 -0
- package/dist/web/index.js +1 -1
- package/electron/cli-main.cjs +74 -0
- package/electron/main.cjs +338 -0
- package/electron/main.js +7 -2
- package/favicon.ico +0 -0
- package/fix-cli-imports.cjs +127 -0
- package/generate-icons.sh +89 -0
- 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/index.html +94 -64
- package/install-android.html +411 -0
- package/js/modules/esptool.js +1 -1
- package/js/script.js +165 -160
- package/js/webusb-serial.js +1017 -0
- package/license.md +1 -1
- package/manifest.json +89 -0
- package/package.cli.json +29 -0
- package/package.json +31 -21
- package/screenshots/desktop.png +0 -0
- package/screenshots/mobile.png +0 -0
- package/src/cli.ts +618 -0
- package/src/esp_loader.ts +1438 -254
- package/src/index.ts +69 -3
- package/src/node-usb-adapter.ts +924 -0
- package/src/stubs/index.ts +4 -1
- package/sw.js +155 -0
package/src/index.ts
CHANGED
|
@@ -21,15 +21,81 @@ export {
|
|
|
21
21
|
CHIP_FAMILY_ESP32H21,
|
|
22
22
|
CHIP_FAMILY_ESP32P4,
|
|
23
23
|
CHIP_FAMILY_ESP32S31,
|
|
24
|
+
// Command constants
|
|
25
|
+
ESP_FLASH_BEGIN,
|
|
26
|
+
ESP_FLASH_DATA,
|
|
27
|
+
ESP_FLASH_END,
|
|
28
|
+
ESP_MEM_BEGIN,
|
|
29
|
+
ESP_MEM_END,
|
|
30
|
+
ESP_MEM_DATA,
|
|
31
|
+
ESP_SYNC,
|
|
32
|
+
ESP_WRITE_REG,
|
|
33
|
+
ESP_READ_REG,
|
|
34
|
+
ESP_ERASE_FLASH,
|
|
35
|
+
ESP_ERASE_REGION,
|
|
36
|
+
ESP_READ_FLASH,
|
|
37
|
+
ESP_SPI_SET_PARAMS,
|
|
38
|
+
ESP_SPI_ATTACH,
|
|
39
|
+
ESP_CHANGE_BAUDRATE,
|
|
40
|
+
ESP_SPI_FLASH_MD5,
|
|
41
|
+
ESP_GET_SECURITY_INFO,
|
|
42
|
+
ESP_CHECKSUM_MAGIC,
|
|
43
|
+
ESP_FLASH_DEFL_BEGIN,
|
|
44
|
+
ESP_FLASH_DEFL_DATA,
|
|
45
|
+
ESP_FLASH_DEFL_END,
|
|
46
|
+
ROM_INVALID_RECV_MSG,
|
|
47
|
+
// Block size constants
|
|
48
|
+
USB_RAM_BLOCK,
|
|
49
|
+
ESP_RAM_BLOCK,
|
|
50
|
+
// Timeout constants
|
|
51
|
+
DEFAULT_TIMEOUT,
|
|
52
|
+
CHIP_ERASE_TIMEOUT,
|
|
53
|
+
MAX_TIMEOUT,
|
|
54
|
+
SYNC_TIMEOUT,
|
|
55
|
+
ERASE_REGION_TIMEOUT_PER_MB,
|
|
56
|
+
MEM_END_ROM_TIMEOUT,
|
|
57
|
+
FLASH_READ_TIMEOUT,
|
|
24
58
|
} from "./const";
|
|
25
59
|
|
|
26
60
|
export const connect = async (logger: Logger) => {
|
|
27
61
|
// - Request a port and open a connection.
|
|
28
|
-
|
|
62
|
+
// Try to use requestSerialPort if available (supports WebUSB for Android)
|
|
63
|
+
let port: SerialPort;
|
|
64
|
+
const customRequestPort = (
|
|
65
|
+
globalThis as { requestSerialPort?: () => Promise<SerialPort> }
|
|
66
|
+
).requestSerialPort;
|
|
67
|
+
if (typeof customRequestPort === "function") {
|
|
68
|
+
port = await customRequestPort();
|
|
69
|
+
} else {
|
|
70
|
+
// Check if Web Serial API is available
|
|
71
|
+
if (!navigator.serial) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
"Web Serial API is not supported in this browser. " +
|
|
74
|
+
"Please use Chrome, Edge, or Opera on desktop, or Chrome on Android. " +
|
|
75
|
+
"Note: The page must be served over HTTPS or localhost.",
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
port = await navigator.serial.requestPort();
|
|
79
|
+
}
|
|
29
80
|
|
|
30
|
-
|
|
81
|
+
// Only open if not already open (requestSerialPort may return an opened port)
|
|
82
|
+
if (!port.readable || !port.writable) {
|
|
83
|
+
await port.open({ baudRate: ESP_ROM_BAUD });
|
|
84
|
+
}
|
|
31
85
|
|
|
32
|
-
|
|
86
|
+
return new ESPLoader(port, logger);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const connectWithPort = async (port: SerialPort, logger: Logger) => {
|
|
90
|
+
// Connect using an already opened port (useful for WebUSB wrapper)
|
|
91
|
+
if (!port) {
|
|
92
|
+
throw new Error("Port is required");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Check if port is already open, if not open it
|
|
96
|
+
if (!port.readable || !port.writable) {
|
|
97
|
+
await port.open({ baudRate: ESP_ROM_BAUD });
|
|
98
|
+
}
|
|
33
99
|
|
|
34
100
|
return new ESPLoader(port, logger);
|
|
35
101
|
};
|