mirror of
https://github.com/espressif/esptool.git
synced 2025-10-20 22:09:59 +08:00
refactor: Comply with black 23.1 style
This commit is contained in:
@@ -8,7 +8,6 @@ from ..mem_definition_base import EfuseBlocksBase, EfuseFieldsBase, EfuseRegiste
|
|||||||
|
|
||||||
|
|
||||||
class EfuseDefineRegisters(EfuseRegistersBase):
|
class EfuseDefineRegisters(EfuseRegistersBase):
|
||||||
|
|
||||||
EFUSE_MEM_SIZE = 0x011C + 4
|
EFUSE_MEM_SIZE = 0x011C + 4
|
||||||
|
|
||||||
# EFUSE registers & command/conf values
|
# EFUSE registers & command/conf values
|
||||||
|
@@ -19,7 +19,6 @@ class EfuseRegistersBase(object):
|
|||||||
|
|
||||||
|
|
||||||
class EfuseBlocksBase(object):
|
class EfuseBlocksBase(object):
|
||||||
|
|
||||||
BLOCKS = None
|
BLOCKS = None
|
||||||
NamedtupleBlock = namedtuple(
|
NamedtupleBlock = namedtuple(
|
||||||
"Block",
|
"Block",
|
||||||
@@ -45,7 +44,6 @@ class EfuseBlocksBase(object):
|
|||||||
|
|
||||||
|
|
||||||
class EfuseFieldsBase(object):
|
class EfuseFieldsBase(object):
|
||||||
|
|
||||||
NamedtupleField = namedtuple(
|
NamedtupleField = namedtuple(
|
||||||
"Efuse",
|
"Efuse",
|
||||||
"name category block word pos type write_disable_bit "
|
"name category block word pos type write_disable_bit "
|
||||||
|
@@ -738,7 +738,6 @@ def verify_signature_v1(args):
|
|||||||
|
|
||||||
|
|
||||||
def validate_signature_block(image_content, sig_blk_num):
|
def validate_signature_block(image_content, sig_blk_num):
|
||||||
|
|
||||||
offset = -SECTOR_SIZE + sig_blk_num * SIG_BLOCK_SIZE
|
offset = -SECTOR_SIZE + sig_blk_num * SIG_BLOCK_SIZE
|
||||||
sig_blk = image_content[offset : offset + SIG_BLOCK_SIZE]
|
sig_blk = image_content[offset : offset + SIG_BLOCK_SIZE]
|
||||||
assert len(sig_blk) == SIG_BLOCK_SIZE
|
assert len(sig_blk) == SIG_BLOCK_SIZE
|
||||||
|
@@ -889,7 +889,7 @@ def make_image(args):
|
|||||||
raise FatalError(
|
raise FatalError(
|
||||||
"Number of specified files does not match number of specified addresses"
|
"Number of specified files does not match number of specified addresses"
|
||||||
)
|
)
|
||||||
for (seg, addr) in zip(args.segfile, args.segaddr):
|
for seg, addr in zip(args.segfile, args.segaddr):
|
||||||
with open(seg, "rb") as f:
|
with open(seg, "rb") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
image.segments.append(ImageSegment(addr, data))
|
image.segments.append(ImageSegment(addr, data))
|
||||||
|
@@ -343,7 +343,6 @@ class ESPLoader(object):
|
|||||||
if self._trace_enabled:
|
if self._trace_enabled:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
try:
|
try:
|
||||||
|
|
||||||
delta = now - self._last_trace
|
delta = now - self._last_trace
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
delta = 0.0
|
delta = 0.0
|
||||||
@@ -738,7 +737,7 @@ class ESPLoader(object):
|
|||||||
stub = StubFlasher(get_stub_json_path(self.CHIP_NAME))
|
stub = StubFlasher(get_stub_json_path(self.CHIP_NAME))
|
||||||
load_start = offset
|
load_start = offset
|
||||||
load_end = offset + size
|
load_end = offset + size
|
||||||
for (start, end) in [
|
for start, end in [
|
||||||
(stub.data_start, stub.data_start + len(stub.data)),
|
(stub.data_start, stub.data_start + len(stub.data)),
|
||||||
(stub.text_start, stub.text_start + len(stub.text)),
|
(stub.text_start, stub.text_start + len(stub.text)),
|
||||||
]:
|
]:
|
||||||
|
@@ -950,7 +950,6 @@ class TestBurnKeyCommands(EfuseTestCase):
|
|||||||
reason="512 bit keys are only supported on ESP32-S2 and S3",
|
reason="512 bit keys are only supported on ESP32-S2 and S3",
|
||||||
)
|
)
|
||||||
def test_burn_key_512bit_non_consecutive_blocks(self):
|
def test_burn_key_512bit_non_consecutive_blocks(self):
|
||||||
|
|
||||||
# Burn efuses seperately to test different kinds
|
# Burn efuses seperately to test different kinds
|
||||||
# of "key used" detection criteria
|
# of "key used" detection criteria
|
||||||
self.espefuse_py(
|
self.espefuse_py(
|
||||||
|
@@ -105,7 +105,6 @@ class TestESP32SecureBootloader(EspSecureTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestSigning(EspSecureTestCase):
|
class TestSigning(EspSecureTestCase):
|
||||||
|
|
||||||
VerifyArgs = namedtuple(
|
VerifyArgs = namedtuple(
|
||||||
"verify_signature_args", ["version", "hsm", "hsm_config", "keyfile", "datafile"]
|
"verify_signature_args", ["version", "hsm", "hsm_config", "keyfile", "datafile"]
|
||||||
)
|
)
|
||||||
@@ -659,7 +658,6 @@ class TestSigning(EspSecureTestCase):
|
|||||||
assert "Signature could not be verified with the provided key." in str(cm.value)
|
assert "Signature could not be verified with the provided key." in str(cm.value)
|
||||||
|
|
||||||
def test_extract_binary_public_key(self):
|
def test_extract_binary_public_key(self):
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile() as pub_keyfile, tempfile.NamedTemporaryFile() as pub_keyfile2: # noqa E501
|
with tempfile.NamedTemporaryFile() as pub_keyfile, tempfile.NamedTemporaryFile() as pub_keyfile2: # noqa E501
|
||||||
args = self.ExtractKeyArgs(
|
args = self.ExtractKeyArgs(
|
||||||
"1", self._open("ecdsa_secure_boot_signing_key.pem"), pub_keyfile
|
"1", self._open("ecdsa_secure_boot_signing_key.pem"), pub_keyfile
|
||||||
@@ -710,7 +708,6 @@ class TestSigning(EspSecureTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestFlashEncryption(EspSecureTestCase):
|
class TestFlashEncryption(EspSecureTestCase):
|
||||||
|
|
||||||
EncryptArgs = namedtuple(
|
EncryptArgs = namedtuple(
|
||||||
"encrypt_flash_data_args",
|
"encrypt_flash_data_args",
|
||||||
[
|
[
|
||||||
@@ -744,7 +741,6 @@ class TestFlashEncryption(EspSecureTestCase):
|
|||||||
flash_crypt_conf=0xF,
|
flash_crypt_conf=0xF,
|
||||||
aes_xts=None,
|
aes_xts=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
original_plaintext = self._open(input_plaintext)
|
original_plaintext = self._open(input_plaintext)
|
||||||
keyfile = self._open(key_path)
|
keyfile = self._open(key_path)
|
||||||
ciphertext = io.BytesIO()
|
ciphertext = io.BytesIO()
|
||||||
|
@@ -123,7 +123,6 @@ class ESPRFC2217Server(object):
|
|||||||
@pytest.mark.flaky(reruns=1, condition=arg_preload_port is not False)
|
@pytest.mark.flaky(reruns=1, condition=arg_preload_port is not False)
|
||||||
class EsptoolTestCase:
|
class EsptoolTestCase:
|
||||||
def run_espsecure(self, args):
|
def run_espsecure(self, args):
|
||||||
|
|
||||||
cmd = [sys.executable, "-m", "espsecure"] + args.split(" ")
|
cmd = [sys.executable, "-m", "espsecure"] + args.split(" ")
|
||||||
print("\nExecuting {}...".format(" ".join(cmd)))
|
print("\nExecuting {}...".format(" ".join(cmd)))
|
||||||
try:
|
try:
|
||||||
|
@@ -45,7 +45,7 @@ class TestMergeBin:
|
|||||||
"-o",
|
"-o",
|
||||||
output_file.name,
|
output_file.name,
|
||||||
] + options
|
] + options
|
||||||
for (offset, name) in offsets_names:
|
for offset, name in offsets_names:
|
||||||
cmd += [hex(offset), name]
|
cmd += [hex(offset), name]
|
||||||
print("\nExecuting {}".format(" ".join(cmd)))
|
print("\nExecuting {}".format(" ".join(cmd)))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user