Skip to content

Commit 3fbbd16

Browse files
authored
Merge pull request #1118 from kernelkit/create-sdcard
Create sdcard
2 parents 497990a + 0102932 commit 3fbbd16

File tree

16 files changed

+542
-97
lines changed

16 files changed

+542
-97
lines changed

.github/workflows/build-image.yml

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
name: Create SD Card Images
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
board:
7+
description: 'Board to create image for'
8+
type: choice
9+
required: true
10+
options:
11+
- raspberry-pi-4
12+
default: 'raspberry-pi-4'
13+
use_latest_release:
14+
description: 'Use latest release artifacts instead of workflow artifacts'
15+
type: boolean
16+
default: false
17+
18+
jobs:
19+
create-image:
20+
name: Create SD Card Image for ${{ inputs.board }}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
clean: true
27+
fetch-depth: 0
28+
submodules: recursive
29+
30+
- name: Install dependencies
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y \
34+
genimage \
35+
u-boot-tools \
36+
parted \
37+
gdisk \
38+
qemu-utils \
39+
dosfstools \
40+
e2fsprogs \
41+
genext2fs \
42+
mtools \
43+
jq
44+
45+
- name: Prepare build environment
46+
run: |
47+
# Set up directory structure similar to buildroot build
48+
mkdir -p output/images
49+
mkdir -p build
50+
51+
- name: Set bootloader and target based on board
52+
run: |
53+
case "${{ inputs.board }}" in
54+
raspberry-pi-4)
55+
echo "BOOTLOADER=rpi4_boot" >> $GITHUB_ENV
56+
echo "TARGET=aarch64" >> $GITHUB_ENV
57+
;;
58+
*)
59+
echo "Error: Unknown board ${{ inputs.board }}"
60+
exit 1
61+
;;
62+
esac
63+
echo "Using bootloader: $BOOTLOADER and target: $TARGET for board: ${{ inputs.board }}"
64+
65+
- name: Download bootloader artifacts
66+
if: ${{ !inputs.use_latest_release }}
67+
run: |
68+
# Download from latest bootloader build workflow on main branch
69+
gh run list --workflow=build-boot.yml --branch=main --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_boot_run_id
70+
BOOT_RUN_ID=$(cat latest_boot_run_id)
71+
72+
gh run download ${BOOT_RUN_ID} --name artifact-${BOOTLOADER} --dir temp_bootloader/
73+
74+
# Extract bootloader directly to output/images
75+
cd temp_bootloader/
76+
tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
77+
cd ../
78+
rm -rf temp_bootloader/
79+
80+
echo "Bootloader files extracted to output/images:"
81+
ls -la output/images/
82+
env:
83+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- name: Download Infix artifacts
86+
if: ${{ !inputs.use_latest_release }}
87+
run: |
88+
# Download from latest Kernelkit Trigger workflow for main branch
89+
gh run list --workflow=164295764 --branch=main --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_infix_run_id
90+
INFIX_RUN_ID=$(cat latest_infix_run_id)
91+
92+
gh run download ${INFIX_RUN_ID} --name artifact-${TARGET} --dir temp_infix/
93+
94+
# Extract Infix directly to output/images
95+
cd temp_infix/
96+
tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
97+
cd ../
98+
rm -rf temp_infix/
99+
100+
echo "Infix files extracted to output/images:"
101+
ls -la output/images/
102+
env:
103+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
105+
- name: Download from latest releases
106+
if: ${{ inputs.use_latest_release }}
107+
run: |
108+
# Download latest bootloader release
109+
gh release download latest-boot --pattern "*${BOOTLOADER}*" --dir temp_bootloader/
110+
cd temp_bootloader/
111+
tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
112+
cd ../
113+
rm -rf temp_bootloader/
114+
115+
# Download latest Infix release
116+
gh release download latest --pattern "*${TARGET}*" --dir temp_infix/
117+
cd temp_infix/
118+
tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
119+
cd ../
120+
rm -rf temp_infix/
121+
122+
echo "All files extracted to output/images:"
123+
ls -la output/images/
124+
env:
125+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
127+
- name: Verify extracted files
128+
run: |
129+
echo "Files available for mkimage.sh:"
130+
ls -la output/images/
131+
echo ""
132+
echo "File types:"
133+
file output/images/* || true
134+
135+
- name: Create SD card image
136+
run: |
137+
export BINARIES_DIR=$PWD/output/images
138+
export BUILD_DIR=$PWD/build
139+
export BR2_EXTERNAL_INFIX_PATH=$PWD
140+
export RELEASE=""
141+
export INFIX_ID="infix"
142+
143+
# Use the standardized mkimage.sh path for the selected board
144+
# BOARD_SCRIPT="src/board/${{ inputs.board }}/mkimage.sh"
145+
BOARD_SCRIPT="src/board/raspberry-pi-4/mkimage.sh"
146+
147+
if [ -f "$BOARD_SCRIPT" ]; then
148+
echo "Using board-specific image creation script: $BOARD_SCRIPT"
149+
chmod +x "$BOARD_SCRIPT"
150+
"$BOARD_SCRIPT"
151+
else
152+
echo "Error: Board script $BOARD_SCRIPT not found!"
153+
exit 1
154+
fi
155+
156+
- name: Verify created image
157+
run: |
158+
echo "Contents of output/images after mkimage.sh:"
159+
ls -lh output/images/
160+
161+
# Look for SD card image with pattern: *-sdcard.img
162+
if ls output/images/*-sdcard.img 1> /dev/null 2>&1; then
163+
echo "Found SD card image(s):"
164+
for img in output/images/*-sdcard.img; do
165+
echo "- $(basename $img)"
166+
file "$img"
167+
fdisk -l "$img" 2>/dev/null || true
168+
done
169+
else
170+
echo "No SD card image found matching pattern: *-sdcard.img"
171+
echo "Available files:"
172+
ls -la output/images/
173+
exit 1
174+
fi
175+
176+
- name: Upload SD card image
177+
uses: actions/upload-artifact@v4
178+
with:
179+
name: sdcard-image-${{ inputs.board }}-${{ env.BOOTLOADER }}
180+
path: |
181+
output/images/*-sdcard.img
182+
retention-days: 30
183+
184+
- name: Create checksums
185+
run: |
186+
cd output/images/
187+
for file in *-sdcard.img; do
188+
if [ -f "$file" ]; then
189+
sha256sum "$file" > "$file.sha256"
190+
fi
191+
done
192+
193+
- name: Upload to release
194+
uses: ncipollo/release-action@v1
195+
with:
196+
allowUpdates: true
197+
omitName: true
198+
omitBody: true
199+
omitBodyDuringUpdate: true
200+
prerelease: true
201+
tag: "latest-boot"
202+
token: ${{ secrets.GITHUB_TOKEN }}
203+
artifacts: "output/images/*-sdcard.img*"
204+
205+
- name: Generate summary
206+
run: |
207+
cat <<EOF >> $GITHUB_STEP_SUMMARY
208+
# SD Card Image Build Complete! 🚀
209+
210+
**Board:** ${{ inputs.board }}
211+
**Target:** ${{ env.TARGET }}
212+
**Bootloader:** ${{ env.BOOTLOADER }}
213+
**Artifact Source:** ${{ inputs.use_latest_release && 'Latest Release' || 'Latest Workflow Run' }}
214+
215+
## Created Images
216+
$(find output/images/ -name "*.img" -o -name "*.qcow2" -o -name "*.raw" | xargs ls -lh 2>/dev/null | sed 's/^/- /' || echo "- No images found")
217+
218+
## Download
219+
The SD card image is available as a workflow artifact above.
220+
EOF

board/common/uboot/splash.bmp

1.1 MB
Binary file not shown.

configs/rpi4_boot_defconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ BR2_SYSTEM_BIN_SH_NONE=y
1414
BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh"
1515
# BR2_PACKAGE_BUSYBOX is not set
1616
BR2_PACKAGE_RPI_FIRMWARE=y
17+
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y
18+
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4_X=y
1719
BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="${BR2_EXTERNAL_INFIX_PATH}/src/board/raspberry-pi-4/config.txt"
1820
BR2_PACKAGE_RPI_FIRMWARE_CMDLINE_FILE="${BR2_EXTERNAL_INFIX_PATH}/src/board/raspberry-pi-4/cmdline.txt"
1921
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
@@ -34,4 +36,5 @@ BR2_PACKAGE_HOST_RAUC=y
3436
BR2_PACKAGE_HOST_UBOOT_TOOLS=y
3537
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y
3638
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y
39+
BR2_PACKAGE_BOOTLOADER_SPLASHSCREEN=y
3740
# GNS3_APPLIANCE is not set

package/Config.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ source "$BR2_EXTERNAL_INFIX_PATH/package/rousette/Config.in"
4242
source "$BR2_EXTERNAL_INFIX_PATH/package/nghttp2-asio/Config.in"
4343
source "$BR2_EXTERNAL_INFIX_PATH/package/date-cpp/Config.in"
4444
source "$BR2_EXTERNAL_INFIX_PATH/package/rauc-installation-status/Config.in"
45+
source "$BR2_EXTERNAL_INFIX_PATH/package/bootloader-splashscreen/Config.in"
4546
endmenu

package/board/raspberry-pi-4/Config.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
config BR2_PACKAGE_RASPBERRY_PI_4
22
bool "Raspberry Pi 4"
33
depends on BR2_aarch64
4+
select SDCARD_AUX
45
select BR2_PACKAGE_FEATURE_WIFI
56
select BR2_PACKAGE_BRCMFMAC_SDIO_FIRMWARE_RPI
67
select BR2_PACKAGE_BRCMFMAC_SDIO_FIRMWARE_RPI_WIFI
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
config BR2_PACKAGE_BOOTLOADER_SPLASHSCREEN
2+
bool "bootloader-splashscreen"
3+
help
4+
Install a BMP splash screen image for bootloader.
5+
6+
config BR2_PACKAGE_BOOTLOADER_SPLASHSCREEN_PATH
7+
string "Path to BMP image"
8+
default "$(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/splash.bmp"
9+
depends on BR2_PACKAGE_BOOTLOADER_SPLASHSCREEN
10+
help
11+
Path to the BMP image file to be used as bootloader splash screen.
12+
The image will be installed to output/images/.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
################################################################################
2+
#
3+
# bootloader-splashscreen
4+
#
5+
################################################################################
6+
7+
BOOTLOADER_SPLASHSCREEN_VERSION = 1.0
8+
BOOTLOADER_SPLASHSCREEN_SOURCE =
9+
BOOTLOADER_SPLASHSCREEN_SITE =
10+
11+
define BOOTLOADER_SPLASHSCREEN_BUILD_CMDS
12+
# Nothing to build
13+
endef
14+
15+
define BOOTLOADER_SPLASHSCREEN_INSTALL_TARGET_CMDS
16+
$(INSTALL) -D -m 0644 $(call qstrip,$(BR2_PACKAGE_BOOTLOADER_SPLASHSCREEN_PATH)) $(BINARIES_DIR)/splash.bmp
17+
endef
18+
19+
$(eval $(generic-package))
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From 989ef8436df2ee48d308981098c44b1b8257c23b Mon Sep 17 00:00:00 2001
2+
From: Tobias Waldekranz <[email protected]>
3+
Date: Mon, 10 Jun 2024 13:25:31 +0200
4+
Subject: [PATCH 8/8] hush: Remove Ctrl-C detection in loops
5+
Organization: Addiva Elektronik
6+
7+
Assume that the original intent was to emulate SIGINT to a shell. This
8+
only works as expected if the loop in question is the ouermost, and
9+
last, statement. In all other cases, it completely breaks the expected
10+
execution flow. It more or less resurrects Visual Basic's "On Error
11+
Resume Next".
12+
13+
Disable this behavior and delegate the problem of loop termination to
14+
the writer of the script instead.
15+
16+
Signed-off-by: Tobias Waldekranz <[email protected]>
17+
---
18+
common/cli_hush.c | 7 -------
19+
1 file changed, 7 deletions(-)
20+
21+
diff --git a/common/cli_hush.c b/common/cli_hush.c
22+
index 171069f5f4..d6d487893f 100644
23+
--- a/common/cli_hush.c
24+
+++ b/common/cli_hush.c
25+
@@ -1796,13 +1796,6 @@ static int run_list_real(struct pipe *pi)
26+
for (; pi; pi = (flag_restore != 0) ? rpipe : pi->next) {
27+
if (pi->r_mode == RES_WHILE || pi->r_mode == RES_UNTIL ||
28+
pi->r_mode == RES_FOR) {
29+
-#ifdef __U_BOOT__
30+
- /* check Ctrl-C */
31+
- ctrlc();
32+
- if ((had_ctrlc())) {
33+
- return 1;
34+
- }
35+
-#endif
36+
flag_restore = 0;
37+
if (!rpipe) {
38+
flag_rep = 0;
39+
--
40+
2.34.1
41+

0 commit comments

Comments
 (0)