-
Notifications
You must be signed in to change notification settings - Fork 11
153 lines (140 loc) · 6.39 KB
/
build.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
# This is a basic workflow to help you get started with Actions
name: Build and Test Linux SDK
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the dev_nuclei_next branch
on:
push:
branches: [ dev* ]
paths-ignore:
- README.md
- LICENSE
- .gitlab-ci.yml
- .gitignore
pull_request:
branches: [ dev_nuclei_next ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
name: build for ${{ matrix.soc }} - ${{ matrix.core }} - ${{ matrix.boot_mode }}
runs-on: ubuntu-20.04
strategy:
matrix:
soc: [demosoc, evalsoc]
core: [ux900, ux900fd, u900, u900fd]
boot_mode: [sd, flash]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Linux SDK Code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Tarball source
run: |
base=$(basename $PWD)
cd ..
tar czvf source.tar.gz --exclude-vcs -C $base .
mv source.tar.gz $base/
- name: Upload source
if: matrix.core == 'ux900fd' && matrix.boot_mode == 'sd' && matrix.soc == 'evalsoc'
uses: actions/upload-artifact@v3
with:
name: nuclei_linux_sdk_source
path: source.tar.gz
# continue build on error
continue-on-error: true
- name: Caching packages
uses: actions/cache@v3
with:
path: buildroot/dl
key: build
# Install dependendenc
- name: Install dependencies
run: |
sudo apt-get install build-essential git autotools-dev cmake texinfo bison minicom flex liblz4-tool \
libgmp-dev libmpfr-dev libmpc-dev gawk libz-dev libssl-dev device-tree-compiler libncursesw5-dev libncursesw5 \
python3 python3-pip mtools
sudo pip3 install git-archive-all
mkdir -p buildroot/dl
QEMUVER=2023.10
if [ ! -f buildroot/dl/nuclei-qemu-${QEMUVER}-linux-x64.tar.gz ] ; then
wget --progress=dot -P buildroot/dl https://nucleisys.com/upload/files/toochain/qemu/nuclei-qemu-${QEMUVER}-linux-x64.tar.gz
fi
mkdir -p prebuilt_tools
tar -xzf buildroot/dl/nuclei-qemu-${QEMUVER}-linux-x64.tar.gz -C prebuilt_tools
# Build bootimages
- name: Build bootimages for ${{ matrix.soc }} - ${{ matrix.core }} - ${{ matrix.boot_mode }}
if: ${{ !( matrix.soc == 'demosoc' && startsWith(matrix.core, 'u900')) }}
run: |
export SOC=${{ matrix.soc }} CORE=${{ matrix.core }} BOOT_MODE=${{ matrix.boot_mode }}
echo "Generate QEMU Disk"
#echo ">>> Apply workaround: change TIMERCLK_FREQ from 32768 to 4000000"
#sed -i "s/32768/4000000/" conf/$SOC/*.dts
#export TIMER_HZ=4000000
make genstamp
make freeloader
cp work/$SOC/freeloader/freeloader.elf work/$SOC/freeloader_qemu.elf
make bootimages
make DISK_SIZE=128 gendisk
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
unset TIMER_HZ
echo ">>> Reset workaround and source code"
git reset --hard
echo "Generate freeloader and boot images"
make genboot
# Run on qemu
- name: Run and test on qemu for ${{ matrix.soc }} - ${{ matrix.core }} - ${{ matrix.boot_mode }}
if: ${{ !( matrix.soc == 'demosoc' && startsWith(matrix.core, 'u900')) }}
run: |
QEMU_PATH=$(pwd)/prebuilt_tools/linux_qemu/bin:$(pwd)/prebuilt_tools/qemu/bin
export PATH=${QEMU_PATH}:$PATH
export SOC=${{ matrix.soc }} CORE=${{ matrix.core }} BOOT_MODE=${{ matrix.boot_mode }}
cd work/$SOC
# show qemu version
bash show_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 5m $(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;
}
- name: Upload bootimages for ${{ matrix.soc }} - ${{ matrix.core }} - ${{ matrix.boot_mode }}
if: ${{ !( matrix.soc == 'demosoc' && startsWith(matrix.core, 'u900')) }}
uses: actions/upload-artifact@v3
with:
name: bootimages_${{ matrix.soc }}_${{ matrix.core }}_${{ matrix.boot_mode }}
path: |
work/${{ matrix.soc }}/boot.zip
work/${{ matrix.soc }}/freeloader/freeloader.elf
work/${{ matrix.soc }}/buildstamp.txt
- name: Upload qemu images for ${{ matrix.soc }} - ${{ matrix.core }} - ${{ matrix.boot_mode }}
if: ${{ !( matrix.soc == 'demosoc' && startsWith(matrix.core, 'u900')) }}
uses: actions/upload-artifact@v3
with:
name: qemu_images_${{ matrix.soc }}_${{ matrix.core }}_${{ matrix.boot_mode }}
path: |
work/${{ matrix.soc }}/boot.zip
work/${{ matrix.soc }}/freeloader/freeloader.elf
work/${{ matrix.soc }}/freeloader_qemu.elf
work/${{ matrix.soc }}/buildstamp.txt
work/${{ matrix.soc }}/disk.img
work/${{ matrix.soc }}/*.sh
- name: Upload cached packages
if: matrix.core == 'ux900fd' && matrix.boot_mode == 'sd' && matrix.soc == 'evalsoc'
uses: actions/upload-artifact@v3
with:
name: build_caching
path: |
buildroot/dl