@@ -1443,11 +1443,11 @@ def ignore_build_dir(self):
1443
1443
def detect_target (self , info = None ):
1444
1444
targets = self .get_detected_targets ()
1445
1445
if targets == False :
1446
- error ("The target detection requires that the 'mbed-ls' python module is installed.\n You can install mbed-ls by running 'pip install mbed-ls'." )
1446
+ error ("The target detection requires that the 'mbed-ls' python module is installed.\n You can install mbed-ls by running 'pip install mbed-ls'." , 1 )
1447
1447
elif len (targets ) > 1 :
1448
- error ("Multiple targets were detected.\n Only 1 target board should be connected to your system." )
1448
+ error ("Multiple targets were detected.\n Only 1 target board should be connected to your system." , 1 )
1449
1449
elif len (targets ) == 0 :
1450
- error ("No targets were detected.\n Please make sure a target board is connected to this system." )
1450
+ error ("No targets were detected.\n Please make sure a target board is connected to this system." , 1 )
1451
1451
else :
1452
1452
action ("Detected \" %s\" connected to \" %s\" and using com port \" %s\" " % (targets [0 ]['name' ], targets [0 ]['mount' ], targets [0 ]['serial' ]))
1453
1453
info = {'msd' : targets [0 ]['mount' ], 'port' : targets [0 ]['serial' ], 'name' : targets [0 ]['name' ]}
@@ -2231,23 +2231,25 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
2231
2231
+ (['-v' ] if verbose else [])
2232
2232
+ args ,
2233
2233
env = env )
2234
-
2234
+
2235
2235
if flash :
2236
2236
fw_name = artifact_name if artifact_name else program .name
2237
2237
fw_fbase = os .path .join (build_path , fw_name )
2238
2238
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 )
2239
+ if not os . path . exists ( fw_file ) :
2240
+ error ("Build program file (firmware) not found \" %s\" " % fw_file , 1 )
2241
2241
detected = program .detect_target ()
2242
2242
2243
2243
try :
2244
2244
from mbed_host_tests .host_tests_toolbox import flash_dev , reset_dev
2245
2245
except (IOError , ImportError , OSError ):
2246
- error ("The '-f' option requires that the 'mbed-greentea' python module is installed.\n You can install mbed-ls by running 'pip install mbed-greentea'." )
2247
- return False
2246
+ error ("The '-f/--flash' option requires that the 'mbed-greentea' python module is installed.\n You can install mbed-ls by running 'pip install mbed-greentea'." , 1 )
2248
2247
2249
- flash_dev (detected ['msd' ], fw_file , program_cycle_s = 0 )
2250
- reset_dev (detected ['port' ])
2248
+ if not flash_dev (detected ['msd' ], fw_file , program_cycle_s = 2 ):
2249
+ error ("Unable to flash the target board connected to your system." , 1 )
2250
+
2251
+ if not reset_dev (detected ['port' ]):
2252
+ error ("Unable to reset the target board connected to your system." , 1 )
2251
2253
2252
2254
program .set_defaults (target = target , toolchain = tchain )
2253
2255
0 commit comments