Skip to content

Commit 63192c7

Browse files
committed
Fixup
1 parent 84ef41b commit 63192c7

File tree

3 files changed

+83
-23
lines changed

3 files changed

+83
-23
lines changed

.github/workflows/build-image.yml

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ on:
1414
description: 'Use latest release artifacts instead of workflow artifacts'
1515
type: boolean
1616
default: false
17-
17+
pull_request:
18+
types: [labeled]
1819
jobs:
1920
create-image:
2021
name: Create SD Card Image for ${{ inputs.board }}
2122
runs-on: ubuntu-latest
23+
#runs-on: [ self-hosted, latest ]
2224
steps:
2325
- name: Checkout repository
2426
uses: actions/checkout@v4
2527
with:
2628
clean: true
27-
fetch-depth: 1
29+
fetch-depth: 0
2830
submodules: recursive
2931

3032
- name: Install dependencies
@@ -38,6 +40,8 @@ jobs:
3840
qemu-utils \
3941
dosfstools \
4042
e2fsprogs \
43+
genext2fs \
44+
mtools \
4145
jq
4246
4347
- name: Prepare build environment
@@ -48,7 +52,8 @@ jobs:
4852
4953
- name: Set bootloader and target based on board
5054
run: |
51-
case "${{ inputs.board }}" in
55+
#case "${{ inputs.board }}" in
56+
case "raspberry-pi-4" in
5257
raspberry-pi-4)
5358
echo "BOOTLOADER=rpi4_boot" >> $GITHUB_ENV
5459
echo "TARGET=aarch64" >> $GITHUB_ENV
@@ -64,17 +69,18 @@ jobs:
6469
if: ${{ !inputs.use_latest_release }}
6570
run: |
6671
# Download from latest bootloader build workflow on main branch
67-
gh run list --workflow=build-boot.yml --branch=main --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_boot_run_id
72+
#gh run list --workflow=build-boot.yml --branch=main --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_boot_run_id
73+
gh run list --workflow=build-boot.yml --branch=create-sdcard --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_boot_run_id
6874
BOOT_RUN_ID=$(cat latest_boot_run_id)
69-
75+
7076
gh run download ${BOOT_RUN_ID} --name artifact-${BOOTLOADER} --dir temp_bootloader/
71-
77+
7278
# Extract bootloader directly to output/images
7379
cd temp_bootloader/
7480
tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
7581
cd ../
7682
rm -rf temp_bootloader/
77-
83+
7884
echo "Bootloader files extracted to output/images:"
7985
ls -la output/images/
8086
env:
@@ -83,18 +89,18 @@ jobs:
8389
- name: Download Infix artifacts
8490
if: ${{ !inputs.use_latest_release }}
8591
run: |
86-
# Download from latest Infix build workflow for main branch
87-
gh run list --workflow=build.yml --branch=main --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_infix_run_id
92+
# Download from latest Kernelkit Trigger workflow for main branch
93+
gh run list --workflow=164295764 --branch=main --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_infix_run_id
8894
INFIX_RUN_ID=$(cat latest_infix_run_id)
89-
95+
9096
gh run download ${INFIX_RUN_ID} --name artifact-${TARGET} --dir temp_infix/
91-
97+
9298
# Extract Infix directly to output/images
9399
cd temp_infix/
94100
tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
95101
cd ../
96102
rm -rf temp_infix/
97-
103+
98104
echo "Infix files extracted to output/images:"
99105
ls -la output/images/
100106
env:
@@ -109,14 +115,14 @@ jobs:
109115
tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
110116
cd ../
111117
rm -rf temp_bootloader/
112-
118+
113119
# Download latest Infix release
114120
gh release download latest --pattern "*${TARGET}*" --dir temp_infix/
115121
cd temp_infix/
116122
tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
117123
cd ../
118124
rm -rf temp_infix/
119-
125+
120126
echo "All files extracted to output/images:"
121127
ls -la output/images/
122128
env:
@@ -135,10 +141,13 @@ jobs:
135141
export BINARIES_DIR=$PWD/output/images
136142
export BUILD_DIR=$PWD/build
137143
export BR2_EXTERNAL_INFIX_PATH=$PWD
138-
144+
export RELEASE=""
145+
export INFIX_ID="infix"
146+
139147
# Use the standardized mkimage.sh path for the selected board
140-
BOARD_SCRIPT="src/board/${{ inputs.board }}/mkimage.sh"
141-
148+
# BOARD_SCRIPT="src/board/${{ inputs.board }}/mkimage.sh"
149+
BOARD_SCRIPT="src/board/raspberry-pi-4/mkimage.sh"
150+
142151
if [ -f "$BOARD_SCRIPT" ]; then
143152
echo "Using board-specific image creation script: $BOARD_SCRIPT"
144153
chmod +x "$BOARD_SCRIPT"
@@ -152,7 +161,7 @@ jobs:
152161
run: |
153162
echo "Contents of output/images after mkimage.sh:"
154163
ls -lh output/images/
155-
164+
156165
# Look for SD card image with pattern: *-sdcard.img
157166
if ls output/images/*-sdcard.img 1> /dev/null 2>&1; then
158167
echo "Found SD card image(s):"
@@ -201,15 +210,15 @@ jobs:
201210
run: |
202211
cat <<EOF >> $GITHUB_STEP_SUMMARY
203212
# SD Card Image Build Complete! 🚀
204-
213+
205214
**Board:** ${{ inputs.board }}
206-
**Target:** ${{ env.TARGET }}
215+
**Target:** ${{ env.TARGET }}
207216
**Bootloader:** ${{ env.BOOTLOADER }}
208217
**Artifact Source:** ${{ inputs.use_latest_release && 'Latest Release' || 'Latest Workflow Run' }}
209-
218+
210219
## Created Images
211220
$(find output/images/ -name "*.img" -o -name "*.qcow2" -o -name "*.raw" | xargs ls -lh 2>/dev/null | sed 's/^/- /' || echo "- No images found")
212-
221+
213222
## Download
214223
The SD card image is available as a workflow artifact above.
215-
EOF
224+
EOF

configs/rpi4_boot_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ BR2_PACKAGE_HOST_UBOOT_TOOLS=y
3535
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y
3636
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y
3737
# GNS3_APPLIANCE is not set
38+
SDCARD_AUX=y

src/board/raspberry-pi-4/mkimage.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
set -e
3+
#. "$BR2_CONFIG" 2>/dev/null
4+
5+
BOARD_DIR=$(dirname "$0")
6+
GENIMAGE_CFG="${BUILD_DIR}/genimage.cfg"
7+
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
8+
9+
# Device trees are installed for distro boot (syslinux.conf), but on RPi
10+
# we need them for the SPL, which feeds the TPL (U-Boot) for use instead
11+
# of the (built-in) control DT other platforms use.
12+
#find "${TARGET_DIR}/boot" -type f -name '*.dtb' -exec cp '{}' "${BINARIES_DIR}/" \;
13+
14+
# We've asked U-Boot previously to build overlays for us: Infix signing
15+
# key and our ixboot scripts. Make sure here they are installed in the
16+
# proper directory so genimage can create the DOS partition the SPL
17+
# reads config.txt from.
18+
find "${BINARIES_DIR}" -type f -name '*.dtbo' -exec mv '{}' "${BINARIES_DIR}/rpi-firmware/overlays/" \;
19+
20+
# Create FILES array for the genimage.cfg generation
21+
FILES=""
22+
for f in "${BINARIES_DIR}"/rpi-firmware/*; do
23+
case "$f" in
24+
*~|*.bak) continue ;;
25+
esac
26+
echo "${FILES}" | grep -q `basename $f` && continue # If already exist it has been added by us.
27+
FILES="${FILES}\t\t\t\"${f#"${BINARIES_DIR}/"}\",\n"
28+
done
29+
30+
echo $FILES
31+
KERNEL=$(sed -n 's/^kernel=//p' "${BINARIES_DIR}/rpi-firmware/config.txt")
32+
FILES="${FILES}\t\t\t\"${KERNEL}\""
33+
34+
35+
sed "s|#BOOT_FILES#|${FILES}|" "${BOARD_DIR}/genimage.cfg.in" | \
36+
sed "s|#INFIX_ID#|${INFIX_ID}|" | \
37+
sed "s|#VERSION#|${RELEASE}|" > "${GENIMAGE_CFG}"
38+
39+
40+
ROOTPATH_TMP=$(mktemp -d)
41+
trap 'rm -rf \"$ROOTPATH_TMP\"' EXIT
42+
43+
rm -rf "${GENIMAGE_TMP}"
44+
45+
genimage \
46+
--rootpath "${ROOTPATH_TMP}" \
47+
--tmppath "${GENIMAGE_TMP}" \
48+
--inputpath "${BINARIES_DIR}" \
49+
--outputpath "${BINARIES_DIR}" \
50+
--config "${GENIMAGE_CFG}"

0 commit comments

Comments
 (0)