Skip to content

Commit 667814f

Browse files
authored
Merge pull request #704 from daid/patch-3
Fix the bug where flashing a target without opening a terminal causes mbed-cli to report a reset failure.
2 parents 8a3873f + 210add7 commit 667814f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

mbed/mbed.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,22 +1793,21 @@ def mbed_sterm(port, baudrate=9600, echo=True, reset=False, sterm=False):
17931793
except (IOError, ImportError, OSError):
17941794
error("The serial terminal functionality requires that the 'mbed-terminal' python module is installed.\nYou can install mbed-terminal by running 'pip install mbed-terminal'.", 1)
17951795

1796-
result = False
17971796
mbed_serial = MbedTerminal(port, baudrate=baudrate, echo=echo)
17981797
if mbed_serial.serial:
17991798
if reset:
1800-
mbed_serial.reset()
1801-
1799+
if not mbed_serial.reset():
1800+
error("Unable to reset the target board connected to your system.\nThis might be caused by an old interface firmware.\nPlease check the board page for new firmware.", 1)
18021801
if sterm:
18031802
# Some boards will reset the COM port after SendBreak, e.g. STLink based
18041803
if not mbed_serial.serial.is_open:
18051804
mbed_serial = MbedTerminal(port, baudrate=baudrate, echo=echo)
18061805

18071806
try:
1808-
result = mbed_serial.terminal()
1807+
if not mbed_serial.terminal():
1808+
error("Unable to open serial terminal.\nMost likely your pyserial is dated and needs to be updated with 'pip install --upgrade pyserial")
18091809
except:
18101810
pass
1811-
return result
18121811

18131812

18141813
# Subparser handling
@@ -2549,8 +2548,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
25492548
error("Unable to flash the target board connected to your system.", 1)
25502549

25512550
if flash or sterm:
2552-
if not mbed_sterm(detected['port'], reset=flash, sterm=sterm):
2553-
error("Unable to reset the target board connected to your system.\nThis might be caused by an old interface firmware.\nPlease check the board page for new firmware.", 1)
2551+
mbed_sterm(detected['port'], reset=flash, sterm=sterm)
25542552

25552553
program.set_defaults(target=target, toolchain=tchain)
25562554

0 commit comments

Comments
 (0)