mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
tools: Use esptool v4
This commit is contained in:
parent
73be74fd71
commit
3e08f355b6
@ -3,19 +3,8 @@
|
|||||||
# Demonstrates the use of otatool.py, a tool for performing ota partition level
|
# Demonstrates the use of otatool.py, a tool for performing ota partition level
|
||||||
# operations.
|
# operations.
|
||||||
#
|
#
|
||||||
# Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
#
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# 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.
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -32,11 +21,17 @@ def get_running_partition(port=None):
|
|||||||
|
|
||||||
IDF_PATH = os.path.expandvars('$IDF_PATH')
|
IDF_PATH = os.path.expandvars('$IDF_PATH')
|
||||||
sys.path.append(os.path.join(IDF_PATH, 'components', 'esptool_py', 'esptool'))
|
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')
|
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:
|
if not port:
|
||||||
error_message = 'Unable to obtain default target device port.\nSerial log:\n\n'
|
error_message = 'Unable to obtain default target device port.\nSerial log:\n\n'
|
||||||
|
@ -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/example_test.py
|
||||||
examples/system/ota/native_ota_example/main/native_ota_example.c
|
examples/system/ota/native_ota_example/main/native_ota_example.c
|
||||||
examples/system/ota/otatool/example_test.py
|
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/main/otatool_main.c
|
||||||
examples/system/ota/otatool/otatool_example.py
|
examples/system/ota/otatool/otatool_example.py
|
||||||
examples/system/ota/simple_ota_example/example_test.py
|
examples/system/ota/simple_ota_example/example_test.py
|
||||||
|
@ -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'))
|
sys.path.insert(0, os.path.join(idf_path, 'components', 'esptool_py', 'esptool'))
|
||||||
import 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 espefuse
|
||||||
import espsecure
|
import espsecure
|
||||||
|
|
||||||
@ -118,7 +129,7 @@ def _uses_esptool(func):
|
|||||||
try:
|
try:
|
||||||
if not self.rom_inst:
|
if not self.rom_inst:
|
||||||
if not self.secure_boot_en:
|
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:
|
else:
|
||||||
self.rom_inst = self.get_rom()(self.port_inst)
|
self.rom_inst = self.get_rom()(self.port_inst)
|
||||||
self.rom_inst.connect('hard_reset')
|
self.rom_inst.connect('hard_reset')
|
||||||
@ -201,11 +212,11 @@ class IDFDUT(DUT.SerialDUT):
|
|||||||
try:
|
try:
|
||||||
# TODO: check whether 8266 works with this logic
|
# TODO: check whether 8266 works with this logic
|
||||||
# Otherwise overwrite it in ESP8266DUT
|
# 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:
|
if expected_rom_class and type(inst) != expected_rom_class:
|
||||||
raise RuntimeError('Target not expected')
|
raise RuntimeError('Target not expected')
|
||||||
return inst.read_mac() is not None, get_target_by_rom_class(type(inst))
|
return inst.read_mac() is not None, get_target_by_rom_class(type(inst))
|
||||||
except(esptool.FatalError, RuntimeError):
|
except(FatalError, RuntimeError):
|
||||||
return False, None
|
return False, None
|
||||||
finally:
|
finally:
|
||||||
if inst is not None:
|
if inst is not None:
|
||||||
@ -302,6 +313,8 @@ class IDFDUT(DUT.SerialDUT):
|
|||||||
'ignore_flash_encryption_efuse_setting': ignore_flash_encryption_efuse_setting,
|
'ignore_flash_encryption_efuse_setting': ignore_flash_encryption_efuse_setting,
|
||||||
'erase_all': False,
|
'erase_all': False,
|
||||||
'after': 'no_reset',
|
'after': 'no_reset',
|
||||||
|
'force': False,
|
||||||
|
'chip': esp.CHIP_NAME.lower().replace('-', ''),
|
||||||
})
|
})
|
||||||
|
|
||||||
esp.change_baud(baud_rate)
|
esp.change_baud(baud_rate)
|
||||||
@ -567,7 +580,7 @@ class ESP32DUT(IDFDUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32ROM
|
return targets.ESP32ROM
|
||||||
|
|
||||||
|
|
||||||
class ESP32S2DUT(IDFDUT):
|
class ESP32S2DUT(IDFDUT):
|
||||||
@ -576,7 +589,7 @@ class ESP32S2DUT(IDFDUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32S2ROM
|
return targets.ESP32S2ROM
|
||||||
|
|
||||||
|
|
||||||
class ESP32S3DUT(IDFDUT):
|
class ESP32S3DUT(IDFDUT):
|
||||||
@ -585,7 +598,7 @@ class ESP32S3DUT(IDFDUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32S3ROM
|
return targets.ESP32S3ROM
|
||||||
|
|
||||||
def erase_partition(self, esp, partition):
|
def erase_partition(self, esp, partition):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
@ -597,7 +610,7 @@ class ESP32C3DUT(IDFDUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32C3ROM
|
return targets.ESP32C3ROM
|
||||||
|
|
||||||
|
|
||||||
class ESP32C6DUT(IDFDUT):
|
class ESP32C6DUT(IDFDUT):
|
||||||
@ -606,7 +619,7 @@ class ESP32C6DUT(IDFDUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32C6BETAROM
|
return targets.ESP32C6BETAROM
|
||||||
|
|
||||||
|
|
||||||
class ESP32H2DUT(IDFDUT):
|
class ESP32H2DUT(IDFDUT):
|
||||||
@ -615,7 +628,7 @@ class ESP32H2DUT(IDFDUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32H2ROM
|
return targets.ESP32H2ROM
|
||||||
|
|
||||||
|
|
||||||
class ESP8266DUT(IDFDUT):
|
class ESP8266DUT(IDFDUT):
|
||||||
@ -624,7 +637,7 @@ class ESP8266DUT(IDFDUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP8266ROM
|
return targets.ESP8266ROM
|
||||||
|
|
||||||
|
|
||||||
def get_target_by_rom_class(cls):
|
def get_target_by_rom_class(cls):
|
||||||
@ -677,7 +690,7 @@ class IDFQEMUDUT(IDFDUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32ROM
|
return targets.ESP32ROM
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_mac(cls, app, port):
|
def get_mac(cls, app, port):
|
||||||
@ -833,7 +846,7 @@ class ESP32C3FPGADUT(IDFFPGADUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32C3ROM
|
return targets.ESP32C3ROM
|
||||||
|
|
||||||
def erase_partition(self, esp, partition):
|
def erase_partition(self, esp, partition):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
@ -870,7 +883,7 @@ class ESP32S3FPGADUT(IDFFPGADUT):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rom(cls):
|
def get_rom(cls):
|
||||||
return esptool.ESP32S3ROM
|
return targets.ESP32S3ROM
|
||||||
|
|
||||||
def erase_partition(self, esp, partition):
|
def erase_partition(self, esp, partition):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user