Skip to content

Commit 2a54f45

Browse files
committed
Fixed handling errors regarding target detection and flashing
1 parent 9c3798f commit 2a54f45

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mbed/mbed.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,19 +2231,19 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
22312231
+ (['-v'] if verbose else [])
22322232
+ args,
22332233
env=env)
2234-
2234+
22352235
if flash:
22362236
fw_name = artifact_name if artifact_name else program.name
22372237
fw_fbase = os.path.join(build_path, fw_name)
22382238
fw_file = fw_fbase + ('.hex' if os.path.exists(fw_fbase+'.hex') else '.bin')
2239-
if not fw_file:
2240-
error("Firmware file not found \"%s\"" % fw_file, 1)
2239+
if not os.path.exists(fw_file):
2240+
error("Build program file (firmware) not found \"%s\"" % fw_file, 1)
22412241
detected = program.detect_target()
22422242

22432243
try:
22442244
from mbed_host_tests.host_tests_toolbox import flash_dev, reset_dev
22452245
except (IOError, ImportError, OSError):
2246-
error("The '-f' option requires that the 'mbed-greentea' python module is installed.\nYou can install mbed-ls by running 'pip install mbed-greentea'.", 1)
2246+
error("The '-f/--flash' option requires that the 'mbed-greentea' python module is installed.\nYou can install mbed-ls by running 'pip install mbed-greentea'.", 1)
22472247

22482248
if not flash_dev(detected['msd'], fw_file, program_cycle_s=2):
22492249
error("Unable to flash the target board connected to your system.", 1)

0 commit comments

Comments
 (0)