This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
282 lines (234 loc) · 8.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#
# Top level makefile for the project
#
include $(UAS_ROOT)/Makefile.common
#
# Used by the SCALE and ChipWhisperer targets, enables re-programmng without
# using the physical buttons on the boards,
PROGRAM_WITH_OPENOCD =0
USB_PORT ?= /dev/ttyUSB0
USB_BAUD ?= 9600
TTEST_NUM_TRACES ?= 1000
SCOPE_CONFIG ?= $(UAS_ROOT)/target/$(UAS_TARGET)/capture/picoscope5000.cfg
SCOPE_POWER_CHANNEL ?=B
CAPTURE_ARGS =
FORCE_ANALYSIS = 1
ANALYSIS_FLAGS =
ifeq ($(FORCE_ANALYSIS),1)
ANALYSIS_FLAGS += --force
endif
DELETE_TRACES_AFTER_ANALYSIS ?=1
DELETE_TRACES=
ifeq ($(DELETE_TRACES_AFTER_ANALYSIS),1)
DELETE_TRACES=--delete-traces-after-analysis
endif
#
# Whether or not to skip trace capture if there is already a comparable trace
# set in the database.
SKIP_CAPTURE_IF_PRESENT ?=1
ifeq ($(SKIP_CAPTURE_IF_PRESENT),1)
CAPTURE_ARGS += --skip-if-present
endif
# Make all variables available to submake shells.
export
TARGETS = sakurax_mb3 \
sakurax_mb5 \
sakurax_mb8 \
sakurax_picorv32 \
scale_lpc1114fn28 \
scale_lpc1313fbd48 \
scale_lpc812m101 \
cw308_stm32f071 \
scarv_stm32f051 \
cw308_stm32f1 \
cw308_stm32f2 \
cw308_stm32f3 \
cw308_stm32f4 \
cw308_stm32f4_int_16mhz \
nxp_lpc1115fbd48 \
#intel_d2000
EXPERIMENTS = memory-bus/bus-width-st-bytes \
memory-bus/bus-width-st-halfword \
memory-bus/bus-width-st-word \
memory-bus/bus-width-ld-bytes \
memory-bus/bus-width-ld-halfword \
memory-bus/bus-width-ld-word \
memory-bus/registers-implicit-ld-ld \
memory-bus/registers-implicit-ld-st \
memory-bus/registers-implicit-st-ld \
memory-bus/registers-implicit-st-st-1 \
memory-bus/registers-implicit-st-st-2 \
memory-bus/registers-implicit-st-st-3 \
memory-bus/seq-ld-bytes \
memory-bus/seq-st-bytes \
pipeline/regs-xor-lhs \
pipeline/regs-xor-rhs \
pipeline/regs-xor-nop \
pipeline/regs-xor-mov-lhs \
pipeline/regs-xor-mov-rhs \
pipeline/cmov-operands \
pipeline/regs-lshf-lhs \
pipeline/regs-lshf-rhs \
pipeline/regs-rshf-lhs \
pipeline/regs-rshf-rhs \
pipeline/branch-flush-regs \
pipeline/branch-flush-regs-post \
pipeline/jump-flush-regs-pre \
pipeline/jump-flush-regs-post \
pipeline/result-stages \
pipeline/iseq-xor-add \
pipeline/iseq-xor-xor \
pipeline/iseq-xor-srli \
pipeline/iseq-xor-rori \
pipeline/iseq-xor-lw \
pipeline/iseq-xor-sw \
regfile/neighbour-hw \
regfile/shift-imm \
speculation/jump-shadow-0 \
speculation/loop-0 \
speculation/loop-1 \
speculation/unpredictable-0 \
speculation/jump-fwd \
speculation/jump-bwd \
speculation/branch-fwd \
speculation/branch-bwd \
countermeasures/rosita-rotate-unprotected \
countermeasures/rosita-rotate-protected \
countermeasures/rosita-ld-ld-0 \
countermeasures/rosita-ld-ld-1 \
countermeasures/rosita-ld-ld-2 \
countermeasures/rosita-ld-ld-3 \
countermeasures/rosita-st-st-0 \
countermeasures/rosita-st-st-1 \
countermeasures/rosita-st-st-2 \
countermeasures/rosita-st-st-3
DB_CON = $(UAS_DB) --backend $(UAS_DB_BACKEND)
# CLI tool used to manually interact with the database
DB_CLI = $(UAS_ROOT)/tools/database/cli.py $(DB_CON)
FLOW_CAPTURE= $(UAS_ROOT)/tools/flow/capture.py
FLOW_ANALYSE= $(UAS_ROOT)/tools/flow/analyse.py
#
# These variables are appended too by the various add_X macros below.
BUILD_TARGETS =
FLOW_TARGETS =
TGT_ANALYSIS_TARGETS =
ALL_ANALYSIS_TARGETS =
#
# Makes experiment names direcotry path friendly by removing "/" and
# replacing with "-" characters.
#
define map_exp
$(subst /,-,${1})
endef
#
# Creates a Makefile target name from three inputs:
#
# 1 - Command: Should be a verb like "build", "program" or "analyse"
# 2 - Target Device Name
# 3 - Experiment Name
#
define map_tgt
${1}_${2}_$(call map_exp,${3})
endef
#
# Add a build target name to the BUILD_TARGETS variable, so we can
# make the build-all phony target work.
#
# 1. Target device.
# 2. Experiment Name.
#
define add_tgt_build
.PHONY: $(call map_tgt,build,${1},${2})
$(call map_tgt,build,${1},${2}) :
$(MAKE) -f Makefile.build UAS_TARGET=${1} UAS_EXPERIMENT=${2} all
BUILD_TARGETS += $(call map_tgt,build,${1},${2})
endef
#
# Add a top level target to program a given device with a given experiment.
#
# 1. Target device.
# 2. Experiment Name.
#
define add_tgt_program
.PHONY: $(call map_tgt,program,${1},${2})
$(call map_tgt,program,${1},${2}) : $(call map_tgt,build,${1},${2})
$(MAKE) -f Makefile.program UAS_TARGET=${1} UAS_EXPERIMENT=${2} program
endef
#
# Add a top level target to capture data from an experiment on a given
# target device.
#
# 1. Target device.
# 2. Experiment Name.
#
define add_tgt_capture
.PHONY: $(call map_tgt,capture,${1},${2})
$(call map_tgt,capture,${1},${2}) : $(call map_tgt,program,${1},${2})
$(FLOW_CAPTURE) \
--baud $(USB_BAUD) \
--backend $(UAS_DB_BACKEND) \
--verbose \
--ttest-traces $(TTEST_NUM_TRACES) \
--scope-power-channel $(SCOPE_POWER_CHANNEL) \
--store-binary $(call map_experiment_elf_full,${2},${1}) \
--store-disasm $(call map_experiment_dis_full,${2},${1}) \
$(CAPTURE_ARGS) \
$(UAS_ROOT)/experiments/${2} \
$(UAS_ROOT)/target/${1}/${1}.cfg \
$(UAS_DB) \
$(SCOPE_CONFIG) \
$(USB_PORT)
endef
#
# Add a top level target to analyse captured data from an experiment on a
# given target device.
#
# 1. Target device.
# 2. Experiment Name.
#
define add_tgt_analyse
$(call map_tgt,analyse,${1},${2}) :
$(FLOW_ANALYSE) \
--verbose $(ANALYSIS_FLAGS) \
--backend $(UAS_DB_BACKEND) $(DELETE_TRACES) \
$(UAS_DB) \
${2} \
--targets ${1}
ALL_ANALYSIS_TARGETS += $(call map_tgt,analyse,${1},${2})
endef
#
# Utility command which does build, program and capture steps all in one go.
#
define add_tgt_flow
flow-$(call map_exp,${1}) : \
$(call map_tgt,build,${UAS_TARGET},${1}) \
$(call map_tgt,program,${UAS_TARGET},${1}) \
$(call map_tgt,capture,${UAS_TARGET},${1}) \
$(call map_tgt,analyse,${UAS_TARGET},${1})
FLOW_TARGETS += flow-$(call map_exp,${1})
TGT_ANALYSIS_TARGETS += $(call map_tgt,analyse,${UAS_TARGET},${1})
endef
define add_tgt_device_test
test_device_${1} :
./external/fw-acquisition/bin/device-test.py -b $(USB_BAUD) $(USB_PORT)
endef
$(foreach EXP,$(EXPERIMENTS), $(eval $(call add_tgt_flow,$(EXP))))
#
# Run every experiment available for the given target.
# Expects UAS_TARGET to be passed as a command line option.
run-all-experiments-for-target: $(FLOW_TARGETS)
#
# Re-run the "analysis" target for every experiment under the specified
# target device.
analyse-all-experiments-for-target: $(TGT_ANALYSIS_TARGETS)
#
# Re-run the "analysis" target for every experiment under every
# target device.
analyse-all-experiments-for-all-targets: $(ALL_ANALYSIS_TARGETS)
$(foreach TGT,$(TARGETS), $(foreach EXP,$(EXPERIMENTS), $(eval $(call add_tgt_build,$(TGT),$(EXP)))))
$(foreach TGT,$(TARGETS), $(foreach EXP,$(EXPERIMENTS), $(eval $(call add_tgt_program,$(TGT),$(EXP)))))
$(foreach TGT,$(TARGETS), $(foreach EXP,$(EXPERIMENTS), $(eval $(call add_tgt_capture,$(TGT),$(EXP)))))
$(foreach TGT,$(TARGETS), $(foreach EXP,$(EXPERIMENTS), $(eval $(call add_tgt_analyse,$(TGT),$(EXP)))))
build-all: $(BUILD_TARGETS)
browse-results:
cd $(MIR_BROWSER_REPO_HOME) && python3 ./browser/wsgi.py $(UAS_DB)