feat(core): 更新py-esptool (version: 4.8.1)
This commit is contained in:
@@ -5,11 +5,12 @@
|
||||
|
||||
import os
|
||||
import struct
|
||||
from typing import Dict
|
||||
|
||||
from .esp32 import ESP32ROM
|
||||
from loader import ESPLoader
|
||||
from reset import HardReset
|
||||
from util import FatalError, NotImplementedInROMError
|
||||
from ..loader import ESPLoader
|
||||
from ..reset import HardReset
|
||||
from ..util import FatalError, NotImplementedInROMError
|
||||
|
||||
|
||||
class ESP32S3ROM(ESP32ROM):
|
||||
@@ -34,6 +35,8 @@ class ESP32S3ROM(ESP32ROM):
|
||||
SPI_MISO_DLEN_OFFS = 0x28
|
||||
SPI_W0_OFFS = 0x58
|
||||
|
||||
SPI_ADDR_REG_MSB = False
|
||||
|
||||
BOOTLOADER_FLASH_OFFSET = 0x0
|
||||
|
||||
SUPPORTS_ENCRYPTED_FLASH = True
|
||||
@@ -95,6 +98,7 @@ class ESP32S3ROM(ESP32ROM):
|
||||
|
||||
GPIO_STRAP_REG = 0x60004038
|
||||
GPIO_STRAP_SPI_BOOT_MASK = 0x8 # Not download mode
|
||||
GPIO_STRAP_VDDSPI_MASK = 1 << 4
|
||||
RTC_CNTL_OPTION1_REG = 0x6000812C
|
||||
RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK = 0x1 # Is download mode forced over USB?
|
||||
|
||||
@@ -115,8 +119,29 @@ class ESP32S3ROM(ESP32ROM):
|
||||
[0x50000000, 0x50002000, "RTC_DATA"],
|
||||
]
|
||||
|
||||
EFUSE_VDD_SPI_REG = EFUSE_BASE + 0x34
|
||||
VDD_SPI_XPD = 1 << 4
|
||||
VDD_SPI_TIEH = 1 << 5
|
||||
VDD_SPI_FORCE = 1 << 6
|
||||
|
||||
UF2_FAMILY_ID = 0xC47E5767
|
||||
|
||||
EFUSE_MAX_KEY = 5
|
||||
KEY_PURPOSES: Dict[int, str] = {
|
||||
0: "USER/EMPTY",
|
||||
1: "RESERVED",
|
||||
2: "XTS_AES_256_KEY_1",
|
||||
3: "XTS_AES_256_KEY_2",
|
||||
4: "XTS_AES_128_KEY",
|
||||
5: "HMAC_DOWN_ALL",
|
||||
6: "HMAC_DOWN_JTAG",
|
||||
7: "HMAC_DOWN_DIGITAL_SIGNATURE",
|
||||
8: "HMAC_UP",
|
||||
9: "SECURE_BOOT_DIGEST0",
|
||||
10: "SECURE_BOOT_DIGEST1",
|
||||
11: "SECURE_BOOT_DIGEST2",
|
||||
}
|
||||
|
||||
def get_pkg_version(self):
|
||||
num_word = 3
|
||||
return (self.read_reg(self.EFUSE_BLOCK1_ADDR + (4 * num_word)) >> 21) & 0x07
|
||||
@@ -221,8 +246,10 @@ class ESP32S3ROM(ESP32ROM):
|
||||
return None # doesn't exist on ESP32-S3
|
||||
|
||||
def get_key_block_purpose(self, key_block):
|
||||
if key_block < 0 or key_block > 5:
|
||||
raise FatalError("Valid key block numbers must be in range 0-5")
|
||||
if key_block < 0 or key_block > self.EFUSE_MAX_KEY:
|
||||
raise FatalError(
|
||||
f"Valid key block numbers must be in range 0-{self.EFUSE_MAX_KEY}"
|
||||
)
|
||||
|
||||
reg, shift = [
|
||||
(self.EFUSE_PURPOSE_KEY0_REG, self.EFUSE_PURPOSE_KEY0_SHIFT),
|
||||
@@ -236,7 +263,9 @@ class ESP32S3ROM(ESP32ROM):
|
||||
|
||||
def is_flash_encryption_key_valid(self):
|
||||
# Need to see either an AES-128 key or two AES-256 keys
|
||||
purposes = [self.get_key_block_purpose(b) for b in range(6)]
|
||||
purposes = [
|
||||
self.get_key_block_purpose(b) for b in range(self.EFUSE_MAX_KEY + 1)
|
||||
]
|
||||
|
||||
if any(p == self.PURPOSE_VAL_XTS_AES128_KEY for p in purposes):
|
||||
return True
|
||||
@@ -251,6 +280,9 @@ class ESP32S3ROM(ESP32ROM):
|
||||
& self.EFUSE_SECURE_BOOT_EN_MASK
|
||||
)
|
||||
|
||||
def _get_rtc_cntl_flash_voltage(self):
|
||||
return None # not supported on ESP32-S3
|
||||
|
||||
def override_vddsdio(self, new_voltage):
|
||||
raise NotImplementedInROMError(
|
||||
"VDD_SDIO overrides are not supported for ESP32-S3"
|
||||
@@ -328,21 +360,28 @@ class ESP32S3ROM(ESP32ROM):
|
||||
strap_reg & self.GPIO_STRAP_SPI_BOOT_MASK == 0
|
||||
and force_dl_reg & self.RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK == 0
|
||||
):
|
||||
print(
|
||||
"WARNING: {} chip was placed into download mode using GPIO0.\n"
|
||||
"esptool.py can not exit the download mode over USB. "
|
||||
"To run the app, reset the chip manually.\n"
|
||||
"To suppress this note, set --after option to 'no_reset'.".format(
|
||||
self.get_chip_description()
|
||||
)
|
||||
raise SystemExit(
|
||||
f"Error: {self.get_chip_description()} chip was placed into download "
|
||||
"mode using GPIO0.\nesptool.py can not exit the download mode over "
|
||||
"USB. To run the app, reset the chip manually.\n"
|
||||
"To suppress this note, set --after option to 'no_reset'."
|
||||
)
|
||||
raise SystemExit(1)
|
||||
|
||||
def hard_reset(self):
|
||||
uses_usb_otg = self.uses_usb_otg()
|
||||
if uses_usb_otg:
|
||||
self._check_if_can_reset()
|
||||
|
||||
try:
|
||||
# Clear force download boot mode to avoid the chip being stuck in download mode after reset
|
||||
# workaround for issue: https://github.com/espressif/arduino-esp32/issues/6762
|
||||
self.write_reg(
|
||||
self.RTC_CNTL_OPTION1_REG, 0, self.RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK
|
||||
)
|
||||
except Exception:
|
||||
# Skip if response was not valid and proceed to reset; e.g. when monitoring while resetting
|
||||
pass
|
||||
|
||||
print("Hard resetting via RTS pin...")
|
||||
HardReset(self._port, uses_usb_otg)()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user