sanitycheck: support pre/post flash scripts
This is needed when a board needs to be reset using an external commands or tools that are not part of the flash command. For example, power reset or by poking a GPIO header on the board using external wiring. add post_flash/pre_flash to the platform section in the hardware map. For example: - available: true connected: true id: OSHW000032254e4500128002ab98002784d1000097969900 platform: reel_board post_script: /tmp/post_flash.sh pre_script: /tmp/pre_flash.sh product: DAPLink CMSIS-DAP runner: pyocd serial: /dev/ttyACM11 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
5c48c2132d
commit
fc85ff052f
1 changed files with 26 additions and 0 deletions
|
@ -759,6 +759,21 @@ class DeviceHandler(Handler):
|
||||||
read_pipe, write_pipe = os.pipe()
|
read_pipe, write_pipe = os.pipe()
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
|
|
||||||
|
pre_script = hardware.get('pre_script')
|
||||||
|
post_script = hardware.get('post_script')
|
||||||
|
|
||||||
|
if pre_script:
|
||||||
|
with subprocess.Popen(pre_script, stderr=subprocess.PIPE, stdout=subprocess.PIPE) as proc:
|
||||||
|
try:
|
||||||
|
(stdout, stderr) = proc.communicate(timeout=30)
|
||||||
|
logger.debug(stdout.decode())
|
||||||
|
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
proc.kill()
|
||||||
|
(stdout, stderr) = proc.communicate()
|
||||||
|
logger.error("{} timed out".format(post_script))
|
||||||
|
|
||||||
t = threading.Thread(target=self.monitor_serial, daemon=True,
|
t = threading.Thread(target=self.monitor_serial, daemon=True,
|
||||||
args=(ser, read_pipe, harness))
|
args=(ser, read_pipe, harness))
|
||||||
t.start()
|
t.start()
|
||||||
|
@ -812,6 +827,17 @@ class DeviceHandler(Handler):
|
||||||
else:
|
else:
|
||||||
self.set_state(out_state, handler_time)
|
self.set_state(out_state, handler_time)
|
||||||
|
|
||||||
|
if post_script:
|
||||||
|
with subprocess.Popen(post_script, stderr=subprocess.PIPE, stdout=subprocess.PIPE) as proc:
|
||||||
|
try:
|
||||||
|
(stdout, stderr) = proc.communicate(timeout=30)
|
||||||
|
logger.debug(stdout.decode())
|
||||||
|
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
proc.kill()
|
||||||
|
(stdout, stderr) = proc.communicate()
|
||||||
|
logger.error("{} timed out".format(post_script))
|
||||||
|
|
||||||
self.make_device_available(serial_device)
|
self.make_device_available(serial_device)
|
||||||
|
|
||||||
self.record(harness)
|
self.record(harness)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue