-
Notifications
You must be signed in to change notification settings - Fork 40
317 lines (267 loc) · 10.6 KB
/
interactive-debugging.yml
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Interactive debugging
on:
push:
branches: ["main", "dev-goog", "dev-msft", "dev-public"]
pull_request:
workflow_dispatch:
jobs:
build_verilator:
name:
runs-on: ubuntu-22.04
env:
CARGO_INCREMENTAL: 0
SCCACHE_VERSION: 0.3.3
# TODO: To update to 5.006, clean up lint errors
VERILATOR_VERSION: v5.012
SCCACHE_GHA_CACHE_TO: sccache-verilator-10000
SCCACHE_GHA_CACHE_FROM: sccache-verilator-
# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1d
steps:
- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install sccache
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
run: |
cargo install sccache --version ${SCCACHE_VERSION} --no-default-features --features=gha
- name: Save sccache binary
uses: actions/cache/save@v3
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Configure sccache
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Restore verilator dir
uses: actions/cache/restore@v3
id: verilator_restore
with:
path: /opt/verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install verilator
if: steps.verilator_restore.outputs.cache-hit != 'true'
run: |
sudo apt-get install flex bison libfl2 libfl-dev help2man
cd /tmp/
git clone -b "${VERILATOR_VERSION}" https://github.com/verilator/verilator
cd verilator
autoconf
./configure --prefix=/opt/verilator CC="sccache gcc" CXX="sccache g++"
make -j6
sudo make install
- name: Save verilator dir
uses: actions/cache/save@v3
if: steps.verilator_restore.outputs.cache-hit != 'true'
with:
path: /opt/verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Pack Verilator
run: |
cd /opt && tar -czvf verilator.tar.gz verilator/
- name: Store Verilator binaries
uses: actions/upload-artifact@v3
with:
name: verilator
path: /opt/*.tar.gz
retention-days: 1
build_openocd:
name:
runs-on: ubuntu-22.04
env:
CARGO_INCREMENTAL: 0
SCCACHE_VERSION: 0.3.3
# A custom fork is needed to allow bypassing core examination and accessing
# peripherals regardless of core state.
OPENOCD_REPO: https://github.com/antmicro/openocd
OPENOCD_VERSION: riscv-nohalt
SCCACHE_GHA_CACHE_TO: sccache-openocd-10000
SCCACHE_GHA_CACHE_FROM: sccache-openocd-
# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1e
steps:
- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install sccache
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
run: |
cargo install sccache --version ${SCCACHE_VERSION} --no-default-features --features=gha
- name: Save sccache binary
uses: actions/cache/save@v3
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Configure sccache
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Restore OpenOCD dir
uses: actions/cache/restore@v3
id: openocd_restore
with:
path: /opt/openocd
key: openocd-${{ env.OPENOCD_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install OpenOCD
if: steps.openocd_restore.outputs.cache-hit != 'true'
run: |
sudo apt-get install make libtool pkg-config autoconf automake texinfo
cd /tmp/
git clone -b "${OPENOCD_VERSION}" https://github.com/antmicro/openocd
cd openocd
./bootstrap
./configure --prefix=/opt/openocd --enable-remote-bitbang \
CC="sccache gcc" CXX="sccache g++" \
CFLAGS="-Wno-error=misleading-indentation -Wno-error=stringop-overflow"
make -j6
sudo make install
- name: Save OpenOCD dir
uses: actions/cache/save@v3
if: steps.openocd_restore.outputs.cache-hit != 'true'
with:
path: /opt/openocd
key: openocd-${{ env.OPENOCD_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Pack OpenOCD
run: |
cd /opt && tar -czvf openocd.tar.gz openocd/
- name: Store OpenOCD binaries
uses: actions/upload-artifact@v3
with:
name: openocd
path: /opt/*.tar.gz
retention-days: 1
gdb_tests:
name: Run GDB debugging tests
runs-on: ubuntu-22.04
needs: [build_verilator, build_openocd]
env:
CARGO_INCREMENTAL: 0
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig
DEBIAN_FRONTEND: "noninteractive"
steps:
- name: Install Risc V Toolchain
run: |
# Building from source takes around 6.65 GB of disk and download size
wget -O toolchain.tar.gz https://github.com/stnolting/riscv-gcc-prebuilt/releases/download/rv64imc-3.0.0/riscv64-unknown-elf.gcc-12.1.0.tar.gz
mkdir /opt/riscv
tar -xzf toolchain.tar.gz -C /opt/riscv/
- name: Install dependencies
run: |
# For some reason GDB requires libpython3.8.so
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update -qy && sudo apt install -qy --no-install-recommends \
libpython3.8
- name: Download Verilator binaries
uses: actions/download-artifact@v3
with:
name: verilator
path: /opt
- name: Download OpenOCD binaries
uses: actions/download-artifact@v3
with:
name: openocd
path: /opt
- name: Unpack binaries
run: |
pushd /opt
tar -zxvf verilator.tar.gz
tar -zxvf openocd.tar.gz
popd
- name: Setup path
run: |
echo /opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin >> $GITHUB_PATH
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Build Verilated simulation
run: |
export CALIPTRA_ROOT=$(pwd)
mkdir run
make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile verilator-build TESTNAME=infinite_loop DEBUG_UNLOCKED=1 \
OBJCACHE="" CC=gcc CXX=g++ LINK=g++
make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile program.hex TESTNAME=infinite_loop
- name: Test core register access
run: |
export CALIPTRA_ROOT=$(pwd)
cd run
${CALIPTRA_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./dump_and_compare.sh'
- name: Test memory access
run: |
export CALIPTRA_ROOT=$(pwd)
cd run
${CALIPTRA_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./mem_access.sh'
- name: Test peripheral access
run: |
export CALIPTRA_ROOT=$(pwd)
cd run
${CALIPTRA_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./peripheral_access.sh'
openocd_tests:
name: Run OpenOCD debugging tests
runs-on: ubuntu-22.04
needs: [build_verilator, build_openocd]
env:
CARGO_INCREMENTAL: 0
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig
DEBIAN_FRONTEND: "noninteractive"
steps:
- name: Install Risc V Toolchain
run: |
# Building from source takes around 6.65 GB of disk and download size
wget -O toolchain.tar.gz https://github.com/stnolting/riscv-gcc-prebuilt/releases/download/rv64imc-3.0.0/riscv64-unknown-elf.gcc-12.1.0.tar.gz
mkdir /opt/riscv
tar -xzf toolchain.tar.gz -C /opt/riscv/
- name: Download Verilator binaries
uses: actions/download-artifact@v3
with:
name: verilator
path: /opt
- name: Download OpenOCD binaries
uses: actions/download-artifact@v3
with:
name: openocd
path: /opt
- name: Unpack binaries
run: |
pushd /opt
tar -zxvf verilator.tar.gz
tar -zxvf openocd.tar.gz
popd
- name: Setup path
run: |
echo /opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin >> $GITHUB_PATH
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Build Verilated simulation
run: |
export CALIPTRA_ROOT=$(pwd)
mkdir run
make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile verilator-build TESTNAME=infinite_loop DEBUG_UNLOCKED=1 FORCE_CPU_RESET=1 \
OBJCACHE="" CC=gcc CXX=g++ LINK=g++
make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile program.hex TESTNAME=infinite_loop
- name: Test peripheral access with core in reset
run: |
export CALIPTRA_ROOT=$(pwd)
cd run
${CALIPTRA_ROOT}/.github/scripts/openocd_test.sh \
-f board/caliptra-verilator-rst.cfg \
-f ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop/peripheral_access.tcl