-
-
Notifications
You must be signed in to change notification settings - Fork 499
179 lines (179 loc) · 11 KB
/
quartz64.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
name: quartz64
on: workflow_dispatch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
defaults:
run:
shell: sh
working-directory: /dev/shm
jobs:
build:
# https://github.com/actions/runner-images
runs-on: ubuntu-22.04
env:
uboot_version: '2023.10'
CROSS_COMPILE: 'aarch64-linux-gnu-'
ARCH: 'arm64'
steps:
# https://github.com/actions/setup-python/tags
- uses: actions/setup-python@v5
with:
python-version: '3.x'
check-latest: true
- name: Build init
run: |
{ python3 -m pip install --no-cache-dir -U pip setuptools wheel; python3 -m pip install --no-cache-dir -U pyelftools; } &
{ sudo apt-get -q update; sudo DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -qq install make gcc libc6-dev flex bison gcc-aarch64-linux-gnu bc libssl-dev swig; } &
{ curl -fLO "https://github.com/u-boot/u-boot/archive/v$uboot_version.tar.gz"; tar xf "v$uboot_version.tar.gz"; rm "v$uboot_version.tar.gz"; } &
{ curl -fO 'https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/snapshot/linux-rolling-stable.tar.gz'; tar xf linux-rolling-stable.tar.gz; rm linux-rolling-stable.tar.gz; } &
wait
curl -sSfo "u-boot-$uboot_version/ddr.bin" 'https://raw.githubusercontent.com/JeffyCN/mirrors/ddf03c1/bin/rk35/rk3568_ddr_1560MHz_v1.13.bin' &
curl -sSfo "u-boot-$uboot_version/bl31.elf" 'https://raw.githubusercontent.com/JeffyCN/mirrors/6186deb/bin/rk35/rk3568_bl31_v1.28.elf' &
curl -sSfo linux-rolling-stable/arch/arm64/configs/quartz64_defconfig "https://raw.githubusercontent.com/$GITHUB_REPOSITORY_OWNER/DietPi/$GITHUB_REF_NAME/.build/images/Quartz64/quartz64_defconfig" &
rm -Rf firmware-quartz64a/DEBIAN firmware-quartz64a/boot/extlinux firmware-quartz64a/lib/firmware/brcm
mkdir -p firmware-quartz64a/DEBIAN firmware-quartz64a/boot/extlinux firmware-quartz64a/lib/firmware/brcm
rm -Rf firmware-quartz64b/DEBIAN firmware-quartz64b/boot/extlinux firmware-quartz64b/lib/firmware/brcm
mkdir -p firmware-quartz64b/DEBIAN firmware-quartz64b/boot/extlinux firmware-quartz64b/lib/firmware/brcm
rm -Rf firmware-soquartz/DEBIAN firmware-soquartz/boot/extlinux firmware-soquartz/lib/firmware/brcm
mkdir -p firmware-soquartz/DEBIAN firmware-soquartz/boot/extlinux firmware-soquartz/lib/firmware/brcm
wait
- name: Build U-Boot
run: |
export ROCKCHIP_TPL='ddr.bin'
export BL31='bl31.elf'
cd "u-boot-$uboot_version"
# Patch kernel_comp_addr_r being too narrow for our kernel image
sed --follow-symlinks -i 's/kernel_comp_addr_r=0x08000000/kernel_comp_addr_r=0x10000000/' include/configs/rk3568_common.h
make quartz64-a-rk3566_defconfig
make -j$(nproc)
mv u-boot-rockchip.bin ../firmware-quartz64a/boot/u-boot.bin
make quartz64-b-rk3566_defconfig
make -j$(nproc)
mv u-boot-rockchip.bin ../firmware-quartz64b/boot/u-boot.bin
make soquartz-cm4-rk3566_defconfig
make -j$(nproc)
mv u-boot-rockchip.bin ../firmware-soquartz/boot/u-boot.bin
cd ..
rm -R "u-boot-$uboot_version"
- name: Build Linux
run: |
cd linux-rolling-stable
make quartz64_defconfig
make -j$(nproc)
cp arch/arm64/boot/Image.gz ../firmware-quartz64a/boot/vmlinuz
cp arch/arm64/boot/Image.gz ../firmware-quartz64b/boot/vmlinuz
mv arch/arm64/boot/Image.gz ../firmware-soquartz/boot/vmlinuz
mv arch/arm64/boot/dts/rockchip/rk3566-quartz64-a.dtb ../firmware-quartz64a/boot/
mv arch/arm64/boot/dts/rockchip/rk3566-quartz64-b.dtb ../firmware-quartz64b/boot/
mv arch/arm64/boot/dts/rockchip/rk3566-soquartz-cm4.dtb ../firmware-soquartz/boot/
make modules_install INSTALL_MOD_PATH='../firmware-quartz64a'
cd ..
rm firmware-quartz64a/lib/modules/*/build
cp -R firmware-quartz64a/lib/modules firmware-quartz64b/lib/
cp -R firmware-quartz64a/lib/modules firmware-soquartz/lib/
- name: Build package
run: |
version=$(mawk '/^VERSION =/{a=$3};/^PATCHLEVEL =/{b=$3};/^SUBLEVEL/{c=$3};END{print a"."b"."c}' linux-rolling-stable/Makefile)
rm -R linux-rolling-stable
curl -sSfO 'https://dietpi.com/downloads/binaries/firmware-quartz64a.deb' &
curl -sSfo firmware-quartz64b/lib/firmware/brcm/brcmfmac43456-sdio.bin 'https://raw.githubusercontent.com/armbian/firmware/master/brcm/brcmfmac43456-sdio.bin' &
curl -sSfo firmware-quartz64b/lib/firmware/brcm/brcmfmac43456-sdio.clm_blob 'https://raw.githubusercontent.com/armbian/firmware/master/brcm/brcmfmac43456-sdio.clm_blob' &
curl -sSfo firmware-quartz64b/lib/firmware/brcm/brcmfmac43456-sdio.clm_blob 'https://raw.githubusercontent.com/armbian/firmware/master/brcm/brcmfmac43456-sdio.txt' &
curl -sSfo firmware-quartz64a/lib/firmware/brcm/brcmfmac43455-sdio.txt 'https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac43455-sdio.AW-CM256SM.txt' &
wait
cur_version=$(dpkg-deb -f firmware-quartz64a.deb Version)
rm firmware-quartz64a.deb
cur_suffix=${cur_version#*-dietpi}
echo "Current package version is: $cur_version"
echo "New kernel version is: $version"
[ "$version-dietpi$cur_suffix" = "$cur_version" ] && version="$version-dietpi$((cur_suffix+1))" || version="$version-dietpi1"
echo "New package version will be: $version"
cp firmware-quartz64a/lib/firmware/brcm/brcmfmac43455-sdio.txt firmware-soquartz/lib/firmware/brcm/
cat << '_EOF_' > firmware-quartz64a/boot/extlinux/extlinux.conf
label DietPi
linux /boot/vmlinuz
fdt /boot/rk3566-quartz64-a.dtb
append root=/dev/mmcblk0p1 rootfstype=ext4 rootwait earlycon=uart8250,mmio32,0xfe660000 console=ttyS2,1500000n8 console=tty1 consoleblank=0 net.ifnames=0
_EOF_
cp firmware-quartz64a/boot/extlinux/extlinux.conf firmware-quartz64b/boot/extlinux/
sed --follow-symlinks -i 's/quartz64-a.dtb/quartz64-b.dtb/' firmware-quartz64b/boot/extlinux/extlinux.conf
cp firmware-quartz64a/boot/extlinux/extlinux.conf firmware-soquartz/boot/extlinux/
sed --follow-symlinks -i 's/quartz64-a.dtb/soquartz-cm4.dtb/' firmware-soquartz/boot/extlinux/extlinux.conf
echo '/boot/extlinux/extlinux.conf' > firmware-quartz64a/DEBIAN/conffiles
echo '/boot/extlinux/extlinux.conf' > firmware-quartz64b/DEBIAN/conffiles
echo '/boot/extlinux/extlinux.conf' > firmware-soquartz/DEBIAN/conffiles
cat << '_EOF_' > firmware-quartz64a/DEBIAN/postinst
#!/bin/dash
echo 'Flashing U-Boot'
BOOT_DRIVE=$(lsblk -npo PKNAME "$(findmnt -Ufnro SOURCE -T /boot)")
if [ $BOOT_DRIVE ]
then
echo "Flashing to detected boot drive: $BOOT_DRIVE"
else
echo 'ERROR: Unable to detect boot drive, aborting U-Boot flashing'
exit 1
fi
dd 'if=/boot/u-boot.bin' "of=$BOOT_DRIVE" seek=64 conv=fdatasync
if grep -q 'root=/dev/mmcblk0p1' /boot/extlinux/extlinux.conf
then
echo 'Setting root filesystem entries in extlinux.conf'
ROOT_PARTUUID=$(findmnt -Ufnro PARTUUID -M /)
if [ $ROOT_PARTUUID ]
then
echo "Setting root filessystem PARTUUID: $ROOT_PARTUUID"
else
echo 'ERROR: Unable to detect root filessystem PARTUUID, aborting'
exit 1
fi
sed --follow-symlinks -i "s|root=/dev/mmcblk0p1|root=PARTUUID=$ROOT_PARTUUID|" /boot/extlinux/extlinux.conf
ROOT_FSTYPE=$(findmnt -Ufnro FSTYPE -M /)
if [ $ROOT_FSTYPE ]
then
echo "Setting root filesystem type: $ROOT_FSTYPE"
else
echo 'ERROR: Unable to detect root filesystem type, aborting'
exit 1
fi
sed --follow-symlinks -i "s|rootfstype=ext4|rootfstype=$ROOT_FSTYPE|" /boot/extlinux/extlinux.conf
fi
exit 0
_EOF_
cp firmware-quartz64a/DEBIAN/postinst firmware-quartz64b/DEBIAN/
cp firmware-quartz64a/DEBIAN/postinst firmware-soquartz/DEBIAN/
chmod +x firmware-*/DEBIAN/postinst
find firmware-quartz64a ! \( -path firmware-quartz64a/DEBIAN -prune \) -type f -exec md5sum {} + | sed 's|firmware-quartz64a/||' > firmware-quartz64a/DEBIAN/md5sums
find firmware-quartz64b ! \( -path firmware-quartz64b/DEBIAN -prune \) -type f -exec md5sum {} + | sed 's|firmware-quartz64b/||' > firmware-quartz64b/DEBIAN/md5sums
find firmware-soquartz ! \( -path firmware-soquartz/DEBIAN -prune \) -type f -exec md5sum {} + | sed 's|firmware-soquartz/||' > firmware-soquartz/DEBIAN/md5sums
cat << _EOF_ > firmware-quartz64a/DEBIAN/control
Package: firmware-quartz64a
Version: $version
Architecture: arm64
Maintainer: MichaIng <micha@dietpi.com>
Date: $(date -u '+%a, %d %b %Y %T %z')
Standards-Version: 4.6.2.0
Installed-Size: $(du -sk 'firmware-quartz64a' | mawk '{print $1}')
Section: kernel
Priority: optional
Description: Linux kernel and U-Boot bootloader for Quartz64 Model A
_EOF_
sed --follow-symlinks -i "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-quartz64a' | mawk '{print $1}')" firmware-quartz64a/DEBIAN/control
cp firmware-quartz64a/DEBIAN/control firmware-quartz64b/DEBIAN/
sed --follow-symlinks -i -e 's/quartz64a/quartz64b/' -e 's/Model A$/Model B/' -e "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-quartz64b' | mawk '{print $1}')" firmware-quartz64b/DEBIAN/control
cp firmware-quartz64a/DEBIAN/control firmware-soquartz/DEBIAN/
sed --follow-symlinks -i -e 's/quartz64a/soquartz/' -e 's/Quartz64 Model A$/SOQuartz/' -e "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-soquartz' | mawk '{print $1}')" firmware-soquartz/DEBIAN/control
sudo chown -R root:root firmware-quartz64a firmware-quartz64b firmware-soquartz
dpkg-deb -b -Zxz -z9 -Sextreme firmware-quartz64a
dpkg-deb -b -Zxz -z9 -Sextreme firmware-quartz64b
dpkg-deb -b -Zxz -z9 -Sextreme firmware-soquartz
sudo rm -R firmware-quartz64a firmware-quartz64b firmware-soquartz
- name: Upload
run: |
[ -d ~/.ssh ] || mkdir ~/.ssh
umask 377
echo '${{ secrets.KNOWN_HOSTS }}' > ~/.ssh/known_hosts
echo '${{ secrets.SSH_KEY }}' > ~/.ssh/id_ed25519
curl -T "firmware-{quartz64a,quartz64b,soquartz}.deb" --key ~/.ssh/id_ed25519 '${{ secrets.UPLOAD_URL }}all/'
curl 'https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/purge_cache' -H 'Authorization: Bearer ${{ secrets.CF_TOKEN }}' -H 'Content-Type: application/json' \
--data '{"files":["https://dietpi.com/downloads/binaries/testing/","https://dietpi.com/downloads/binaries/testing/firmware-quartz64a.deb","https://dietpi.com/downloads/binaries/testing/firmware-quartz64b.deb","https://dietpi.com/downloads/binaries/testing/firmware-soquartz.deb"]}'