esp32tool 1.3.4 → 1.3.6

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/src/esp_loader.ts CHANGED
@@ -88,6 +88,13 @@ import {
88
88
  ESP32P4_RTC_CNTL_WDT_WKEY,
89
89
  ESP32P4_RTC_CNTL_OPTION1_REG,
90
90
  ESP32P4_RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK,
91
+ ESP32P4_LP_SYSTEM_REG_ANA_XPD_PAD_GROUP_REG,
92
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_ANA_REG,
93
+ ESP32P4_PMU_ANA_0P1A_EN_CUR_LIM_0,
94
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_REG,
95
+ ESP32P4_PMU_0P1A_TARGET0_0,
96
+ ESP32P4_PMU_0P1A_FORCE_TIEH_SEL_0,
97
+ ESP32P4_PMU_DATE_REG,
91
98
  } from "./const";
92
99
  import { getStubCode } from "./stubs";
93
100
  import { hexFormatter, sleep, slipEncode, toHex } from "./util";
@@ -500,6 +507,11 @@ export class ESPLoader extends EventTarget {
500
507
  // Detect chip type
501
508
  await this.detectChip();
502
509
 
510
+ // Power on flash for ESP32-P4 Rev 301 (must be done before loading stub)
511
+ if (this.chipFamily === CHIP_FAMILY_ESP32P4 && this.chipRevision === 301) {
512
+ await this.powerOnFlash();
513
+ }
514
+
503
515
  // Detect if device is using USB-JTAG/Serial or USB-OTG (not external serial chip)
504
516
  // This is needed to determine the correct reset strategy for console mode
505
517
  try {
@@ -647,6 +659,75 @@ export class ESPLoader extends EventTarget {
647
659
  return 0;
648
660
  }
649
661
 
662
+ /**
663
+ * Power on the flash chip for ESP32-P4 Rev 301 (ECO6)
664
+ * The flash chip is powered off by default on ECO6, when the default flash
665
+ * voltage changed from 1.8V to 3.3V. This is to prevent damage to 1.8V flash chips.
666
+ */
667
+ async powerOnFlash(): Promise<void> {
668
+ if (this.chipFamily !== CHIP_FAMILY_ESP32P4) {
669
+ return; // Only needed for ESP32-P4
670
+ }
671
+
672
+ if (this.chipRevision !== 301) {
673
+ return; // Only needed for Rev 301 (ECO6)
674
+ }
675
+
676
+ this.logger.debug("Powering on flash for ESP32-P4 Rev 301 (ECO6)");
677
+
678
+ // Power up pad group
679
+ await this.writeRegister(ESP32P4_LP_SYSTEM_REG_ANA_XPD_PAD_GROUP_REG, 1);
680
+ await sleep(10); // 0.01 seconds
681
+
682
+ // Flash power up sequence
683
+ const pmuAnaReg = await this.readRegister(
684
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_ANA_REG,
685
+ );
686
+ await this.writeRegister(
687
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_ANA_REG,
688
+ pmuAnaReg | ESP32P4_PMU_ANA_0P1A_EN_CUR_LIM_0,
689
+ );
690
+
691
+ const pmuReg = await this.readRegister(ESP32P4_PMU_EXT_LDO_P0_0P1A_REG);
692
+ await this.writeRegister(
693
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_REG,
694
+ pmuReg | ESP32P4_PMU_0P1A_FORCE_TIEH_SEL_0,
695
+ );
696
+
697
+ const pmuDateReg = await this.readRegister(ESP32P4_PMU_DATE_REG);
698
+ await this.writeRegister(ESP32P4_PMU_DATE_REG, pmuDateReg | (3 << 0));
699
+
700
+ await sleep(0.05); // 0.00005 seconds = 0.05 ms
701
+
702
+ const pmuAnaReg2 = await this.readRegister(
703
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_ANA_REG,
704
+ );
705
+ await this.writeRegister(
706
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_ANA_REG,
707
+ pmuAnaReg2 & ~ESP32P4_PMU_ANA_0P1A_EN_CUR_LIM_0,
708
+ );
709
+
710
+ const pmuReg2 = await this.readRegister(ESP32P4_PMU_EXT_LDO_P0_0P1A_REG);
711
+ await this.writeRegister(
712
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_REG,
713
+ pmuReg2 & ~ESP32P4_PMU_0P1A_TARGET0_0,
714
+ );
715
+
716
+ // Update eFuse voltage to PMU
717
+ const pmuReg3 = await this.readRegister(ESP32P4_PMU_EXT_LDO_P0_0P1A_REG);
718
+ await this.writeRegister(ESP32P4_PMU_EXT_LDO_P0_0P1A_REG, pmuReg3 | 0x80);
719
+
720
+ const pmuReg4 = await this.readRegister(ESP32P4_PMU_EXT_LDO_P0_0P1A_REG);
721
+ await this.writeRegister(
722
+ ESP32P4_PMU_EXT_LDO_P0_0P1A_REG,
723
+ pmuReg4 & ~ESP32P4_PMU_0P1A_FORCE_TIEH_SEL_0,
724
+ );
725
+
726
+ await sleep(2); // 0.0018 seconds = 1.8 ms, rounded to 2ms
727
+
728
+ this.logger.debug("Flash powered on successfully");
729
+ }
730
+
650
731
  /**
651
732
  * Get security info including chip ID (ESP32-C3 and later)
652
733
  */
@@ -1639,15 +1720,15 @@ export class ESPLoader extends EventTarget {
1639
1720
  if (this.chipFamily === CHIP_FAMILY_ESP32S2) {
1640
1721
  const wdtResetUsed = await this.tryUsbWdtReset("ESP32-S2");
1641
1722
  if (wdtResetUsed) return;
1642
- } else if (this.chipFamily === CHIP_FAMILY_ESP32S3) {
1643
- const wdtResetUsed = await this.tryUsbWdtReset("ESP32-S3");
1644
- if (wdtResetUsed) return;
1723
+ // } else if (this.chipFamily === CHIP_FAMILY_ESP32S3) {
1724
+ // const wdtResetUsed = await this.tryUsbWdtReset("ESP32-S3");
1725
+ // if (wdtResetUsed) return;
1645
1726
  } else if (this.chipFamily === CHIP_FAMILY_ESP32P4) {
1646
1727
  const wdtResetUsed = await this.tryUsbWdtReset("ESP32-P4");
1647
1728
  if (wdtResetUsed) return;
1648
- } else if (this.chipFamily === CHIP_FAMILY_ESP32C3) {
1649
- const wdtResetUsed = await this.tryUsbWdtReset("ESP32-C3");
1650
- if (wdtResetUsed) return;
1729
+ // } else if (this.chipFamily === CHIP_FAMILY_ESP32C3) {
1730
+ // const wdtResetUsed = await this.tryUsbWdtReset("ESP32-C3");
1731
+ // if (wdtResetUsed) return;
1651
1732
  } else if (this.chipFamily === CHIP_FAMILY_ESP32C5) {
1652
1733
  const wdtResetUsed = await this.tryUsbWdtReset("ESP32-C5");
1653
1734
  if (wdtResetUsed) return;
@@ -2827,6 +2908,9 @@ export class ESPLoader extends EventTarget {
2827
2908
  }
2828
2909
 
2829
2910
  async runStub(skipFlashDetection = false): Promise<EspStubLoader> {
2911
+ this.logger.debug(
2912
+ `Loading stub for ${this.chipName}, revision: ${this.chipRevision}`,
2913
+ );
2830
2914
  const stub = await getStubCode(this.chipFamily, this.chipRevision);
2831
2915
 
2832
2916
  // No stub available for this chip, return ROM loader
@@ -3536,6 +3620,14 @@ export class ESPLoader extends EventTarget {
3536
3620
  throw new Error("Port not ready after reconnect");
3537
3621
  }
3538
3622
 
3623
+ // Power on flash for ESP32-P4 Rev 301 (must be done before loading stub)
3624
+ if (
3625
+ this.chipFamily === CHIP_FAMILY_ESP32P4 &&
3626
+ this.chipRevision === 301
3627
+ ) {
3628
+ await this.powerOnFlash();
3629
+ }
3630
+
3539
3631
  // Load stub
3540
3632
  const stubLoader = await this.runStub(true);
3541
3633
  this.logger.debug("Stub loaded");
package/sw.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Service Worker for ESP32Tool PWA
2
- const CACHE_NAME = 'esp32tool-v1.3.4';
2
+ const CACHE_NAME = 'esp32tool-v1.3.5';
3
3
  const RUNTIME_CACHE = 'esp32tool-runtime';
4
4
 
5
5
  // Core files to cache on install (relative paths work for any deployment path)