12 temporary_binary
= None
16 def __init__(self
, cmd
, run
, isolate
):
19 self
.isolate
= isolate
22 """Start the target, eg. a simulator."""
26 """Start the debug server that gdb connects to, eg. OpenOCD."""
27 if self
.openocd_config
:
28 return testlib
.Openocd(cmd
=self
.cmd
, config
=self
.openocd_config
)
30 raise NotImplementedError
32 def compile(self
, *sources
):
33 binary_name
= "%s_%s-%d" % (
35 os
.path
.basename(os
.path
.splitext(sources
[0])[0]),
38 self
.temporary_binary
= tempfile
.NamedTemporaryFile(
39 prefix
=binary_name
+ "_")
40 binary_name
= self
.temporary_binary
.name
41 Target
.temporary_files
.append(self
.temporary_binary
)
42 march
= "RV%dIMA" % self
.xlen
45 testlib
.compile(sources
+
46 ("programs/entry.S", "programs/init.c",
49 "-T", "targets/%s/link.lds" % (self
.directory
or self
.name
),
56 class SpikeTarget(Target
):
57 # pylint: disable=abstract-method
60 ram_size
= 5 * 1024 * 1024
61 instruction_hardware_breakpoint_count
= 4
64 class Spike64Target(SpikeTarget
):
70 return testlib
.Spike(self
.cmd
, halted
=True)
72 class Spike32Target(SpikeTarget
):
77 return testlib
.Spike(self
.cmd
, halted
=True, xlen
=32)
79 class FreedomE300Target(Target
):
84 instruction_hardware_breakpoint_count
= 2
85 openocd_config
= "targets/%s/openocd.cfg" % name
87 class FreedomE300SimTarget(Target
):
88 name
= "freedom-e300-sim"
92 ram_size
= 256 * 1024 * 1024
93 instruction_hardware_breakpoint_count
= 2
94 openocd_config
= "targets/%s/openocd.cfg" % name
97 return testlib
.VcsSim(simv
=self
.run
, debug
=False)
99 class FreedomU500Target(Target
):
100 name
= "freedom-u500"
104 instruction_hardware_breakpoint_count
= 2
105 openocd_config
= "targets/%s/openocd.cfg" % name
107 class FreedomU500SimTarget(Target
):
108 name
= "freedom-u500-sim"
112 ram_size
= 256 * 1024 * 1024
113 instruction_hardware_breakpoint_count
= 2
114 openocd_config
= "targets/%s/openocd.cfg" % name
117 return testlib
.VcsSim(simv
=self
.run
, debug
=False)
124 FreedomE300SimTarget
,
125 FreedomU500SimTarget
]
127 def add_target_options(parser
):
128 group
= parser
.add_mutually_exclusive_group(required
=True)
130 group
.add_argument("--%s" % t
.name
, action
="store_const", const
=t
,
132 parser
.add_argument("--run",
133 help="The command to use to start the actual target (e.g. "
135 parser
.add_argument("--cmd",
136 help="The command to use to start the debug server.")
138 xlen_group
= parser
.add_mutually_exclusive_group()
139 xlen_group
.add_argument("--32", action
="store_const", const
=32, dest
="xlen",
140 help="Force the target to be 32-bit.")
141 xlen_group
.add_argument("--64", action
="store_const", const
=64, dest
="xlen",
142 help="Force the target to be 64-bit.")
144 parser
.add_argument("--isolate", action
="store_true",
145 help="Try to run in such a way that multiple instances can run at "
146 "the same time. This may make it harder to debug a failure if it "