Skip to content

Commit 86c1503

Browse files
authored
Merge pull request #72 from espressif/fix/esptool_wrong_boot_mode
fix(esp): esptool wrong boot mode issue
2 parents 5ec4729 + ccb19d3 commit 86c1503

File tree

1 file changed

+5
-12
lines changed
  • pytest-embedded-serial-esp/pytest_embedded_serial_esp

1 file changed

+5
-12
lines changed

pytest-embedded-serial-esp/pytest_embedded_serial_esp/serial.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class EspSerial(Serial):
1313
1414
Attributes:
1515
esp: esptool.ESPLoader, will auto upload stub.
16+
stub: esptool.ESPStubLoader, stubbed loader.
1617
"""
1718

1819
DEFAULT_BAUDRATE = 115200
@@ -58,7 +59,7 @@ def __init__(
5859
raise ValueError('Couldn\'t auto detect chip. Please manually specify with "--port"')
5960

6061
# stub loader has more functionalities, need to run after calling `run_stub()`
61-
self.stub: esptool.ESPLoader = None # type: ignore
62+
self.stub: esptool.ESPLoader = self.esp.run_stub()
6263

6364
if baud > initial_baud:
6465
self.esp.change_baud(baud) # change back to the users settings
@@ -78,29 +79,21 @@ def _post_init(self):
7879

7980
def use_esptool(func):
8081
"""
81-
1. close the port and open the port to kill the `self._forward_io` thread
82-
2. call `run_stub()`
83-
3. call to the decorated function, could use `self.stub` as the stubbed loader
84-
4. call `hard_reset()`
85-
5. create the `self.forward_io` thread again.
82+
1. call to the decorated function, could use `self.stub` as the stubbed loader
83+
2. call `hard_reset()`
84+
3. create the `self.forward_io` thread again.
8685
"""
8786

8887
@functools.wraps(func)
8988
def wrapper(self, *args, **kwargs):
90-
self.proc.close()
91-
self.proc.open()
92-
9389
settings = self.proc.get_settings()
9490

9591
try:
9692
with DuplicateStdout(self.pexpect_proc):
97-
self.esp.connect('hard_reset')
98-
self.stub = self.esp.run_stub()
9993
ret = func(self, *args, **kwargs)
10094
self.stub.hard_reset()
10195
finally:
10296
self.proc.apply_settings(settings)
103-
self.create_forward_io_thread(self.pexpect_proc)
10497

10598
return ret
10699

0 commit comments

Comments
 (0)