Skip to content

Commit

Permalink
msg for when flash fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiCheng-Lu committed Jan 30, 2024
1 parent 8cddd51 commit 94ffedc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scons/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ def parse_config(entry):

def flash_run(entry):
'''flash and run file, return a pyserial object which monitors the device serial output'''
output = subprocess.check_output(["ls", "/dev/serial/by-id/"])
device_path = f"/dev/serial/by-id/{str(output, 'ASCII').strip()}"
serialData = serial.Serial(device_path, 115200)
try:
output = subprocess.check_output(["ls", "/dev/serial/by-id/"])
device_path = f"/dev/serial/by-id/{str(output, 'ASCII').strip()}"
serialData = serial.Serial(device_path, 115200)
except:
print()
print("Flashing requires a controller board to be connected, use --platform=x86 for x86 targets")

OPENOCD = 'openocd'
OPENOCD_SCRIPT_DIR = '/usr/share/openocd/scripts/'
Expand All @@ -46,8 +50,7 @@ def flash_run(entry):
]
cmd = 'sudo {}'.format(' '.join(OPENOCD_CFG))

subprocess.run(cmd, shell=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
subprocess.run(cmd, shell=True).check_returncode()

print("Flash complete")
return serialData

0 comments on commit 94ffedc

Please sign in to comment.