Skip to content

Commit cb801d0

Browse files
authored
s31 stub support (#111)
1 parent 436c9dd commit cb801d0

5 files changed

Lines changed: 39 additions & 10 deletions

File tree

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/const.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ export const ESP32P4_PMU_0P1A_TARGET0_0 = 0xff << 23;
419419
export const ESP32P4_PMU_0P1A_FORCE_TIEH_SEL_0 = 1 << 7;
420420
export const ESP32P4_PMU_DATE_REG = ESP32P4_DR_REG_PMU_BASE + 0x3fc;
421421

422-
export const ESP32S31_SPI_REG_BASE = 0x20500000;
422+
export const ESP32S31_SPI_REG_BASE = 0x20501000;
423423
export const ESP32S31_BASEFUSEADDR = 0x20715000;
424-
export const ESP32S31_EFUSE_BLOCK1_ADDR = ESP32S31_BASEFUSEADDR + 0x044;
425-
export const ESP32S31_MACFUSEADDR = 0x20715000 + 0x044;
424+
export const ESP32S31_EFUSE_BLOCK1_ADDR = ESP32S31_BASEFUSEADDR + 0x050;
425+
export const ESP32S31_MACFUSEADDR = ESP32S31_BASEFUSEADDR + 0x050;
426426
export const ESP32S31_SPI_USR_OFFS = 0x18;
427427
export const ESP32S31_SPI_USR1_OFFS = 0x1c;
428428
export const ESP32S31_SPI_USR2_OFFS = 0x20;
@@ -431,6 +431,15 @@ export const ESP32S31_SPI_MISO_DLEN_OFFS = 0x28;
431431
export const ESP32S31_SPI_W0_OFFS = 0x58;
432432
export const ESP32S31_UART_DATE_REG_ADDR = 0x2038a000 + 0x8c;
433433
export const ESP32S31_BOOTLOADER_FLASH_OFFSET = 0x2000;
434+
// ESP32-S31 RTC Watchdog Timer registers (LP_WDT)
435+
export const ESP32S31_DR_REG_LP_WDT_BASE = 0x20801000;
436+
export const ESP32S31_RTC_CNTL_WDTCONFIG0_REG =
437+
ESP32S31_DR_REG_LP_WDT_BASE + 0x0000; // LP_WDT_RWDT_CONFIG0_REG
438+
export const ESP32S31_RTC_CNTL_WDTCONFIG1_REG =
439+
ESP32S31_DR_REG_LP_WDT_BASE + 0x0004; // LP_WDT_RWDT_CONFIG1_REG
440+
export const ESP32S31_RTC_CNTL_WDTWPROTECT_REG =
441+
ESP32S31_DR_REG_LP_WDT_BASE + 0x0018; // LP_WDT_RWDT_WPROTECT_REG
442+
export const ESP32S31_RTC_CNTL_WDT_WKEY = 0x50d83aa1;
434443

435444
export interface SpiFlashAddresses {
436445
regBase: number;

src/esp_loader.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ import {
6969
ESP32H2_EFUSE_BLOCK1_ADDR,
7070
ESP32P4_EFUSE_BLOCK1_ADDR,
7171
ESP32S31_EFUSE_BLOCK1_ADDR,
72+
ESP32S31_RTC_CNTL_WDTWPROTECT_REG,
73+
ESP32S31_RTC_CNTL_WDTCONFIG0_REG,
74+
ESP32S31_RTC_CNTL_WDTCONFIG1_REG,
75+
ESP32S31_RTC_CNTL_WDT_WKEY,
7276
SlipReadError,
7377
ESP32S2_RTC_CNTL_WDTWPROTECT_REG,
7478
ESP32S2_RTC_CNTL_WDTCONFIG0_REG,
@@ -1640,6 +1644,12 @@ export class ESPLoader extends EventTarget {
16401644
WDTCONFIG0_REG = ESP32P4_RTC_CNTL_WDTCONFIG0_REG;
16411645
WDTCONFIG1_REG = ESP32P4_RTC_CNTL_WDTCONFIG1_REG;
16421646
WDT_WKEY = ESP32P4_RTC_CNTL_WDT_WKEY;
1647+
} else if (this.chipFamily === CHIP_FAMILY_ESP32S31) {
1648+
// S31 uses LP_WDT (Low Power Watchdog Timer)
1649+
WDTWPROTECT_REG = ESP32S31_RTC_CNTL_WDTWPROTECT_REG;
1650+
WDTCONFIG0_REG = ESP32S31_RTC_CNTL_WDTCONFIG0_REG;
1651+
WDTCONFIG1_REG = ESP32S31_RTC_CNTL_WDTCONFIG1_REG;
1652+
WDT_WKEY = ESP32S31_RTC_CNTL_WDT_WKEY;
16431653
} else {
16441654
throw new Error(
16451655
`rtcWdtResetChipSpecific() is not supported for ${this.chipFamily}`,
@@ -1700,12 +1710,13 @@ export class ESPLoader extends EventTarget {
17001710

17011711
// Check if chip supports WDT reset
17021712
// WDT reset is not needed for ESP32-C3
1703-
// WDT reset is supported by: ESP32-S2, ESP32-S3, ESP32-P4
1713+
// WDT reset is supported by: ESP32-S2, ESP32-S3, ESP32-P4, ESP32-S31
17041714
// WDT reset is NOT supported by: ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2
17051715
const supportsWdtReset =
17061716
this.chipFamily === CHIP_FAMILY_ESP32S2 ||
17071717
this.chipFamily === CHIP_FAMILY_ESP32S3 ||
1708-
this.chipFamily === CHIP_FAMILY_ESP32P4;
1718+
this.chipFamily === CHIP_FAMILY_ESP32P4 ||
1719+
this.chipFamily === CHIP_FAMILY_ESP32S31;
17091720

17101721
if (!supportsWdtReset) {
17111722
this.logger.debug(

src/stubs/esp32s31.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"entry": 788533248,
3+
"text": "ARG3pwAvN9cBLwbOIswmykrIk4cHABMHR9tj6ucE7wCQaRMH9f+FRyqEY+TnAO8QQEABRe8AMHqBRQFF7wBQcyKF7wCwaLdXQUmTh/eEkUUoAD7EhUTBKAlJJSxjHZUAaABhJLJF7wBQDX0s/bcjoAcAkQddt+MKJf/jEJT+7xCAN2Hd7xAAOMm/CcW31wEvI6qn2oKAt6cALyOgpwCCgLfXAS+Dp0fbEwUADIKHQREixDfUAS8TBETbBsaTBgAMHEBjCtUAkwawDWMN1QAiRLJAQQGChxMFsA2Cl",
4+
"text_start": 788533248,
5+
"data": "ECIAL0wiAS+OEwAvjhMAL44TAC+OEwAvjhMAL44TAC+OEwAvjhMAL44TAC+OEwAvjhMAL44TAC+OEwAvjhMAL44TAC+OEwAvjhMAL44TAC+OEwAvjhMAL44TAC+qGgAvthoALwIbAC8uGwAvuBsAL2IbAC+MGgAv+hsAL3YcAC+cHAAvQhoAL4ocAC9CGgAvAh0ALxIdAC8WHQAvAhsAL24dAC+CHQAv",
6+
"data_start": 788647348,
7+
"bss_start": 788570112
8+
}

src/stubs/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ export const getStubCode = async (
4242
// Chips without stub support yet
4343
if (
4444
chipFamily == CHIP_FAMILY_ESP32H4 ||
45-
chipFamily == CHIP_FAMILY_ESP32H21 ||
46-
chipFamily == CHIP_FAMILY_ESP32S31
45+
chipFamily == CHIP_FAMILY_ESP32H21
4746
) {
4847
return null;
4948
}
@@ -75,6 +74,8 @@ export const getStubCode = async (
7574
} else {
7675
stubcode = await import("./esp32p4.json");
7776
}
77+
} else if (chipFamily == CHIP_FAMILY_ESP32S31) {
78+
stubcode = await import("./esp32s31.json");
7879
} else {
7980
// Unknown chip family - no stub available
8081
return null;

0 commit comments

Comments
 (0)