Merge branch 'test/fix_failed_to_download_in_example_test' into 'master'
test: fix failed to download in example test See merge request idf/esp-idf!4061
This commit is contained in:
commit
3c94b6e10a
|
@ -29,9 +29,9 @@ def test_examples_parttool(env, extra_data):
|
||||||
script_path = os.path.join(os.getenv("IDF_PATH"), "examples", "storage", "parttool", "parttool_example.py")
|
script_path = os.path.join(os.getenv("IDF_PATH"), "examples", "storage", "parttool", "parttool_example.py")
|
||||||
|
|
||||||
binary_path = ""
|
binary_path = ""
|
||||||
for config in dut.download_config:
|
for flash_file in dut.app.flash_files:
|
||||||
if "parttool.bin" in config:
|
if "parttool.bin" in flash_file[1]:
|
||||||
binary_path = config
|
binary_path = flash_file[1]
|
||||||
break
|
break
|
||||||
|
|
||||||
subprocess.check_call([sys.executable, script_path, "--binary", binary_path])
|
subprocess.check_call([sys.executable, script_path, "--binary", binary_path])
|
||||||
|
|
|
@ -32,9 +32,9 @@ def test_otatool_example(env, extra_data):
|
||||||
script_path = os.path.join(os.getenv("IDF_PATH"), "examples", "system", "ota", "otatool", "otatool_example.py")
|
script_path = os.path.join(os.getenv("IDF_PATH"), "examples", "system", "ota", "otatool", "otatool_example.py")
|
||||||
binary_path = ""
|
binary_path = ""
|
||||||
|
|
||||||
for config in dut.download_config:
|
for flash_file in dut.app.flash_files:
|
||||||
if "otatool.bin" in config:
|
if "otatool.bin" in flash_file[1]:
|
||||||
binary_path = config
|
binary_path = flash_file[1]
|
||||||
break
|
break
|
||||||
|
|
||||||
subprocess.check_call([sys.executable, script_path, "--binary", binary_path])
|
subprocess.check_call([sys.executable, script_path, "--binary", binary_path])
|
||||||
|
|
|
@ -22,8 +22,6 @@ import tempfile
|
||||||
|
|
||||||
from serial.tools import list_ports
|
from serial.tools import list_ports
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
import DUT
|
import DUT
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -51,14 +49,20 @@ def _uses_esptool(func):
|
||||||
|
|
||||||
settings = self.port_inst.get_settings()
|
settings = self.port_inst.get_settings()
|
||||||
|
|
||||||
rom = esptool.ESP32ROM(self.port_inst)
|
try:
|
||||||
rom.connect('hard_reset')
|
rom = esptool.ESP32ROM(self.port_inst)
|
||||||
esp = rom.run_stub()
|
rom.connect('hard_reset')
|
||||||
|
esp = rom.run_stub()
|
||||||
|
|
||||||
ret = func(self, esp, *args, **kwargs)
|
ret = func(self, esp, *args, **kwargs)
|
||||||
|
# do hard reset after use esptool
|
||||||
|
esp.hard_reset()
|
||||||
|
finally:
|
||||||
|
# always need to restore port settings
|
||||||
|
self.port_inst.apply_settings(settings)
|
||||||
|
|
||||||
self.port_inst.apply_settings(settings)
|
|
||||||
self.start_receive()
|
self.start_receive()
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
return handler
|
return handler
|
||||||
|
|
||||||
|
@ -94,6 +98,8 @@ class IDFDUT(DUT.SerialDUT):
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
return None
|
return None
|
||||||
finally:
|
finally:
|
||||||
|
# do hard reset after use esptool
|
||||||
|
esp.hard_reset()
|
||||||
esp._port.close()
|
esp._port.close()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -121,31 +127,27 @@ class IDFDUT(DUT.SerialDUT):
|
||||||
|
|
||||||
# fake flasher args object, this is a hack until
|
# fake flasher args object, this is a hack until
|
||||||
# esptool Python API is improved
|
# esptool Python API is improved
|
||||||
Flash_Args = namedtuple('write_flash_args',
|
class FlashArgs(object):
|
||||||
['flash_size',
|
def __init__(self, attributes):
|
||||||
'flash_mode',
|
for key, value in attributes.items():
|
||||||
'flash_freq',
|
self.__setattr__(key, value)
|
||||||
'addr_filename',
|
|
||||||
'no_stub',
|
|
||||||
'compress',
|
|
||||||
'verify',
|
|
||||||
'encrypt'])
|
|
||||||
|
|
||||||
flash_args = Flash_Args(
|
flash_args = FlashArgs({
|
||||||
self.app.flash_settings["flash_size"],
|
'flash_size': self.app.flash_settings["flash_size"],
|
||||||
self.app.flash_settings["flash_mode"],
|
'flash_mode': self.app.flash_settings["flash_mode"],
|
||||||
self.app.flash_settings["flash_freq"],
|
'flash_freq': self.app.flash_settings["flash_freq"],
|
||||||
flash_files,
|
'addr_filename': flash_files,
|
||||||
False,
|
'no_stub': False,
|
||||||
True,
|
'compress': True,
|
||||||
False,
|
'verify': False,
|
||||||
False
|
'encrypt': False,
|
||||||
)
|
})
|
||||||
|
|
||||||
esp.change_baud(baud_rate)
|
esp.change_baud(baud_rate)
|
||||||
|
esptool.detect_flash_size(esp, flash_args)
|
||||||
esptool.write_flash(esp, flash_args)
|
esptool.write_flash(esp, flash_args)
|
||||||
finally:
|
finally:
|
||||||
for (_,f) in flash_files:
|
for (_, f) in flash_files:
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def start_app(self, erase_nvs=ERASE_NVS):
|
def start_app(self, erase_nvs=ERASE_NVS):
|
||||||
|
@ -171,7 +173,9 @@ class IDFDUT(DUT.SerialDUT):
|
||||||
|
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
esp.hard_reset()
|
# decorator `_use_esptool` will do reset
|
||||||
|
# so we don't need to do anything in this method
|
||||||
|
pass
|
||||||
|
|
||||||
@_uses_esptool
|
@_uses_esptool
|
||||||
def erase_partition(self, esp, partition):
|
def erase_partition(self, esp, partition):
|
||||||
|
|
Loading…
Reference in a new issue