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 ESP32S2ROM(ESP32ROM):
|
||||
@@ -31,6 +32,8 @@ class ESP32S2ROM(ESP32ROM):
|
||||
SPI_MISO_DLEN_OFFS = 0x28
|
||||
SPI_W0_OFFS = 0x58
|
||||
|
||||
SPI_ADDR_REG_MSB = False
|
||||
|
||||
MAC_EFUSE_REG = 0x3F41A044 # ESP32-S2 has special block for MAC efuses
|
||||
|
||||
UART_CLKDIV_REG = 0x3F400014
|
||||
@@ -81,6 +84,7 @@ class ESP32S2ROM(ESP32ROM):
|
||||
|
||||
GPIO_STRAP_REG = 0x3F404038
|
||||
GPIO_STRAP_SPI_BOOT_MASK = 0x8 # Not download mode
|
||||
GPIO_STRAP_VDDSPI_MASK = 1 << 4
|
||||
RTC_CNTL_OPTION1_REG = 0x3F408128
|
||||
RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK = 0x1 # Is download mode forced over USB?
|
||||
|
||||
@@ -99,8 +103,29 @@ class ESP32S2ROM(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 = 0xBFDD4EEE
|
||||
|
||||
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 = 4
|
||||
return (self.read_reg(self.EFUSE_BLOCK1_ADDR + (4 * num_word)) >> 0) & 0x0F
|
||||
@@ -183,6 +208,9 @@ class ESP32S2ROM(ESP32ROM):
|
||||
# ESP32-S2 XTAL is fixed to 40MHz
|
||||
return 40
|
||||
|
||||
def _get_rtc_cntl_flash_voltage(self):
|
||||
return None # not supported on ESP32-S2
|
||||
|
||||
def override_vddsdio(self, new_voltage):
|
||||
raise NotImplementedInROMError(
|
||||
"VDD_SDIO overrides are not supported for ESP32-S2"
|
||||
@@ -215,8 +243,10 @@ class ESP32S2ROM(ESP32ROM):
|
||||
)
|
||||
|
||||
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),
|
||||
@@ -230,7 +260,9 @@ class ESP32S2ROM(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
|
||||
@@ -266,15 +298,12 @@ class ESP32S2ROM(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()
|
||||
|
||||
Reference in New Issue
Block a user