-
Notifications
You must be signed in to change notification settings - Fork 11
/
.gitlab-ci.yml
501 lines (470 loc) · 15.4 KB
/
.gitlab-ci.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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
variables:
GIT_SUBMODULE_STRATEGY: recursive
GET_SOURCES_ATTEMPTS: 5
GIT_STRATEGY: fetch
FF_USE_FASTZIP: "true"
SHARELOC: "/home/xl_ci/linuxsdk/"
QEMUPATH: "/home/share/devtools/qemu/linux64/8.0"
workflow:
rules:
- if: $CI_COMMIT_MESSAGE =~ /draft|wip|stash/i
when: never
- if: $CI_COMMIT_BRANCH =~ /master|develop|dev_nuclei*|feature\/.|/
- if: $CI_COMMIT_BRANCH == "dev_nuclei_next" && $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /master|develop|dev_nuclei*/ && $CI_PIPELINE_SOURCE == "merge_request_event"
before_script:
- source /home/share/devtools/env.sh
- echo "Use qemu located in $QEMUPATH"
- export PATH=$QEMUPATH/bin:$PATH
stages:
- build
- run
- manual
cache:
paths:
- buildroot/dl
.snippet_build_sdk: &snippet_build_sdk
- echo ">>Clean previous build workspace"
- make clean
- echo ">>Show help message for $SOC - $CORE - $BOOT_MODE"
- make help
- echo ">>Build buildroot_initramfs_sysroot for $CORE"
- |
make -j buildroot_initramfs_sysroot > >(tee build_sysroot.log |grep '>>>') || {
echo 'Show last 200 lines of build log'
tail -n 200 build_sysroot.log
xz -f -z build_sysroot.log
exit 1
}
- xz -f -z build_sysroot.log
- echo ">>Build multiple prefetch freeloader for $SOC - $CORE - $BOOT_MODE"
- |
export MAKEOPTS="SOC=$SOC CORE=$CORE BOOT_MODE=${BOOT_MODE}"
export SELVAR0="CPU_HZ"
export VARLIST0="30000000,50000000,100000000"
export SELVAR1="SPFL1DCTRL1"
export VARLIST1="0x0,0x1f,0xf,0x3f"
bash .github/build_multiple_freeloader.sh > >(tee build_pref_freeloader.log) || {
xz -f -z build_pref_freeloader.log
exit 1
}
unset MAKEOPTS SELVAR0 VARLIST0 SELVAR1 VARLIST1
- echo ">>Build multiple cache settings freeloader for $SOC - $CORE - $BOOT_MODE"
- |
export MAKEOPTS="SOC=$SOC CORE=$CORE BOOT_MODE=${BOOT_MODE}"
export SELVAR0="CPU_HZ"
export VARLIST0="30000000,50000000,100000000"
export SELVAR1="CACHE_CTRL"
export VARLIST1="0x100C1,0x10001"
bash .github/build_multiple_freeloader.sh > >(tee build_cache_freeloader.log) || {
xz -f -z build_cache_freeloader.log
exit 1
}
unset MAKEOPTS SELVAR0 VARLIST0 SELVAR1 VARLIST1
- xz -f -z build_cache_freeloader.log
- echo ">>Build simulation freeloader for $SOC - $CORE - $BOOT_MODE"
- |
export MAKEOPTS="SOC=$SOC CORE=$CORE BOOT_MODE=${BOOT_MODE}"
export SELVAR0="SIMULATION"
export VARLIST0="1"
export SELVAR1="SPFL1DCTRL1"
export VARLIST1="0x0,0x1f,0xf,0x3f"
bash .github/build_multiple_freeloader.sh > >(tee build_simu_freeloader.log) || {
xz -f -z build_simu_freeloader.log
exit 1
}
unset MAKEOPTS SELVAR0 VARLIST0 SELVAR1 VARLIST1
- xz -f -z build_simu_freeloader.log
- echo ">>Build simulation freeloader console=hvc0 for $SOC - $CORE - $BOOT_MODE"
- |
export MAKEOPTS="SOC=$SOC CORE=$CORE BOOT_MODE=${BOOT_MODE} HVC_CONSOLE=y"
export SELVAR0="SIMULATION"
export VARLIST0="1"
export SELVAR1="SPFL1DCTRL1"
export VARLIST1="0x0,0x1f,0xf,0x3f"
bash .github/build_multiple_freeloader.sh > >(tee build_simu_hvc_freeloader.log) || {
xz -f -z build_simu_hvc_freeloader.log
exit 1
}
unset MAKEOPTS SELVAR0 VARLIST0 SELVAR1 VARLIST1
- xz -f -z build_simu_hvc_freeloader.log
- echo ">>Build freeloader for $SOC - $CORE - $BOOT_MODE"
- |
echo ">>>Build freeloader for default MHz"
make freeloader > >(tee build_freeloader.log) || {
xz -f -z build_freeloader.log
exit 1
}
- xz -f -z build_freeloader.log
- echo ">>Build and generate boot images for $SOC - $CORE - $BOOT_MODE"
- |
make preboot && make -j bootimages > >(tee build_bootimages.log) || {
xz -f -z build_bootimages.log
exit 1
}
- xz -f -z build_bootimages.log
- |
echo ">>Build and generate qemu images for $SOC - $CORE - $BOOT_MODE"
#echo ">>> Apply workaround: change TIMERCLK_FREQ from 32768 to 1000000"
#sed -i "s/32768/1000000/" conf/$SOC/*.dts
#export TIMER_HZ=1000000
make freeloader
QEMU_FREELOADER=work/$SOC/freeloader_qemu.elf
cp work/$SOC/freeloader/freeloader.elf $QEMU_FREELOADER
make -j DISK_SIZE=128 gendisk > >(tee build_qemu_disk.log) || {
xz -f -z build_qemu_disk.log
exit 1
}
echo ">>> Reset workaround and source code, and rebuilt freeloader and boot images"
git reset --hard
make genboot
xz -f -z build_qemu_disk.log
unset TIMER_HZ
- |
RUNQEMUSH=work/$SOC/run_qemu.sh
SHOWQEMUSH=work/$SOC/show_qemu.sh
qemucmd=qemu-system-riscv32
if [[ $CORE == *ux* ]] ; then
qemucmd=qemu-system-riscv64
fi
echo "which $qemucmd" > $SHOWQEMUSH
echo "$qemucmd --version" >> $SHOWQEMUSH
echo "$qemucmd -M nuclei_${SOC},download=flashxip -cpu nuclei-${CORE},ext=$ARCH_EXT -smp 8 -m 2g -bios freeloader_qemu.elf -nographic -drive file=disk.img,if=sd,format=raw" > $RUNQEMUSH
chmod +x $RUNQEMUSH
chmod +x $SHOWQEMUSH
- |
if [ "x$SOC" == "xdemosoc" ] ; then
echo ">>Will build xlspike simulation images only for demosoc"
echo ">>Build simulation target for $SOC - $CORE - $BOOT_MODE"
make presim && make -j opensbi_sim > >(tee build_opensbi_payload.log) || {
xz -f -z build_opensbi_payload.log
exit 1
}
cp -f work/${SOC}/opensbi/platform/nuclei/${SOC}/firmware/fw_payload.elf work/${SOC}/fw_payload_xlspike.elf
xz -f -z build_opensbi_payload.log
fi
- |
genbootzip=work/${SOC}/genboot_artifacts_${CI_COMMIT_SHA::8}.zip
echo "Zip all generated boot images and freeloader elfs to ${genbootzip}"
rm -f ${genbootzip}
zip -r ${genbootzip} work/${SOC}/boot.zip work/${SOC}/freeloader/freeloader.elf work/${SOC}/run_qemu.sh work/${SOC}/disk.img work/${SOC}/freeloader_*.elf work/${SOC}/buildstamp.txt work/${SOC}/fw_payload_xlspike.elf
- echo "Please find generated freeloaders in $SHARELOC/$(git describe --always)"
.snippet_run_sdk_in_xlspike: &snippet_run_sdk_in_xlspike
- |
if [ "x$SOC" != "xdemosoc" ] ; then
echo ">>Will not run xlspike simulation for $SOC"
exit 0
fi
# show xlspike help and version
which xl_spike
xl_spike -h
# run xlspike with timeout
timeout --foreground -s SIGKILL 16m xl_spike work/${SOC}/fw_payload_xlspike.elf > >(tee run_xlspike.log) || {
if cat run_xlspike.log | grep "Run /init" ; then echo "Kernel boot successfully" ; else echo "Kernel boot failed" && exit 1; fi;
if cat run_xlspike.log | grep "Welcome to" ; then echo "Pass simulation" && exit 0; else echo "Failed init process" && exit 1; fi;
}
.snippet_run_sdk_in_qemu: &snippet_run_sdk_in_qemu
- echo ">>Run using qemu for $SOC - $CORE - $BOOT_MODE"
- |
#if [ "x$SOC" != "xdemosoc" ] ; then
# echo ">>Will not run qemu simulation for $SOC"
# exit 0
#fi
cd work/$SOC
# show qemu version
bash show_qemu.sh
cat run_qemu.sh
# $(cat run_qemu.sh) is workaround for directly run bash run_qemu.sh
# If do kill it will just kill bash process, the qemu process is not killed
# SIGTERM is better for kill qemu
timeout --foreground -s SIGTERM 3m $(cat run_qemu.sh) > >(tee run_qemu.log) || {
if cat run_qemu.log | grep "Run /init" ; then echo "Kernel boot successfully" ; else echo "Kernel boot failed" && exit 1; fi;
if cat run_qemu.log | grep "Welcome to" ; then echo "Pass simulation" && exit 0; else echo "Failed init process" && exit 1; fi;
}
.job_rules:
interruptible: true
only:
changes:
- conf/**/*
- .github/**/*
- Makefile*
- .gitlab-ci.yml
- buildroot
- opensbi
- freeloader
- linux
- u-boot
tags:
- env::shell
- net::outside
- user::xl_ci
## Job template for build linux sdk
.build_linux_sdk_template: &build_linux_sdk_job_def
extends: .job_rules
artifacts:
name: "bootimages-${SOC}-${CORE}-${BOOT_MODE}-${CI_COMMIT_SHA::8}"
paths:
- work/${SOC}/
- build_*.log.*
expire_in: 2 day
script:
- *snippet_build_sdk
## Job template for run linux in xlspike
.run_linux_sdk_xlspike_template: &run_linux_sdk_xlspike_job_def
extends: .job_rules
script:
- *snippet_run_sdk_in_xlspike
## Job template for run linux in qemu
.run_linux_sdk_qemu_template: &run_linux_sdk_qemu_job_def
extends: .job_rules
script:
- *snippet_run_sdk_in_qemu
## Job template for build linux sdk
.build_run_linux_sdk_template: &build_run_linux_sdk_job_def
<<: *build_linux_sdk_job_def
script:
- *snippet_build_sdk
- *snippet_run_sdk_in_qemu
# Manual job template
.build_linux_sdk_manual_template: &build_linux_sdk_manual_job_def
extends: .job_rules
when: manual
artifacts:
name: "bootimages-${SOC}-${CORE}-${BOOT_MODE}-${CI_COMMIT_SHA::8}"
paths:
- work/${SOC}/freeloader/freeloader.elf
- work/${SOC}/boot.zip
expire_in: 2 day
script:
- export MAKEOPTS="${MAKEOPTS}"
- make preboot
- BUILDBOOTIMAGES=0 bash .github/build_sdk.sh
## Job for build sdk
# Build For ux900 Core, without FPU, flash boot mode
build_ux900_flash:
stage: build
variables:
SOC: "demosoc"
CORE: "ux900"
ARCH_EXT: ""
BOOT_MODE: "flash"
parallel:
matrix:
- SOC: ["demosoc", "evalsoc"]
<<: *build_linux_sdk_job_def
## Job for build sdk
# Build For ux900 Core, without FPU, sd boot mode
build_ux900_sd:
stage: build
variables:
SOC: "demosoc"
CORE: "ux900"
ARCH_EXT: ""
BOOT_MODE: "sd"
parallel:
matrix:
- SOC: ["demosoc", "evalsoc"]
<<: *build_linux_sdk_job_def
# Manual job for ux900 sd
build_ux900_sd_manual:
stage: manual
needs:
- job: build_ux900_sd
variables:
SOC: "evalsoc"
CORE: "ux900"
ARCH_EXT: ""
BOOT_MODE: "sd"
<<: *build_linux_sdk_manual_job_def
# Manual job for ux900 flash
build_ux900_flash_manual:
stage: manual
needs:
- job: build_ux900_flash
variables:
SOC: "evalsoc"
CORE: "ux900"
ARCH_EXT: ""
BOOT_MODE: "flash"
<<: *build_linux_sdk_manual_job_def
release_sources:
extends: .job_rules
stage: build
needs:
- job: build_ux900_flash
script:
- activate_swdev
- make snapshot
- snapshot_zip=($(ls -t1 GENERATED/snapshot/snapshot_*.zip))
- cp -f ${snapshot_zip} linuxsdk_${CI_COMMIT_REF_NAME//\//\_}_${CI_COMMIT_SHA::8}.zip
artifacts:
name: "nuclei_linuxsdk-job${CI_JOB_ID}_${CI_COMMIT_SHA::8}"
paths:
- buildroot/dl
- linuxsdk_*.zip
expire_in: 2 day
## Job for run sim
# Run For ux900 Core, without FPU, flash boot mode
run_ux900_flash_xlspike:
stage: run
dependencies:
- build_ux900_flash
variables:
SOC: "demosoc"
CORE: "ux900"
BOOT_MODE: "flash"
<<: *run_linux_sdk_xlspike_job_def
## Job for run sim
# Run For ux900 Core, without FPU, sd boot mode
run_ux900_sd_xlspike:
stage: run
dependencies:
- build_ux900_sd
variables:
SOC: "demosoc"
CORE: "ux900"
BOOT_MODE: "sd"
<<: *run_linux_sdk_xlspike_job_def
## Job for run qemu
# Run For ux900 Core, without FPU, flash boot mode
run_ux900_flash_qemu:
stage: run
dependencies:
- build_ux900_flash
parallel:
matrix:
- SOC: ["demosoc", "evalsoc"]
variables:
CORE: "ux900"
BOOT_MODE: "flash"
<<: *run_linux_sdk_qemu_job_def
## Job for run qemu
# Run For ux900 Core, without FPU, sd boot mode
run_ux900_sd_qemu:
stage: run
dependencies:
- build_ux900_sd
parallel:
matrix:
- SOC: ["demosoc", "evalsoc"]
variables:
CORE: "ux900"
BOOT_MODE: "sd"
<<: *run_linux_sdk_qemu_job_def
## Job for build sdk
# Build For ux900FD Core, with FPU, flash boot mode
build_ux900fd_flash:
stage: build
dependencies:
variables:
SOC: "demosoc"
CORE: "ux900fd"
ARCH_EXT: ""
BOOT_MODE: "flash"
parallel:
matrix:
- SOC: ["demosoc", "evalsoc"]
<<: *build_linux_sdk_job_def
## Job for build sdk
# Build For ux900FD Core, with FPU, sd boot mode
build_ux900fd_sd:
stage: build
dependencies:
variables:
SOC: "demosoc"
CORE: "ux900fd"
ARCH_EXT: ""
BOOT_MODE: "sd"
parallel:
matrix:
- SOC: ["demosoc", "evalsoc"]
<<: *build_linux_sdk_job_def
# Manual job for ux900fd sd
build_ux900fd_sd_manual:
stage: manual
needs:
- job: build_ux900fd_sd
variables:
SOC: "evalsoc"
CORE: "ux900fd"
ARCH_EXT: ""
BOOT_MODE: "sd"
<<: *build_linux_sdk_manual_job_def
# Manual job for ux900fd flash
build_ux900fd_flash_manual:
stage: manual
needs:
- job: build_ux900fd_flash
variables:
SOC: "evalsoc"
CORE: "ux900fd"
ARCH_EXT: ""
BOOT_MODE: "flash"
<<: *build_linux_sdk_manual_job_def
## Job for run sim
# Run For ux900FD Core, with FPU, flash boot mode
# This ux900fd init process will fail
run_ux900fd_flash_xlspike:
stage: run
allow_failure: true
dependencies:
- build_ux900fd_flash
variables:
SOC: "demosoc"
CORE: "ux900fd"
BOOT_MODE: "flash"
<<: *run_linux_sdk_xlspike_job_def
## Job for run sim
# Run For ux900FD Core, with FPU, sd boot mode
# This ux900fd init process will fail
run_ux900fd_sd_xlspike:
stage: run
allow_failure: true
dependencies:
- build_ux900fd_sd
variables:
SOC: "demosoc"
CORE: "ux900fd"
BOOT_MODE: "sd"
<<: *run_linux_sdk_xlspike_job_def
## Job for run qemu
# Run For ux900FD Core, with FPU, flash boot mode
# This ux900fd init process will fail
run_ux900fd_flash_qemu:
stage: run
allow_failure: true
dependencies:
- build_ux900fd_flash
parallel:
matrix:
- SOC: ["demosoc", "evalsoc"]
variables:
CORE: "ux900fd"
BOOT_MODE: "flash"
<<: *run_linux_sdk_qemu_job_def
## Job for run qemu
# Run For ux900FD Core, with FPU, sd boot mode
# This ux900fd init process will fail
run_ux900fd_sd_qemu:
stage: run
allow_failure: true
dependencies:
- build_ux900fd_sd
parallel:
matrix:
- SOC: ["demosoc", "evalsoc"]
variables:
CORE: "ux900fd"
BOOT_MODE: "sd"
<<: *run_linux_sdk_qemu_job_def
# Build and run for rv32 core
build_run_rv32:
stage: build
variables:
SOC: "evalsoc"
ARCH_EXT: ""
parallel:
matrix:
- CORE: ["u900", "u900fd"]
BOOT_MODE: ["sd", "flash"]
<<: *build_run_linux_sdk_job_def