projects
/
riscv-tests.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7dfc16a
)
Talk to spike using OpenOCD instead of directly.
author
Tim Newsome
<tim@sifive.com>
Tue, 21 Feb 2017 21:07:14 +0000
(13:07 -0800)
committer
Tim Newsome
<tim@sifive.com>
Tue, 21 Feb 2017 21:07:14 +0000
(13:07 -0800)
debug/targets.py
patch
|
blob
|
history
debug/testlib.py
patch
|
blob
|
history
diff --git
a/debug/targets.py
b/debug/targets.py
index 52b623cc59262353b4a84d4582b1a862c1438588..5ac62a83de518f934f89aca4ef7733d38ad53861 100644
(file)
--- a/
debug/targets.py
+++ b/
debug/targets.py
@@
-68,20
+68,21
@@
class SpikeTarget(Target):
ram_size = 5 * 1024 * 1024
instruction_hardware_breakpoint_count = 4
reset_vector = 0x1000
ram_size = 5 * 1024 * 1024
instruction_hardware_breakpoint_count = 4
reset_vector = 0x1000
+ openocd_config = "targets/%s/openocd.cfg" % directory
class Spike64Target(SpikeTarget):
name = "spike64"
xlen = 64
use_fpu = True
class Spike64Target(SpikeTarget):
name = "spike64"
xlen = 64
use_fpu = True
- def
server
(self):
+ def
target
(self):
return testlib.Spike(self.cmd, halted=True)
class Spike32Target(SpikeTarget):
name = "spike32"
xlen = 32
return testlib.Spike(self.cmd, halted=True)
class Spike32Target(SpikeTarget):
name = "spike32"
xlen = 32
- def
server
(self):
+ def
target
(self):
return testlib.Spike(self.cmd, halted=True, xlen=32)
class FreedomE300Target(Target):
return testlib.Spike(self.cmd, halted=True, xlen=32)
class FreedomE300Target(Target):
diff --git
a/debug/testlib.py
b/debug/testlib.py
index a762174df18240a2309d3f8def20f14ff998d3c5..83bbe3ea843bee53044b885f25cee05a9daf367e 100644
(file)
--- a/
debug/testlib.py
+++ b/
debug/testlib.py
@@
-51,14
+51,14
@@
def unused_port():
class Spike(object):
logname = "spike.log"
class Spike(object):
logname = "spike.log"
- def __init__(self, cmd, binary=None, halted=False, with_gdb=True,
+ def __init__(self, cmd, binary=None, halted=False, with_
jtag_
gdb=True,
timeout=None, xlen=64):
"""Launch spike. Return tuple of its process and the port it's running
on."""
if cmd:
cmd = shlex.split(cmd)
else:
timeout=None, xlen=64):
"""Launch spike. Return tuple of its process and the port it's running
on."""
if cmd:
cmd = shlex.split(cmd)
else:
- cmd = ["spike"]
+ cmd = ["spike"
, "-l"
]
if xlen == 32:
cmd += ["--isa", "RV32"]
if xlen == 32:
cmd += ["--isa", "RV32"]
@@
-67,9
+67,9
@@
class Spike(object):
if halted:
cmd.append('-H')
if halted:
cmd.append('-H')
- if with_gdb:
- self.port = unused_port()
- cmd += ['--gdb-port', str(self.port)]
+ if with_
jtag_
gdb:
+ cmd += ['--rbb-port', '0']
+ os.environ['REMOTE_BITBANG_HOST'] = 'localhost'
cmd.append("-m32")
cmd.append('pk')
if binary:
cmd.append("-m32")
cmd.append('pk')
if binary:
@@
-80,6
+80,18
@@
class Spike(object):
self.process = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=logfile, stderr=logfile)
self.process = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=logfile, stderr=logfile)
+ if with_jtag_gdb:
+ self.port = None
+ for _ in range(30):
+ m = re.search(r"Listening for remote bitbang connection on port (\d+).",
+ file(self.logname).read())
+ if m:
+ self.port = int(m.group(1))
+ os.environ['REMOTE_BITBANG_PORT'] = m.group(1)
+ break
+ time.sleep(0.11)
+ assert self.port, "Didn't get spike message about bitbang connection"
+
def __del__(self):
try:
self.process.kill()
def __del__(self):
try:
self.process.kill()
@@
-132,15
+144,11
@@
class Openocd(object):
if cmd:
cmd = shlex.split(cmd)
else:
if cmd:
cmd = shlex.split(cmd)
else:
- cmd = ["openocd"]
- if config:
- cmd += ["-f", find_file(config)]
- if debug:
- cmd.append("-d")
+ cmd = ["openocd", "-d"]
# This command needs to come before any config scripts on the command
# line, since they are executed in order.
# This command needs to come before any config scripts on the command
# line, since they are executed in order.
- cmd
[1:1]
= [
+ cmd
+
= [
# Tell OpenOCD to bind gdb to an unused, ephemeral port.
"--command",
"gdb_port 0",
# Tell OpenOCD to bind gdb to an unused, ephemeral port.
"--command",
"gdb_port 0",
@@
-153,6
+161,11
@@
class Openocd(object):
"telnet_port disabled",
]
"telnet_port disabled",
]
+ if config:
+ cmd += ["-f", find_file(config)]
+ if debug:
+ cmd.append("-d")
+
logfile = open(Openocd.logname, "w")
logfile.write("+ %s\n" % " ".join(cmd))
logfile.flush()
logfile = open(Openocd.logname, "w")
logfile.write("+ %s\n" % " ".join(cmd))
logfile.flush()