12 temporary_binary
= None
15 def __init__(self
, cmd
, run
, isolate
):
18 self
.isolate
= isolate
21 """Start the target, eg. a simulator."""
25 """Start the debug server that gdb connects to, eg. OpenOCD."""
26 if self
.openocd_config
:
27 return testlib
.Openocd(cmd
=self
.cmd
, config
=self
.openocd_config
)
29 raise NotImplementedError
31 def compile(self
, *sources
):
32 binary_name
= "%s_%s-%d" % (
34 os
.path
.basename(os
.path
.splitext(sources
[0])[0]),
37 self
.temporary_binary
= tempfile
.NamedTemporaryFile(
38 prefix
=binary_name
+ "_")
39 binary_name
= self
.temporary_binary
.name
40 Target
.temporary_files
.append(self
.temporary_binary
)
41 testlib
.compile(sources
+
42 ("programs/entry.S", "programs/init.c",
44 "-T", "targets/%s/link.lds" % (self
.directory
or self
.name
),
51 class SpikeTarget(Target
):
52 # pylint: disable=abstract-method
55 ram_size
= 5 * 1024 * 1024
56 instruction_hardware_breakpoint_count
= 4
59 class Spike64Target(SpikeTarget
):
64 return testlib
.Spike(self
.cmd
, halted
=True)
66 class Spike32Target(SpikeTarget
):
71 return testlib
.Spike(self
.cmd
, halted
=True, xlen
=32)
73 class FreedomE300Target(Target
):
78 instruction_hardware_breakpoint_count
= 2
79 openocd_config
= "targets/%s/openocd.cfg" % name
81 class FreedomE300SimTarget(Target
):
82 name
= "freedom-e300-sim"
86 ram_size
= 256 * 1024 * 1024
87 instruction_hardware_breakpoint_count
= 2
88 openocd_config
= "targets/%s/openocd.cfg" % name
91 return testlib
.VcsSim(simv
=self
.run
, debug
=False)
93 class FreedomU500Target(Target
):
98 instruction_hardware_breakpoint_count
= 2
99 openocd_config
= "targets/%s/openocd.cfg" % name
101 class FreedomU500SimTarget(Target
):
102 name
= "freedom-u500-sim"
106 ram_size
= 256 * 1024 * 1024
107 instruction_hardware_breakpoint_count
= 2
108 openocd_config
= "targets/%s/openocd.cfg" % name
111 return testlib
.VcsSim(simv
=self
.run
, debug
=False)
118 FreedomE300SimTarget
,
119 FreedomU500SimTarget
]
121 def add_target_options(parser
):
122 group
= parser
.add_mutually_exclusive_group(required
=True)
124 group
.add_argument("--%s" % t
.name
, action
="store_const", const
=t
,
126 parser
.add_argument("--run",
127 help="The command to use to start the actual target (e.g. "
129 parser
.add_argument("--cmd",
130 help="The command to use to start the debug server.")
132 xlen_group
= parser
.add_mutually_exclusive_group()
133 xlen_group
.add_argument("--32", action
="store_const", const
=32, dest
="xlen",
134 help="Force the target to be 32-bit.")
135 xlen_group
.add_argument("--64", action
="store_const", const
=64, dest
="xlen",
136 help="Force the target to be 64-bit.")
138 parser
.add_argument("--isolate", action
="store_true",
139 help="Try to run in such a way that multiple instances can run at "
140 "the same time. This may make it harder to debug a failure if it "