Skip to content

Commit bc7b1c5

Browse files
Marti Bolivarnashif
authored andcommitted
scripts: west: fix some intel_s1000 runner issues
There are a few issues with the intel_s1000 runner: - it doesn't attach to the client when running debug (this is a part of the command's contract specified in core.py) - it uses hard-coded sleeps when running subprocesses instead of waiting for them to terminate - it re-implements pre-existing popen_ignore_int() functionality (in a way that is not portable to Windows) rather than using it directly Fix these issues. Signed-off-by: Marti Bolivar <[email protected]>
1 parent a9aa250 commit bc7b1c5

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

scripts/meta/west/runner/intel_s1000.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Copyright (c) 2018 Intel Corporation.
2+
# Copyright 2018 Open Source Foundries Limited.
23
#
34
# SPDX-License-Identifier: Apache-2.0
45

56
'''Runner for debugging and flashing intel_s1000 devices'''
67
from os import path
78
from .core import ZephyrBinaryRunner
89
import time
9-
import signal
10+
import subprocess
1011

1112
DEFAULT_XT_GDB_PORT = 20000
1213

@@ -75,6 +76,7 @@ def do_run(self, command, **kwargs):
7576
elif command == 'debugserver':
7677
self.debugserver(**kwargs)
7778
else:
79+
self.debugserver(**kwargs)
7880
self.do_debug()
7981

8082
def flash(self, **kwargs):
@@ -90,23 +92,19 @@ def flash(self, **kwargs):
9092
# Start the server
9193
# Note that XTOCD always fails the first time. It has to be
9294
# relaunched the second time to work.
93-
self.popen_ignore_int(server_cmd)
94-
time.sleep(3)
95+
self.call(server_cmd)
9596
server_proc = self.popen_ignore_int(server_cmd)
9697
time.sleep(3)
9798

98-
# Start the client
99+
# Start the client, and wait for it to finish flashing the file.
99100
gdb_cmd = [self.gdb_cmd, '-x', gdb_flash_file]
100101
client_proc = self.popen_ignore_int(gdb_cmd)
101-
102-
# Wait for 3 seconds (waiting for XTGDB to finish)
103-
time.sleep(3)
102+
client_proc.wait()
104103

105104
# At this point, the ELF image is loaded and the program is in
106-
# execution. Now we can quit the client (xt-gdb) and the server
107-
# (xt-ocd) as they are not needed anymore. The loaded program
108-
# (ELF) will continue to run though.
109-
client_proc.terminate()
105+
# execution. Now we can quit the server (xt-ocd); it is not
106+
# needed anymore. The loaded program (ELF) will continue to
107+
# run.
110108
server_proc.terminate()
111109

112110
def do_debug(self):
@@ -118,15 +116,10 @@ def do_debug(self):
118116
gdb_cmd = [self.gdb_cmd,
119117
'-ex', 'target remote :{}'.format(self.gdb_port),
120118
self.elf_name]
121-
122-
# The below statement will consume the "^C" keypress ensuring
123-
# the python main application doesn't exit. This is important
124-
# since ^C in gdb means a "halt" operation.
125-
previous = signal.signal(signal.SIGINT, signal.SIG_IGN)
126-
try:
127-
self.check_call(gdb_cmd)
128-
finally:
129-
signal.signal(signal.SIGINT, previous)
119+
gdb_proc = self.popen_ignore_int(gdb_cmd)
120+
retcode = gdb_proc.wait()
121+
if retcode:
122+
raise subprocess.CalledProcessError((retcode, gdb_cmd))
130123

131124
def print_gdbserver_message(self, gdb_port):
132125
print('Intel S1000 GDB server running on port {}'.format(gdb_port))
@@ -142,6 +135,5 @@ def debugserver(self, **kwargs):
142135

143136
# Note that XTOCD always fails the first time. It has to be
144137
# relaunched the second time to work.
145-
self.popen_ignore_int(server_cmd)
146-
time.sleep(3)
138+
self.call(server_cmd)
147139
self.check_call(server_cmd)

0 commit comments

Comments
 (0)