Merge branch 'feature/esptool_v4' into 'master'

tools: Use esptool v4

See merge request espressif/esp-idf!18098
pull/9068/head
Roland Dobai 2022-05-26 23:35:17 +08:00
commit a5ebf0c3e7
3 zmienionych plików z 36 dodań i 29 usunięć

Wyświetl plik

@ -3,19 +3,8 @@
# Demonstrates the use of otatool.py, a tool for performing ota partition level
# operations.
#
# Copyright 2018 Espressif Systems (Shanghai) PTE LTD
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
import re
@ -32,11 +21,17 @@ def get_running_partition(port=None):
IDF_PATH = os.path.expandvars('$IDF_PATH')
sys.path.append(os.path.join(IDF_PATH, 'components', 'esptool_py', 'esptool'))
import esptool
try:
# esptool>=4.0
from esptool.loader import ESPLoader
except (AttributeError, ModuleNotFoundError):
# esptool<4.0
from esptool import ESPLoader
ESPTOOL_PY = os.path.join(IDF_PATH, 'components', 'esptool_py', 'esptool', 'esptool.py')
baud = os.environ.get('ESPTOOL_BAUD', esptool.ESPLoader.ESP_ROM_BAUD)
baud = os.environ.get('ESPTOOL_BAUD', ESPLoader.ESP_ROM_BAUD)
if not port:
error_message = 'Unable to obtain default target device port.\nSerial log:\n\n'

Wyświetl plik

@ -2243,7 +2243,6 @@ examples/system/ota/advanced_https_ota/main/ble_helper/include/ble_api.h
examples/system/ota/native_ota_example/example_test.py
examples/system/ota/native_ota_example/main/native_ota_example.c
examples/system/ota/otatool/example_test.py
examples/system/ota/otatool/get_running_partition.py
examples/system/ota/otatool/main/otatool_main.c
examples/system/ota/otatool/otatool_example.py
examples/system/ota/simple_ota_example/example_test.py

Wyświetl plik

@ -34,6 +34,17 @@ except ImportError: # cheat and use IDF's copy of esptool if available
sys.path.insert(0, os.path.join(idf_path, 'components', 'esptool_py', 'esptool'))
import esptool
try:
# esptool>=4.0
detect_chip = esptool.cmds.detect_chip
FatalError = esptool.util.FatalError
targets = esptool.targets
except (AttributeError, ModuleNotFoundError):
# esptool<4.0
detect_chip = esptool.ESPLoader.detect_chip
FatalError = esptool.FatalError
targets = esptool
import espefuse
import espsecure
@ -118,7 +129,7 @@ def _uses_esptool(func):
try:
if not self.rom_inst:
if not self.secure_boot_en:
self.rom_inst = esptool.ESPLoader.detect_chip(self.port_inst)
self.rom_inst = detect_chip(self.port_inst)
else:
self.rom_inst = self.get_rom()(self.port_inst)
self.rom_inst.connect('hard_reset')
@ -201,11 +212,11 @@ class IDFDUT(DUT.SerialDUT):
try:
# TODO: check whether 8266 works with this logic
# Otherwise overwrite it in ESP8266DUT
inst = esptool.ESPLoader.detect_chip(port)
inst = detect_chip(port)
if expected_rom_class and type(inst) != expected_rom_class:
raise RuntimeError('Target not expected')
return inst.read_mac() is not None, get_target_by_rom_class(type(inst))
except(esptool.FatalError, RuntimeError):
except(FatalError, RuntimeError):
return False, None
finally:
if inst is not None:
@ -302,6 +313,8 @@ class IDFDUT(DUT.SerialDUT):
'ignore_flash_encryption_efuse_setting': ignore_flash_encryption_efuse_setting,
'erase_all': False,
'after': 'no_reset',
'force': False,
'chip': esp.CHIP_NAME.lower().replace('-', ''),
})
esp.change_baud(baud_rate)
@ -567,7 +580,7 @@ class ESP32DUT(IDFDUT):
@classmethod
def get_rom(cls):
return esptool.ESP32ROM
return targets.ESP32ROM
class ESP32S2DUT(IDFDUT):
@ -576,7 +589,7 @@ class ESP32S2DUT(IDFDUT):
@classmethod
def get_rom(cls):
return esptool.ESP32S2ROM
return targets.ESP32S2ROM
class ESP32S3DUT(IDFDUT):
@ -585,7 +598,7 @@ class ESP32S3DUT(IDFDUT):
@classmethod
def get_rom(cls):
return esptool.ESP32S3ROM
return targets.ESP32S3ROM
def erase_partition(self, esp, partition):
raise NotImplementedError()
@ -597,7 +610,7 @@ class ESP32C3DUT(IDFDUT):
@classmethod
def get_rom(cls):
return esptool.ESP32C3ROM
return targets.ESP32C3ROM
class ESP32C6DUT(IDFDUT):
@ -606,7 +619,7 @@ class ESP32C6DUT(IDFDUT):
@classmethod
def get_rom(cls):
return esptool.ESP32C6BETAROM
return targets.ESP32C6BETAROM
class ESP32H2DUT(IDFDUT):
@ -615,7 +628,7 @@ class ESP32H2DUT(IDFDUT):
@classmethod
def get_rom(cls):
return esptool.ESP32H2ROM
return targets.ESP32H2ROM
class ESP8266DUT(IDFDUT):
@ -624,7 +637,7 @@ class ESP8266DUT(IDFDUT):
@classmethod
def get_rom(cls):
return esptool.ESP8266ROM
return targets.ESP8266ROM
def get_target_by_rom_class(cls):
@ -677,7 +690,7 @@ class IDFQEMUDUT(IDFDUT):
@classmethod
def get_rom(cls):
return esptool.ESP32ROM
return targets.ESP32ROM
@classmethod
def get_mac(cls, app, port):
@ -833,7 +846,7 @@ class ESP32C3FPGADUT(IDFFPGADUT):
@classmethod
def get_rom(cls):
return esptool.ESP32C3ROM
return targets.ESP32C3ROM
def erase_partition(self, esp, partition):
raise NotImplementedError()
@ -870,7 +883,7 @@ class ESP32S3FPGADUT(IDFFPGADUT):
@classmethod
def get_rom(cls):
return esptool.ESP32S3ROM
return targets.ESP32S3ROM
def erase_partition(self, esp, partition):
raise NotImplementedError()