Skip to content

Commit a792494

Browse files
committed
workflows: Add weekly U-Boot build for RB1
Resulting binaries are uploaded to fileserver as to be used in image generation jobs. Signed-off-by: Loïc Minier <[email protected]>
1 parent 11f4107 commit a792494

File tree

2 files changed

+178
-0
lines changed

2 files changed

+178
-0
lines changed

.github/workflows/u-boot.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Build U-Boot for RB1
2+
3+
on:
4+
# run on pull requests to the main branch
5+
pull_request:
6+
branches: [main]
7+
# run on pushes to the main branch
8+
push:
9+
branches: [main]
10+
# run weekly on Monday at 8:30am
11+
schedule:
12+
- cron: '30 8 * * 1'
13+
# allow manual runs
14+
workflow_dispatch:
15+
16+
# only need permission to read repository; implicitely set all other
17+
# permissions to none
18+
permissions:
19+
contents: read
20+
21+
env:
22+
# where results will be posted/hosted
23+
FILESERVER_URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app
24+
# github runs are only unique per repository and may also be re-run; create a
25+
# build id for the current run
26+
BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
27+
28+
# cancel in progress builds for this workflow triggered by the same ref
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.ref }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
build-u-boot-rb1:
35+
# TODO test whether this builds on x86 too
36+
# XXX currently missing docker
37+
#runs-on: [self-hosted, x86]
38+
runs-on: [self-hosted, arm64, debbuilder]
39+
container:
40+
image: debian:trixie
41+
volumes:
42+
- /srv/gh-runners/quic-yocto/builds:/fileserver-builds
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
# make sure we have latest packages first, to get latest fixes, to avoid
49+
# an automated update while we're building, and to prevent version skews
50+
- name: Update OS packages
51+
run: |
52+
set -ux
53+
apt update
54+
apt -y upgrade
55+
apt -y full-upgrade
56+
57+
- name: Build U-Boot Android boot image for RB1
58+
run: |
59+
set -ux
60+
# install build-dependencies
61+
apt -y install git crossbuild-essential-arm64 make bison flex bc \
62+
libssl-dev gnutls-dev xxd coreutils gzip mkbootimg
63+
scripts/build-u-boot-rb1.sh
64+
65+
- name: Upload results to fileserver
66+
run: |
67+
set -ux
68+
# curl will be used to talk to fileserver; should be installed by
69+
# default
70+
apt -y install curl
71+
# create directory for results on fileserver
72+
dir="/fileserver-builds/${BUILD_ID}"
73+
mkdir -vp "${dir}"
74+
# copy output files
75+
cp -av \
76+
u-boot/u-boot-nodtb.bin.gz \
77+
u-boot/dts/upstream/src/arm64/qcom/qrb2210-rb1.dtb \
78+
u-boot/u-boot-nodtb.bin.gz-dtb \
79+
u-boot/u-boot.bin \
80+
u-boot/rb1-boot.img \
81+
"${dir}"
82+
# instruct fileserver to publish this directory
83+
url="${FILESERVER_URL}/${BUILD_ID}/"
84+
curl -X POST -H 'Accept: text/event-stream' "${url}"
85+
# create files with directory and URL of these results
86+
echo "${dir}" >u-boot-rb1.dir
87+
echo "${url}" >u-boot-rb1.url
88+
89+
- name: Save URL of build results as an artifact
90+
uses: actions/upload-artifact@v4
91+
with:
92+
path: u-boot-rb1.dir
93+
path: u-boot-rb1.url
94+

scripts/build-u-boot-rb1.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
GIT_REPO="https://github.com/b49020/u-boot"
6+
GIT_BRANCH="qcom-mainline"
7+
CONFIG="qcom_defconfig"
8+
U_BOOT_DEVICE_TREE="qcom/qrb2210-rb1"
9+
ABOOT_BASE_ADDRESS="0x80000000"
10+
ABOOT_PAGE_SIZE="4096"
11+
ABOOT_OUTPUT="rb1-boot.img"
12+
13+
log_i() {
14+
echo "I: $*" >&2
15+
}
16+
17+
fatal() {
18+
echo "F: $*" >&2
19+
exit 1
20+
}
21+
22+
# needed to clone repository
23+
packages="git"
24+
# will pull gcc-aarch64-linux-gnu; should pull a native compiler on arm64 and
25+
# a cross-compiler on other architectures
26+
packages="${packages} crossbuild-essential-arm64"
27+
# u-boot build-dependencies
28+
packages="${packages} make bison flex bc libssl-dev gnutls-dev xxd"
29+
# for nproc
30+
packages="${packages} coreutils"
31+
# needed to pack resulting u-boot binary into an Android boot image
32+
packages="${packages} gzip mkbootimg"
33+
34+
log_i "Checking build-dependencies ($packages)"
35+
missing=""
36+
for pkg in ${packages}; do
37+
# check if package with this name is installed
38+
if dpkg -l "${pkg}" 2>&1 | grep -q "^ii ${pkg}"; then
39+
continue
40+
fi
41+
# otherwise, check if it's a virtual package and if some package providing
42+
# it is installed
43+
providers="$(apt-cache showpkg "${pkg}" |
44+
sed -e '1,/^Reverse Provides: *$/ d' -e 's/ .*$//' |
45+
sort -u)"
46+
provider_found="no"
47+
for provider in ${providers}; do
48+
if dpkg -l "${provider}" 2>&1 | grep -q "^ii ${provider}"; then
49+
provider_found="yes"
50+
break
51+
fi
52+
done
53+
if [ "${provider_found}" = yes ]; then
54+
continue
55+
fi
56+
missing="${missing} ${pkg}"
57+
done
58+
if [ -n "${missing}" ]; then
59+
fatal "Missing build-dependencies: ${missing}"
60+
fi
61+
62+
log_i "Cloning U-Boot (${GIT_REPO}:${GIT_BRANCH})"
63+
git clone --depth=1 --branch "${GIT_BRANCH}" "${GIT_REPO}" u-boot
64+
65+
cd u-boot
66+
67+
log_i "Configuring U-Boot (${CONFIG})"
68+
make "${CONFIG}"
69+
70+
log_i "Building U-Boot (with device tree ${U_BOOT_DEVICE_TREE})"
71+
make -j`nproc` DEVICE_TREE="${U_BOOT_DEVICE_TREE}"
72+
73+
log_i "Creating Android boot image (${ABOOT_OUTPUT})"
74+
gzip u-boot-nodtb.bin
75+
cat u-boot-nodtb.bin.gz \
76+
"dts/upstream/src/arm64/${U_BOOT_DEVICE_TREE}.dtb" \
77+
>u-boot-nodtb.bin.gz-dtb
78+
mkbootimg --base "${ABOOT_BASE_ADDRESS}" \
79+
--pagesize "${ABOOT_PAGE_SIZE}" \
80+
--kernel u-boot-nodtb.bin.gz-dtb \
81+
--cmdline "root=/dev/notreal" \
82+
--ramdisk u-boot.bin \
83+
--output "${ABOOT_OUTPUT}"
84+

0 commit comments

Comments
 (0)