Skip to content

Minimal BPI-R4 test · sd · 24.10 #55

Minimal BPI-R4 test · sd · 24.10

Minimal BPI-R4 test · sd · 24.10 #55

name: BPI-R4-Minimal-MTK-Bootloader-Test
run-name: Minimal BPI-R4 test · ${{ inputs.media }} · ${{ github.ref_name }}
on:
workflow_dispatch:
inputs:
media:
description: "Boot medium to validate (sd or emmc)"
required: false
type: string
default: "sd"
permissions:
contents: read
concurrency:
group: bpi-r4-minimal-${{ github.ref }}-${{ inputs.media }}
cancel-in-progress: false
jobs:
build:
runs-on: self-hosted
env:
seed: BPI-R4-MINIMAL
steps:
- name: Checkout
uses: actions/checkout@v4
with:
clean: false
- name: Cache OpenWrt build directories
uses: actions/cache@v4
with:
path: |
openwrt/dl
openwrt/staging_dir
openwrt/build_dir
# mtk-feed # disabled for now; upstream URL currently 404
bl-mt798x-dhcpd
key: ${{ runner.os }}-openwrt-minimal-${{ hashFiles('SCRIPTS/01_get_ready_minimal.sh', 'SCRIPTS/02_prepare_package_minimal.sh', 'SCRIPTS/BPI-R4/02_target_only_minimal.sh', 'SEED/BPI-R4-MINIMAL/config.seed') }}
restore-keys: |
${{ runner.os }}-openwrt-minimal-
- name: Build with Podman
id: compileopenwrt
continue-on-error: true
env:
INPUT_MEDIA: ${{ inputs.media || 'sd' }}
run: |
CURRENT_UID=$(id -u)
CURRENT_GID=$(id -g)
# Resolve GPT layout based on media
if [ "$INPUT_MEDIA" = "emmc" ]; then
GPT_LAYOUT="bpi-r4-emmc-8g-ab.json"
else
GPT_LAYOUT="bpi-r4-sd-ab.json"
fi
# Write build script to a file to avoid indentation issues
cat > build_script.sh <<'SCRIPT'
set -e
export DEBIAN_FRONTEND=noninteractive
if [ "$(id -u)" = "0" ]; then
export FORCE_UNSAFE_CONFIGURE=1
fi
# 1. Install dependencies
apt-get -o Acquire::Languages=none update -qq
apt-get install -y -qq --no-install-recommends \
asciidoc bash bin86 binutils bison bzip2 clang file flex g++ g++-multilib gawk \
gcc-multilib gettext git curl gzip help2man intltool jq libbpf-dev libelf-dev \
libncurses-dev libssl-dev libthread-queue-any-perl libusb-dev libxml-parser-perl \
make patch perl-modules pkg-config python3-dev python3-pip python3-pyelftools \
python3-setuptools rsync sharutils swig time unzip util-linux wget xsltproc \
xz-utils zlib1g-dev zip zstd dwarves dos2unix npm quilt bc llvm
npm install -g pnpm
pip3 install --user -U pylibfdt --break-system-packages
# 2. Execute scripts
chmod +x SCRIPTS/*.sh
chmod +x SCRIPTS/BPI-R4/*.sh
echo "=== Step 1: Get Ready ==="
bash SCRIPTS/01_get_ready_minimal.sh
echo "=== Step 2: Prepare Package ==="
cd openwrt
bash ../SCRIPTS/02_prepare_package_minimal.sh
bash ../SCRIPTS/BPI-R4/02_target_only_minimal.sh
echo "=== Step 3: Config ==="
cp -rf ../SEED/BPI-R4-MINIMAL/config.seed .config
echo "=== Step 4: Defconfig ==="
make defconfig
echo "=== Step 4b: Narrow bootloader variants for $INPUT_MEDIA ==="
sed -i \
-e '/^CONFIG_PACKAGE_trusted-firmware-a-mt7988-emmc-comb=/d' \
-e '/^CONFIG_PACKAGE_trusted-firmware-a-mt7988-sdmmc-comb=/d' \
-e '/^CONFIG_PACKAGE_trusted-firmware-a-mt7988-spim-nand-ubi-comb=/d' \
-e '/^CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-emmc=/d' \
-e '/^CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-sdmmc=/d' \
-e '/^CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-snand=/d' \
.config
case "$INPUT_MEDIA" in
emmc)
printf '%s\n' \
'# CONFIG_PACKAGE_trusted-firmware-a-mt7988-sdmmc-comb is not set' \
'# CONFIG_PACKAGE_trusted-firmware-a-mt7988-spim-nand-ubi-comb is not set' \
'# CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-sdmmc is not set' \
'# CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-snand is not set' \
'CONFIG_PACKAGE_trusted-firmware-a-mt7988-emmc-comb=y' \
'CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-emmc=y' >> .config
;;
sd|*)
printf '%s\n' \
'# CONFIG_PACKAGE_trusted-firmware-a-mt7988-emmc-comb is not set' \
'# CONFIG_PACKAGE_trusted-firmware-a-mt7988-spim-nand-ubi-comb is not set' \
'# CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-emmc is not set' \
'# CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-snand is not set' \
'CONFIG_PACKAGE_trusted-firmware-a-mt7988-sdmmc-comb=y' \
'CONFIG_PACKAGE_u-boot-mt7988_bananapi_bpi-r4-sdmmc=y' >> .config
;;
esac
echo "=== Step 4c: Final bootloader config ==="
grep -E '^(# )?CONFIG_PACKAGE_(trusted-firmware-a-mt7988|u-boot-mt7988_bananapi_bpi-r4)' .config || true
echo "=== Step 5: Download ==="
make download -j$(nproc)
echo "=== Step 6: Refresh host tar ==="
rm -rf build_dir/host/tar-* \
staging_dir/host/stamp/.tar_installed \
staging_dir/host/bin/tar \
staging_dir/host/share/man/man1/tar.1 \
staging_dir/host/man/man1/tar.1
make -j1 V=sc tools/tar/compile
echo "=== Step 7: Compile ==="
set +e
IGNORE_ERRORS=1 make -j$(nproc)
build_status=$?
set -e
if [ "$build_status" -ne 0 ]; then
echo "================================================================"
echo "=== Debug: Final .config ==="
grep -E '^(# )?CONFIG_PACKAGE_(trusted-firmware-a-mt7988|u-boot-mt7988_bananapi_bpi-r4)' .config || true
echo "================================================================"
echo "=== Debug: Custom ATF mt7988 bl2.mk ==="
sed -n '104,128p' ../bl-mt798x-dhcpd/atf-20260123/plat/mediatek/mt7988/bl2/bl2.mk || true
echo "================================================================"
echo "=== Verbose ATF rebuild ==="
make package/boot/arm-trusted-firmware-mediatek/clean
make package/boot/arm-trusted-firmware-mediatek/compile -j1 V=s || true
echo "================================================================"
echo "=== Verbose world rebuild ==="
make -j1 V=s || true
exit "$build_status"
fi
# 3. Fix permissions
echo "=== Fixing Permissions ==="
if [ "$(id -u)" = "0" ]; then
chown -R $CURRENT_UID:$CURRENT_GID /build || true
fi
SCRIPT
podman run --rm \
-v ${{ github.workspace }}:/build \
-w /build \
-e CURRENT_UID=$CURRENT_UID \
-e CURRENT_GID=$CURRENT_GID \
-e BPI_R4_GPT_LAYOUT=$GPT_LAYOUT \
ubuntu:24.04 \
bash build_script.sh
- name: Fail job if build failed
if: ${{ always() && steps.compileopenwrt.outcome == 'failure' }}
run: exit 1