esp32tool 1.4.0 → 1.5.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/apple-touch-icon.png +0 -0
- package/css/style.css +463 -0
- package/dist/cli.js +2 -2
- package/dist/esp_loader.js +29 -17
- package/dist/node-usb-adapter.js +13 -13
- package/dist/util/console-color.js +1 -0
- package/dist/util.d.ts +5 -0
- package/dist/util.js +15 -0
- package/dist/web/index.js +1 -1
- package/eslint.config.js +9 -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 +5 -0
- package/js/hex-editor.js +833 -0
- package/js/modules/esptool.js +1 -1
- package/js/script.js +164 -24
- package/package.json +7 -7
- package/screenshots/desktop.png +0 -0
- package/screenshots/mobile.png +0 -0
- package/src/cli.ts +2 -2
- package/src/const.ts +0 -2
- package/src/esp_loader.ts +30 -17
- package/src/node-usb-adapter.ts +13 -13
- package/src/util/console-color.ts +1 -0
- package/src/util.ts +20 -0
- package/sw.js +2 -1
package/apple-touch-icon.png
CHANGED
|
Binary file
|
package/css/style.css
CHANGED
|
@@ -2269,3 +2269,466 @@ body.console-active .main {
|
|
|
2269
2269
|
padding-top: 0 !important;
|
|
2270
2270
|
overflow: hidden !important;
|
|
2271
2271
|
}
|
|
2272
|
+
|
|
2273
|
+
/* ========== Hex Editor Container ========== */
|
|
2274
|
+
.hexeditor-container {
|
|
2275
|
+
position: fixed;
|
|
2276
|
+
top: 0;
|
|
2277
|
+
left: 0;
|
|
2278
|
+
right: 0;
|
|
2279
|
+
bottom: 0;
|
|
2280
|
+
z-index: 1001;
|
|
2281
|
+
background-color: #1c1c1c;
|
|
2282
|
+
display: flex;
|
|
2283
|
+
flex-direction: column;
|
|
2284
|
+
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
2285
|
+
color: #ddd;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
.hexeditor-container.hidden {
|
|
2289
|
+
display: none;
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
/* Hide header and commands when hex editor is active */
|
|
2293
|
+
body.hexeditor-active .header {
|
|
2294
|
+
display: none !important;
|
|
2295
|
+
}
|
|
2296
|
+
body.hexeditor-active #commands {
|
|
2297
|
+
display: none !important;
|
|
2298
|
+
}
|
|
2299
|
+
body.hexeditor-active #notSupported {
|
|
2300
|
+
display: none !important;
|
|
2301
|
+
}
|
|
2302
|
+
body.hexeditor-active .main {
|
|
2303
|
+
padding-top: 0 !important;
|
|
2304
|
+
overflow: hidden !important;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
/* Hex Editor Header / Toolbar */
|
|
2308
|
+
.hexeditor-toolbar {
|
|
2309
|
+
display: flex;
|
|
2310
|
+
align-items: center;
|
|
2311
|
+
gap: 8px;
|
|
2312
|
+
padding: 6px 12px;
|
|
2313
|
+
background-color: #2a2a2a;
|
|
2314
|
+
border-bottom: 1px solid #444;
|
|
2315
|
+
flex-wrap: wrap;
|
|
2316
|
+
min-height: 40px;
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
.hexeditor-toolbar h3 {
|
|
2320
|
+
margin: 0;
|
|
2321
|
+
font-size: 14px;
|
|
2322
|
+
font-weight: 600;
|
|
2323
|
+
white-space: nowrap;
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
.hexeditor-toolbar .spacer {
|
|
2327
|
+
flex: 1;
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
.hexeditor-toolbar button {
|
|
2331
|
+
padding: 4px 14px;
|
|
2332
|
+
font-size: 12px;
|
|
2333
|
+
background-color: #444;
|
|
2334
|
+
color: #ddd;
|
|
2335
|
+
border: 1px solid #555;
|
|
2336
|
+
border-radius: 3px;
|
|
2337
|
+
cursor: pointer;
|
|
2338
|
+
white-space: nowrap;
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
.hexeditor-toolbar button:hover {
|
|
2342
|
+
background-color: #555;
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
.hexeditor-toolbar button.primary {
|
|
2346
|
+
background-color: #2e7d32;
|
|
2347
|
+
border-color: #388e3c;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
.hexeditor-toolbar button.primary:hover {
|
|
2351
|
+
background-color: #388e3c;
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
.hexeditor-toolbar button.danger {
|
|
2355
|
+
background-color: #c62828;
|
|
2356
|
+
border-color: #d32f2f;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
.hexeditor-toolbar button.danger:hover {
|
|
2360
|
+
background-color: #d32f2f;
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
.hexeditor-toolbar button:disabled {
|
|
2364
|
+
opacity: 0.5;
|
|
2365
|
+
cursor: not-allowed;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
/* Search bar */
|
|
2369
|
+
.hexeditor-search {
|
|
2370
|
+
display: flex;
|
|
2371
|
+
align-items: center;
|
|
2372
|
+
gap: 6px;
|
|
2373
|
+
padding: 4px 12px;
|
|
2374
|
+
background-color: #252525;
|
|
2375
|
+
border-bottom: 1px solid #333;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
.hexeditor-search label {
|
|
2379
|
+
font-size: 12px;
|
|
2380
|
+
color: #aaa;
|
|
2381
|
+
white-space: nowrap;
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
.hexeditor-search input[type="text"] {
|
|
2385
|
+
padding: 3px 8px;
|
|
2386
|
+
font-size: 12px;
|
|
2387
|
+
font-family: inherit;
|
|
2388
|
+
background-color: #333;
|
|
2389
|
+
color: #ddd;
|
|
2390
|
+
border: 1px solid #555;
|
|
2391
|
+
border-radius: 3px;
|
|
2392
|
+
outline: none;
|
|
2393
|
+
width: 200px;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
.hexeditor-search input[type="text"]:focus {
|
|
2397
|
+
border-color: #71ae1e;
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
.hexeditor-search select {
|
|
2401
|
+
padding: 3px 6px;
|
|
2402
|
+
font-size: 12px;
|
|
2403
|
+
font-family: inherit;
|
|
2404
|
+
background-color: #333;
|
|
2405
|
+
color: #ddd;
|
|
2406
|
+
border: 1px solid #555;
|
|
2407
|
+
border-radius: 3px;
|
|
2408
|
+
outline: none;
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
.hexeditor-search button {
|
|
2412
|
+
padding: 3px 10px;
|
|
2413
|
+
font-size: 12px;
|
|
2414
|
+
background-color: #444;
|
|
2415
|
+
color: #ddd;
|
|
2416
|
+
border: 1px solid #555;
|
|
2417
|
+
border-radius: 3px;
|
|
2418
|
+
cursor: pointer;
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
.hexeditor-search button:hover {
|
|
2422
|
+
background-color: #555;
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
.hexeditor-search .search-info {
|
|
2426
|
+
font-size: 11px;
|
|
2427
|
+
color: #888;
|
|
2428
|
+
margin-left: 4px;
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
/* Status bar */
|
|
2432
|
+
.hexeditor-statusbar {
|
|
2433
|
+
display: flex;
|
|
2434
|
+
align-items: center;
|
|
2435
|
+
gap: 16px;
|
|
2436
|
+
padding: 4px 12px;
|
|
2437
|
+
background-color: #1a3a1a;
|
|
2438
|
+
border-top: 1px solid #444;
|
|
2439
|
+
font-size: 11px;
|
|
2440
|
+
color: #aaa;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
.hexeditor-statusbar .status-item {
|
|
2444
|
+
white-space: nowrap;
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
.hexeditor-statusbar .status-modified {
|
|
2448
|
+
color: #ffab40;
|
|
2449
|
+
font-weight: 600;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
/* Main hex content area */
|
|
2453
|
+
.hexeditor-body {
|
|
2454
|
+
flex: 1;
|
|
2455
|
+
overflow: hidden;
|
|
2456
|
+
display: flex;
|
|
2457
|
+
flex-direction: column;
|
|
2458
|
+
position: relative;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
.hexeditor-viewport {
|
|
2462
|
+
flex: 1;
|
|
2463
|
+
overflow-y: auto;
|
|
2464
|
+
overflow-x: auto;
|
|
2465
|
+
position: relative;
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
/* Row layout */
|
|
2469
|
+
.hexeditor-row {
|
|
2470
|
+
display: flex;
|
|
2471
|
+
line-height: 20px;
|
|
2472
|
+
height: 20px;
|
|
2473
|
+
white-space: nowrap;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
.hexeditor-row:hover {
|
|
2477
|
+
background-color: #2a2a2a;
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
.hexeditor-row.highlight-row {
|
|
2481
|
+
background-color: #3a3a1a !important;
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
/* Address gutter */
|
|
2485
|
+
.hexeditor-addr {
|
|
2486
|
+
width: 80px;
|
|
2487
|
+
min-width: 80px;
|
|
2488
|
+
text-align: right;
|
|
2489
|
+
padding-right: 12px;
|
|
2490
|
+
color: #6a9955;
|
|
2491
|
+
font-size: 12px;
|
|
2492
|
+
user-select: none;
|
|
2493
|
+
-webkit-user-select: none;
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
/* Hex cells area */
|
|
2497
|
+
.hexeditor-hex {
|
|
2498
|
+
display: flex;
|
|
2499
|
+
gap: 0;
|
|
2500
|
+
padding-right: 16px;
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
.hexeditor-hex .hex-cell {
|
|
2504
|
+
width: 26px;
|
|
2505
|
+
text-align: center;
|
|
2506
|
+
font-size: 12px;
|
|
2507
|
+
cursor: text;
|
|
2508
|
+
color: #ddd;
|
|
2509
|
+
border: 1px solid transparent;
|
|
2510
|
+
padding: 0 1px;
|
|
2511
|
+
box-sizing: border-box;
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
.hexeditor-hex .hex-cell:nth-child(8n) {
|
|
2515
|
+
margin-right: 6px;
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
.hexeditor-hex .hex-cell.modified {
|
|
2519
|
+
color: #ff6b6b;
|
|
2520
|
+
font-weight: bold;
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
.hexeditor-hex .hex-cell.selected {
|
|
2524
|
+
background-color: #264f78;
|
|
2525
|
+
border-color: #3a7cbf;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
.hexeditor-hex .hex-cell.search-match {
|
|
2529
|
+
background-color: #5a5a00;
|
|
2530
|
+
border-color: #8a8a00;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
.hexeditor-hex .hex-cell.search-current {
|
|
2534
|
+
background-color: #8a6a00;
|
|
2535
|
+
border-color: #bb9b00;
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
.hexeditor-hex .hex-cell.editing {
|
|
2539
|
+
background-color: #1e3a5f;
|
|
2540
|
+
border-color: #4a90d9;
|
|
2541
|
+
outline: none;
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
.hexeditor-hex .hex-cell.zero {
|
|
2545
|
+
color: #555;
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
.hexeditor-hex .hex-cell.ff {
|
|
2549
|
+
color: #666;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
/* Separator between hex and ASCII */
|
|
2553
|
+
.hexeditor-sep {
|
|
2554
|
+
width: 2px;
|
|
2555
|
+
min-width: 2px;
|
|
2556
|
+
background-color: #444;
|
|
2557
|
+
margin: 0 4px;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
/* ASCII area */
|
|
2561
|
+
.hexeditor-ascii {
|
|
2562
|
+
display: flex;
|
|
2563
|
+
gap: 0;
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
.hexeditor-ascii .ascii-cell {
|
|
2567
|
+
width: 9px;
|
|
2568
|
+
text-align: center;
|
|
2569
|
+
font-size: 12px;
|
|
2570
|
+
cursor: text;
|
|
2571
|
+
color: #b5cea8;
|
|
2572
|
+
border: 1px solid transparent;
|
|
2573
|
+
box-sizing: border-box;
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
.hexeditor-ascii .ascii-cell.non-printable {
|
|
2577
|
+
color: #555;
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
.hexeditor-ascii .ascii-cell.modified {
|
|
2581
|
+
color: #ff6b6b;
|
|
2582
|
+
font-weight: bold;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
.hexeditor-ascii .ascii-cell.selected {
|
|
2586
|
+
background-color: #264f78;
|
|
2587
|
+
border-color: #3a7cbf;
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
.hexeditor-ascii .ascii-cell.search-match {
|
|
2591
|
+
background-color: #5a5a00;
|
|
2592
|
+
border-color: #8a8a00;
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
.hexeditor-ascii .ascii-cell.search-current {
|
|
2596
|
+
background-color: #8a6a00;
|
|
2597
|
+
border-color: #bb9b00;
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
.hexeditor-ascii .ascii-cell.editing {
|
|
2601
|
+
background-color: #1e3a5f;
|
|
2602
|
+
border-color: #4a90d9;
|
|
2603
|
+
outline: none;
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
/* Progress overlay for loading */
|
|
2607
|
+
.hexeditor-progress-overlay {
|
|
2608
|
+
position: absolute;
|
|
2609
|
+
top: 0; left: 0; right: 0; bottom: 0;
|
|
2610
|
+
background-color: rgba(0,0,0,0.85);
|
|
2611
|
+
display: flex;
|
|
2612
|
+
flex-direction: column;
|
|
2613
|
+
align-items: center;
|
|
2614
|
+
justify-content: center;
|
|
2615
|
+
z-index: 10;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
.hexeditor-progress-overlay.hidden {
|
|
2619
|
+
display: none;
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
.hexeditor-progress-overlay .progress-text {
|
|
2623
|
+
font-size: 16px;
|
|
2624
|
+
color: #ddd;
|
|
2625
|
+
margin-bottom: 16px;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
.hexeditor-progress-overlay .progress-bar-outer {
|
|
2629
|
+
width: 400px;
|
|
2630
|
+
max-width: 80%;
|
|
2631
|
+
height: 20px;
|
|
2632
|
+
background-color: #333;
|
|
2633
|
+
border-radius: 10px;
|
|
2634
|
+
overflow: hidden;
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
.hexeditor-progress-overlay .progress-bar-inner {
|
|
2638
|
+
height: 100%;
|
|
2639
|
+
background-color: #71ae1e;
|
|
2640
|
+
width: 0%;
|
|
2641
|
+
transition: width 0.15s linear;
|
|
2642
|
+
border-radius: 10px;
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
/* Goto address input */
|
|
2646
|
+
.hexeditor-goto {
|
|
2647
|
+
display: flex;
|
|
2648
|
+
align-items: center;
|
|
2649
|
+
gap: 6px;
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
.hexeditor-goto input {
|
|
2653
|
+
width: 100px;
|
|
2654
|
+
padding: 3px 8px;
|
|
2655
|
+
font-size: 12px;
|
|
2656
|
+
font-family: inherit;
|
|
2657
|
+
background-color: #333;
|
|
2658
|
+
color: #ddd;
|
|
2659
|
+
border: 1px solid #555;
|
|
2660
|
+
border-radius: 3px;
|
|
2661
|
+
outline: none;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
.hexeditor-goto input:focus {
|
|
2665
|
+
border-color: #71ae1e;
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
/* Responsive hex editor for narrow viewports */
|
|
2669
|
+
@media (max-width: 768px) {
|
|
2670
|
+
.hexeditor-container {
|
|
2671
|
+
font-size: 11px;
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
.hexeditor-toolbar {
|
|
2675
|
+
padding: 4px 8px;
|
|
2676
|
+
gap: 4px;
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
.hexeditor-toolbar h3 {
|
|
2680
|
+
font-size: 12px;
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
.hexeditor-toolbar button {
|
|
2684
|
+
padding: 3px 8px;
|
|
2685
|
+
font-size: 11px;
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
.hexeditor-search {
|
|
2689
|
+
flex-wrap: wrap;
|
|
2690
|
+
gap: 4px;
|
|
2691
|
+
padding: 4px 8px;
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
.hexeditor-search input[type="text"] {
|
|
2695
|
+
width: 140px;
|
|
2696
|
+
font-size: 11px;
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
.hexeditor-addr {
|
|
2700
|
+
width: 64px;
|
|
2701
|
+
min-width: 64px;
|
|
2702
|
+
padding-right: 6px;
|
|
2703
|
+
font-size: 11px;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
.hexeditor-hex .hex-cell {
|
|
2707
|
+
width: 20px;
|
|
2708
|
+
font-size: 11px;
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
.hexeditor-hex .hex-cell:nth-child(8n) {
|
|
2712
|
+
margin-right: 3px;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
.hexeditor-ascii .ascii-cell {
|
|
2716
|
+
width: 7px;
|
|
2717
|
+
font-size: 11px;
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
.hexeditor-sep {
|
|
2721
|
+
margin: 0 2px;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
.hexeditor-statusbar {
|
|
2725
|
+
gap: 8px;
|
|
2726
|
+
padding: 3px 8px;
|
|
2727
|
+
font-size: 10px;
|
|
2728
|
+
flex-wrap: wrap;
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
.hexeditor-goto input {
|
|
2732
|
+
width: 70px;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -218,7 +218,7 @@ async function connectViaUSB(targetVid, targetPid, baudRate) {
|
|
|
218
218
|
try {
|
|
219
219
|
await webPort.close();
|
|
220
220
|
}
|
|
221
|
-
catch (
|
|
221
|
+
catch (_closeErr) {
|
|
222
222
|
// Ignore close errors
|
|
223
223
|
}
|
|
224
224
|
}
|
|
@@ -427,7 +427,7 @@ async function main() {
|
|
|
427
427
|
try {
|
|
428
428
|
await esploader.disconnect();
|
|
429
429
|
}
|
|
430
|
-
catch (
|
|
430
|
+
catch (_disconnectErr) {
|
|
431
431
|
// Ignore disconnect errors during error handling
|
|
432
432
|
}
|
|
433
433
|
}
|
package/dist/esp_loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="@types/w3c-web-serial" />
|
|
2
2
|
import { CHIP_FAMILY_ESP32, CHIP_FAMILY_ESP32S2, CHIP_FAMILY_ESP32S3, CHIP_FAMILY_ESP32C2, CHIP_FAMILY_ESP32C3, CHIP_FAMILY_ESP32C5, CHIP_FAMILY_ESP32C6, CHIP_FAMILY_ESP32C61, CHIP_FAMILY_ESP32H2, CHIP_FAMILY_ESP32H4, CHIP_FAMILY_ESP32H21, CHIP_FAMILY_ESP32P4, CHIP_FAMILY_ESP32S31, CHIP_FAMILY_ESP8266, MAX_TIMEOUT, DEFAULT_TIMEOUT, ERASE_REGION_TIMEOUT_PER_MB, ESP_CHANGE_BAUDRATE, ESP_CHECKSUM_MAGIC, ESP_FLASH_BEGIN, ESP_FLASH_DATA, ESP_FLASH_END, ESP_MEM_BEGIN, ESP_MEM_DATA, ESP_MEM_END, ESP_READ_REG, ESP_WRITE_REG, ESP_SPI_ATTACH, ESP_SYNC, ESP_GET_SECURITY_INFO, FLASH_SECTOR_SIZE, FLASH_WRITE_SIZE, STUB_FLASH_WRITE_SIZE, MEM_END_ROM_TIMEOUT, ROM_INVALID_RECV_MSG, SYNC_PACKET, SYNC_TIMEOUT, USB_RAM_BLOCK, ESP_ERASE_FLASH, ESP_ERASE_REGION, ESP_READ_FLASH, CHIP_ERASE_TIMEOUT, FLASH_READ_TIMEOUT, timeoutPerMb, ESP_ROM_BAUD, USB_JTAG_SERIAL_PID, ESP_FLASH_DEFL_BEGIN, ESP_FLASH_DEFL_DATA, ESP_FLASH_DEFL_END, getSpiFlashAddresses, DETECTED_FLASH_SIZES, CHIP_DETECT_MAGIC_REG_ADDR, CHIP_DETECT_MAGIC_VALUES, CHIP_ID_TO_INFO, ESP32_BASEFUSEADDR, ESP32_APB_CTL_DATE_ADDR, ESP32S2_EFUSE_BLOCK1_ADDR, ESP32S3_EFUSE_BLOCK1_ADDR, ESP32C2_EFUSE_BLOCK2_ADDR, ESP32C5_EFUSE_BLOCK1_ADDR, ESP32C6_EFUSE_BLOCK1_ADDR, ESP32C61_EFUSE_BLOCK1_ADDR, ESP32H2_EFUSE_BLOCK1_ADDR, ESP32P4_EFUSE_BLOCK1_ADDR, ESP32S31_EFUSE_BLOCK1_ADDR, SlipReadError, ESP32S2_RTC_CNTL_WDTWPROTECT_REG, ESP32S2_RTC_CNTL_WDTCONFIG0_REG, ESP32S2_RTC_CNTL_WDTCONFIG1_REG, ESP32S2_RTC_CNTL_WDT_WKEY, ESP32S2_RTC_CNTL_OPTION1_REG, ESP32S2_RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK, ESP32S3_RTC_CNTL_WDTWPROTECT_REG, ESP32S3_RTC_CNTL_WDTCONFIG0_REG, ESP32S3_RTC_CNTL_WDTCONFIG1_REG, ESP32S3_RTC_CNTL_WDT_WKEY, ESP32S3_RTC_CNTL_OPTION1_REG, ESP32S3_RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK, ESP32C3_EFUSE_RD_MAC_SPI_SYS_3_REG, ESP32C3_EFUSE_RD_MAC_SPI_SYS_5_REG, ESP32C3_RTC_CNTL_WDTWPROTECT_REG, ESP32C3_RTC_CNTL_WDTCONFIG0_REG, ESP32C3_RTC_CNTL_WDTCONFIG1_REG, ESP32C3_RTC_CNTL_WDT_WKEY, ESP32C5_C6_RTC_CNTL_WDTWPROTECT_REG, ESP32C5_C6_RTC_CNTL_WDTCONFIG0_REG, ESP32C5_C6_RTC_CNTL_WDTCONFIG1_REG, ESP32C5_C6_RTC_CNTL_WDT_WKEY, ESP32C5_UART_CLKDIV_REG, ESP32C5_PCR_SYSCLK_CONF_REG, ESP32C5_PCR_SYSCLK_XTAL_FREQ_V, ESP32C5_PCR_SYSCLK_XTAL_FREQ_S, ESP32P4_RTC_CNTL_WDTWPROTECT_REG, ESP32P4_RTC_CNTL_WDTCONFIG0_REG, ESP32P4_RTC_CNTL_WDTCONFIG1_REG, ESP32P4_RTC_CNTL_WDT_WKEY, ESP32P4_RTC_CNTL_OPTION1_REG, ESP32P4_RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK, ESP32P4_LP_SYSTEM_REG_ANA_XPD_PAD_GROUP_REG, ESP32P4_PMU_EXT_LDO_P0_0P1A_ANA_REG, ESP32P4_PMU_ANA_0P1A_EN_CUR_LIM_0, ESP32P4_PMU_EXT_LDO_P0_0P1A_REG, ESP32P4_PMU_0P1A_TARGET0_0, ESP32P4_PMU_0P1A_FORCE_TIEH_SEL_0, ESP32P4_PMU_DATE_REG, ESP32S2_UARTDEV_BUF_NO, ESP32S2_UARTDEV_BUF_NO_USB_OTG, ESP32S3_UARTDEV_BUF_NO, ESP32S3_UARTDEV_BUF_NO_USB_OTG, ESP32S3_UARTDEV_BUF_NO_USB_JTAG_SERIAL, ESP32C3_UARTDEV_BUF_NO_USB_JTAG_SERIAL, ESP32C3_BUF_UART_NO_OFFSET, ESP32C5_UARTDEV_BUF_NO, ESP32C5_UARTDEV_BUF_NO_USB_JTAG_SERIAL, ESP32C6_UARTDEV_BUF_NO, ESP32C6_UARTDEV_BUF_NO_USB_JTAG_SERIAL, ESP32C61_UARTDEV_BUF_NO_REV_LE2, ESP32C61_UARTDEV_BUF_NO_REV_GT2, ESP32C61_UARTDEV_BUF_NO_USB_JTAG_SERIAL_REV_LE2, ESP32C61_UARTDEV_BUF_NO_USB_JTAG_SERIAL_REV_GT2, ESP32H2_UARTDEV_BUF_NO, ESP32H2_UARTDEV_BUF_NO_USB_JTAG_SERIAL, ESP32H4_UARTDEV_BUF_NO, ESP32H4_UARTDEV_BUF_NO_USB_JTAG_SERIAL, ESP32P4_UARTDEV_BUF_NO_REV0, ESP32P4_UARTDEV_BUF_NO_REV300, ESP32P4_UARTDEV_BUF_NO_USB_OTG, ESP32P4_UARTDEV_BUF_NO_USB_JTAG_SERIAL, } from "./const";
|
|
3
3
|
import { getStubCode } from "./stubs";
|
|
4
|
-
import { hexFormatter, sleep, slipEncode, toHex } from "./util";
|
|
4
|
+
import { hexFormatter, padTo, sleep, slipEncode, toHex } from "./util";
|
|
5
5
|
import { FLASH_MANUFACTURERS, FLASH_DEVICES } from "./flash_jedec";
|
|
6
6
|
import { deflate } from "pako";
|
|
7
7
|
import { pack, unpack } from "./struct";
|
|
@@ -714,14 +714,20 @@ export class ESPLoader extends EventTarget {
|
|
|
714
714
|
}
|
|
715
715
|
else {
|
|
716
716
|
if (step.dtr !== undefined) {
|
|
717
|
-
webusb
|
|
718
|
-
|
|
719
|
-
|
|
717
|
+
if (webusb) {
|
|
718
|
+
await this.setDTRWebUSB(step.dtr);
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
await this.setDTR(step.dtr);
|
|
722
|
+
}
|
|
720
723
|
}
|
|
721
724
|
if (step.rts !== undefined) {
|
|
722
|
-
webusb
|
|
723
|
-
|
|
724
|
-
|
|
725
|
+
if (webusb) {
|
|
726
|
+
await this.setRTSWebUSB(step.rts);
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
await this.setRTS(step.rts);
|
|
730
|
+
}
|
|
725
731
|
}
|
|
726
732
|
}
|
|
727
733
|
if (step.delayMs)
|
|
@@ -1078,8 +1084,12 @@ export class ESPLoader extends EventTarget {
|
|
|
1078
1084
|
});
|
|
1079
1085
|
}
|
|
1080
1086
|
}
|
|
1081
|
-
// Add general fallback strategies only for
|
|
1082
|
-
|
|
1087
|
+
// Add general fallback strategies only for Native USB chips (not USB-Serial)
|
|
1088
|
+
// and only for chips not already handled by specific blocks above
|
|
1089
|
+
if (!isUSBSerialChip &&
|
|
1090
|
+
!isCP2102 &&
|
|
1091
|
+
!isESP32S2NativeUSB &&
|
|
1092
|
+
!isUSBJTAGSerial) {
|
|
1083
1093
|
// Classic reset (for chips not handled above)
|
|
1084
1094
|
if (portInfo.usbVendorId !== 0x1a86) {
|
|
1085
1095
|
resetStrategies.push({
|
|
@@ -1111,7 +1121,7 @@ export class ESPLoader extends EventTarget {
|
|
|
1111
1121
|
},
|
|
1112
1122
|
});
|
|
1113
1123
|
// WebUSB Strategy: USB-JTAG/Serial fallback
|
|
1114
|
-
if (!
|
|
1124
|
+
if (!isEspressifUSB) {
|
|
1115
1125
|
resetStrategies.push({
|
|
1116
1126
|
name: "USB-JTAG/Serial fallback (WebUSB)",
|
|
1117
1127
|
fn: async function () {
|
|
@@ -1189,7 +1199,7 @@ export class ESPLoader extends EventTarget {
|
|
|
1189
1199
|
this.logger.debug(`Connected CDC/JTAG successfully with ${strategy.name} reset.`);
|
|
1190
1200
|
return;
|
|
1191
1201
|
}
|
|
1192
|
-
catch (
|
|
1202
|
+
catch (_error) {
|
|
1193
1203
|
throw new Error("Sync timeout or abandoned");
|
|
1194
1204
|
}
|
|
1195
1205
|
}
|
|
@@ -1991,7 +2001,7 @@ export class ESPLoader extends EventTarget {
|
|
|
1991
2001
|
// Restart Readloop
|
|
1992
2002
|
this.readLoop();
|
|
1993
2003
|
}
|
|
1994
|
-
catch (
|
|
2004
|
+
catch (_e) {
|
|
1995
2005
|
// this.logger.error(`Reconfigure port error: ${e}`);
|
|
1996
2006
|
// throw new Error(`Unable to change the baud rate to ${baud}: ${e}`);
|
|
1997
2007
|
}
|
|
@@ -2100,6 +2110,8 @@ export class ESPLoader extends EventTarget {
|
|
|
2100
2110
|
const headerFlashSizeFreq = header[3];
|
|
2101
2111
|
this.logger.log(`Image header, Magic=${toHex(headerMagic)}, FlashMode=${toHex(headerFlashMode)}, FlashSizeFreq=${toHex(headerFlashSizeFreq)}`);
|
|
2102
2112
|
}
|
|
2113
|
+
const paddedData = padTo(new Uint8Array(binaryData), 4);
|
|
2114
|
+
binaryData = paddedData.buffer;
|
|
2103
2115
|
const uncompressedFilesize = binaryData.byteLength;
|
|
2104
2116
|
let compressedFilesize = 0;
|
|
2105
2117
|
let dataToFlash;
|
|
@@ -2596,7 +2608,7 @@ export class ESPLoader extends EventTarget {
|
|
|
2596
2608
|
try {
|
|
2597
2609
|
await this._writeChain;
|
|
2598
2610
|
}
|
|
2599
|
-
catch (
|
|
2611
|
+
catch (_err) {
|
|
2600
2612
|
// this.logger.debug(`Pending write error during disconnect: ${err}`);
|
|
2601
2613
|
}
|
|
2602
2614
|
// Release persistent writer before closing
|
|
@@ -2605,7 +2617,7 @@ export class ESPLoader extends EventTarget {
|
|
|
2605
2617
|
await this._writer.close();
|
|
2606
2618
|
this._writer.releaseLock();
|
|
2607
2619
|
}
|
|
2608
|
-
catch (
|
|
2620
|
+
catch (_err) {
|
|
2609
2621
|
// this.logger.debug(`Writer close/release error: ${err}`);
|
|
2610
2622
|
}
|
|
2611
2623
|
this._writer = undefined;
|
|
@@ -2618,7 +2630,7 @@ export class ESPLoader extends EventTarget {
|
|
|
2618
2630
|
await writer.close();
|
|
2619
2631
|
writer.releaseLock();
|
|
2620
2632
|
}
|
|
2621
|
-
catch (
|
|
2633
|
+
catch (_err) {
|
|
2622
2634
|
// this.logger.debug(`Direct writer close error: ${err}`);
|
|
2623
2635
|
}
|
|
2624
2636
|
}
|
|
@@ -2640,7 +2652,7 @@ export class ESPLoader extends EventTarget {
|
|
|
2640
2652
|
try {
|
|
2641
2653
|
this._reader.cancel();
|
|
2642
2654
|
}
|
|
2643
|
-
catch (
|
|
2655
|
+
catch (_err) {
|
|
2644
2656
|
// Reader already released, resolve immediately
|
|
2645
2657
|
clearTimeout(timeout);
|
|
2646
2658
|
resolve(undefined);
|
|
@@ -2670,7 +2682,7 @@ export class ESPLoader extends EventTarget {
|
|
|
2670
2682
|
try {
|
|
2671
2683
|
await this._writeChain;
|
|
2672
2684
|
}
|
|
2673
|
-
catch (
|
|
2685
|
+
catch (_err) {
|
|
2674
2686
|
// this.logger.debug(`Pending write error during release: ${err}`);
|
|
2675
2687
|
}
|
|
2676
2688
|
// Release writer
|