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
):
69 return testlib
.Spike(self
.cmd
, halted
=True)
71 class Spike32Target(SpikeTarget
):
76 return testlib
.Spike(self
.cmd
, halted
=True, xlen
=32)
78 class FreedomE300Target(Target
):
83 instruction_hardware_breakpoint_count
= 2
84 openocd_config
= "targets/%s/openocd.cfg" % name
86 class FreedomE300SimTarget(Target
):
87 name
= "freedom-e300-sim"
91 ram_size
= 256 * 1024 * 1024
92 instruction_hardware_breakpoint_count
= 2
93 openocd_config
= "targets/%s/openocd.cfg" % name
96 return testlib
.VcsSim(simv
=self
.run
, debug
=False)
98 class FreedomU500Target(Target
):
103 instruction_hardware_breakpoint_count
= 2
104 openocd_config
= "targets/%s/openocd.cfg" % name
106 class FreedomU500SimTarget(Target
):
107 name
= "freedom-u500-sim"
111 ram_size
= 256 * 1024 * 1024
112 instruction_hardware_breakpoint_count
= 2
113 openocd_config
= "targets/%s/openocd.cfg" % name
116 return testlib
.VcsSim(simv
=self
.run
, debug
=False)
123 FreedomE300SimTarget
,
124 FreedomU500SimTarget
]
126 def add_target_options(parser
):
127 group
= parser
.add_mutually_exclusive_group(required
=True)
129 group
.add_argument("--%s" % t
.name
, action
="store_const", const
=t
,
131 parser
.add_argument("--run",
132 help="The command to use to start the actual target (e.g. "
134 parser
.add_argument("--cmd",
135 help="The command to use to start the debug server.")
137 xlen_group
= parser
.add_mutually_exclusive_group()
138 xlen_group
.add_argument("--32", action
="store_const", const
=32, dest
="xlen",
139 help="Force the target to be 32-bit.")
140 xlen_group
.add_argument("--64", action
="store_const", const
=64, dest
="xlen",
141 help="Force the target to be 64-bit.")
143 parser
.add_argument("--isolate", action
="store_true",
144 help="Try to run in such a way that multiple instances can run at "
145 "the same time. This may make it harder to debug a failure if it "