Skip to content

Commit

Permalink
twister: fix the hanging up on an exception happens during west flash
Browse files Browse the repository at this point in the history
Fix the missing logic of setting the flash_error flag when
caught the exceptions. And we should let the serial thread
can be run first if flash error. Otherwise the twister will
hang up while an exception happens on closing serial, after
the zephyrproject-rtos#47820 got merged. This mostly happens on frdm_k64f.

Fixes zephyrproject-rtos#49086

Signed-off-by: Enjia Mai <[email protected]>
  • Loading branch information
enjiamai authored and MaureenHelm committed Aug 17, 2022
1 parent ce085bc commit a2160ef
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scripts/pylib/twister/twisterlib/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,14 +571,25 @@ def handle(self):

except subprocess.CalledProcessError:
os.write(write_pipe, b'x') # halt the thread
self.instance.status = "error"
self.instance.reason = "Device issue (Flash error)"
flash_error = True

if post_flash_script:
self.run_custom_script(post_flash_script, 30)

if not flash_error:
t.join(self.timeout)
if t.is_alive():
logger.debug("Timed out while monitoring serial output on {}".format(self.instance.platform.name))
else:
# When the flash error is due exceptions,
# twister tell the monitor serial thread
# to close the serial. But it is necessary
# for this thread being run first and close
# have the change to close the serial.
t.join(0.1)

if t.is_alive():
logger.debug("Timed out while monitoring serial output on {}".format(self.instance.platform.name))

if ser.isOpen():
ser.close()
Expand Down

0 comments on commit a2160ef

Please sign in to comment.