-
Notifications
You must be signed in to change notification settings - Fork 13
182 lines (152 loc) · 7.12 KB
/
Copy pathbuild.yml
File metadata and controls
182 lines (152 loc) · 7.12 KB
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
name: Build Prebuilt u-boot
on:
push:
branches:
- canmv_k230
- action
jobs:
build:
runs-on: ubuntu-24.04
permissions:
contents: write
defaults:
run:
shell: bash
steps:
- name: Setup SSH
run: |
git config --global user.name kendryte747
git config --global user.email kendryte747@gmail.com
mkdir -p ~/.ssh
echo "${{ secrets.ACTIONS_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Prepare Environment
run: |
sudo apt update
sudo apt install -y build-essential bison flex gcc libncurses5-dev \
libssl-dev pkg-config python3 python3-pip python-is-python3 python3-venv curl git
python3 -m venv ~/.canmv_venv
source ~/.canmv_venv/bin/activate
pip3 install pycryptodome gmssl jsonschema jinja2
- name: Install repo tool
run: |
mkdir -p ~/bin
curl -o ~/bin/repo https://storage.googleapis.com/git-repo-downloads/repo
chmod a+x ~/bin/repo
echo "$HOME/bin" >> $GITHUB_PATH
- name: Init repo
run: |
mkdir ${{ github.workspace }}/canmv_k230
cd ${{ github.workspace }}/canmv_k230
repo init -u https://github.com/canmv-k230/manifest \
-b master \
--repo-url=https://github.com/canmv-k230/git-repo.git \
--repo-branch stable
- name: Sync repo
run: |
cd ${{ github.workspace }}/canmv_k230
repo sync -j$(nproc)
- name: Get Git revision and set as environment variable
id: get_revision
run: |
cd ${{ github.workspace }}/canmv_k230/src/uboot/uboot
revision=$(git describe --long --tag --dirty --always)
echo "REVISION=$revision" >> $GITHUB_ENV
- name: Cache RISC-V Toolchain
id: cache-toolchain
uses: actions/cache@v4
with:
path: ~/.kendryte/k230_toolchains/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.0/
key: k230-toolchain-v2.6.0
- name: Download toolchains
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
mkdir -p ~/.kendryte/k230_toolchains
wget -q https://github.com/kendryte/canmv_k230/releases/download/v1.1/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.0.tar.bz2 -O /tmp/toolchain.tar.bz2
tar -xjf /tmp/toolchain.tar.bz2 -C ~/.kendryte/k230_toolchains
ls -alth ~/.kendryte/k230_toolchains
- name: Build Prebuilt u-boot
shell: bash
run: |
cd ${{ github.workspace }}/canmv_k230
mkdir -p ~/artifacts
source ~/.canmv_venv/bin/activate
export SKIP_TOOLCHAIN_CHECK=1
declare -A defconfig_to_board=(
[k230_rtos_aihardware_defconfig]="k230_aihardware"
[k230_canmv_v1p0p1_defconfig]="k230_canmv"
[k230_canmv_01studio_defconfig]="k230_canmv_01studio"
[k230_canmv_dongshanpi_defconfig]="k230_canmv_dongshanpi"
[k230_canmv_gt6700_defconfig]="k230_canmv_gt6700"
[k230_canmv_hiwonder_defconfig]="k230_canmv_hiwonder"
[k230_canmv_lckfb_defconfig]="k230_canmv_lckfb"
[k230_canmv_rtt_evb_defconfig]="k230_canmv_rtt_evb"
[k230_canmv_v3p0_defconfig]="k230_canmv_v3p0"
[k230_canmv_wondermk_defconfig]="k230_canmv_wondermk"
[k230_canmv_yahboom_defconfig]="k230_canmv_yahboom"
[k230_rtos_evb_defconfig]="k230_evb"
[k230_rtos_evb_spinand_defconfig]="k230_evb_spinand"
[k230_canmv_labplus_1956_defconfig]="k230_labplus_1956"
[k230d_canmv_atk_dnk230d_defconfig]="k230d_canmv_atk_dnk230d"
[k230d_canmv_bpi_zero_defconfig]="k230d_canmv_bpi_zero"
[k230d_canmv_junroc_ai_cam_defconfig]="k230d_canmv_junroc_ai_cam"
[k230d_canmv_labplus_ai_camera_defconfig]="k230d_labplus_ai_camera"
)
echo "Defconfigs: ${!defconfig_to_board[@]}"
for UBOOT_DEFCONFIG in "${!defconfig_to_board[@]}"; do
echo "=============================="
echo " Building U-Boot: ${UBOOT_DEFCONFIG}"
echo "=============================="
base_name=${defconfig_to_board[$UBOOT_DEFCONFIG]}
mkdir -p ~/artifacts/${base_name}
make ${UBOOT_DEFCONFIG} || exit $?
# disable prebuilt
sed -i 's/^CONFIG_UBOOT_USE_PREBUILT=y$/CONFIG_UBOOT_USE_PREBUILT=n/' ${{ github.workspace }}/canmv_k230/.config
make -j8 uboot || exit $?
# Also copy artifacts to artifacts folder
cp ${{ github.workspace }}/canmv_k230/output/${UBOOT_DEFCONFIG}/uboot/u-boot.bin ~/artifacts/${base_name}/u-boot.bin || { echo "u-boot.bin missing"; exit $?; }
cp ${{ github.workspace }}/canmv_k230/output/${UBOOT_DEFCONFIG}/uboot/spl/u-boot-spl.bin ~/artifacts/${base_name}/u-boot-spl.bin || { echo "u-boot-spl.bin missing"; exit $?; }
# build fastboot spl
make uboot-clean || exit $?
echo "CONFIG_UBOOT_ENABLE_FAST_BOOT=y" >> ${{ github.workspace }}/canmv_k230/.config
echo "CONFIG_UBOOT_FAST_BOOT_RTSMART=y" >> ${{ github.workspace }}/canmv_k230/.config
# disable prebuilt
sed -i 's/^CONFIG_UBOOT_USE_PREBUILT=y$/CONFIG_UBOOT_USE_PREBUILT=n/' ${{ github.workspace }}/canmv_k230/.config
make -j8 uboot || exit $?
cp ${{ github.workspace }}/canmv_k230/output/${UBOOT_DEFCONFIG}/uboot/spl/u-boot-spl.bin ~/artifacts/${base_name}/u-boot-spl-fastboot.bin || { echo "u-boot-spl-fastboot missing"; exit $?; }
done
tree ~/artifacts
- uses: actions/upload-artifact@v4
if: github.ref != 'refs/heads/dev'
with:
name: "u-boot-prebuilt-${{ env.REVISION }}"
path: ~/artifacts
if-no-files-found: error
compression-level: 0
- name: Install Prebuilt u-boot
if: github.ref != 'refs/heads/dev'
run: |
# Capture the U-Boot commit hash
cd ${{ github.workspace }}/canmv_k230/src/uboot/uboot
UBOOT_COMMIT=$(git rev-parse HEAD)
# Install prebuilt artifacts into canmv_k230/boards
python3 .github/workflows/install_uboot_artifacts.py \
--source ~/artifacts \
--target ${{ github.workspace }}/canmv_k230/boards
# Commit the installed files to CanMV K230 repository
cd ${{ github.workspace }}/canmv_k230
# Ensure we are on the main branch
git checkout main
# Set up Git identity
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add boards
git commit -m "Update prebuilt u-boot from https://github.com/canmv-k230/u-boot/commit/${UBOOT_COMMIT}"
git status
# Push using token-authenticated ssh
git remote set-url github git@github.com:kendryte/k230_rtos_sdk.git
git push github main
- name: Clean up SSH private key
if: always()
run: |
rm -f ~/.ssh/id_rsa