Skip to content

Commit daf8b29

Browse files
committed
uttls/mkimage.sh: consolidate sdcard.img generation
This commit consolidates mkimage.sh scripts into a unified SD card image creation tool that works for all boards. It needs a bootloader an $ARCH rootfs.squashfs image and a genimage.cfg.in template. - Detects build directories from `O=` environment variable or `output/` - Sources `.config` to discover Buildroot paths - Uses Buildroot's `support/scripts/genimage.sh` when available - Automatically generates `.bmap` files if `bmaptool` is available - Fallback to direct `genimage` invocation if wrapper not found See the online instructions for usage. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 24755e7 commit daf8b29

File tree

8 files changed

+374
-259
lines changed

8 files changed

+374
-259
lines changed

.github/workflows/build-image.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ on:
88
type: choice
99
required: true
1010
options:
11-
- raspberry-pi64
12-
- banana-pi-r3
13-
default: 'raspberry-pi64'
11+
- raspberrypi-rpi64
12+
- bananapi-bpi-r3
13+
- friendlyarm-nanopi-r2s
14+
default: 'raspberrypi-rpi64'
1415
use_latest_release:
1516
description: 'Use latest release artifacts instead of workflow artifacts'
1617
type: boolean
@@ -52,14 +53,18 @@ jobs:
5253
- name: Set bootloader and target based on board
5354
run: |
5455
case "${{ inputs.board }}" in
55-
raspberry-pi64)
56+
raspberrypi-rpi64)
5657
echo "BOOTLOADER=rpi4_boot" >> $GITHUB_ENV
5758
echo "TARGET=aarch64" >> $GITHUB_ENV
5859
;;
59-
banana-pi-r3)
60+
bananapi-bpi-r3)
6061
echo "BOOTLOADER=mt7986_sd_boot" >> $GITHUB_ENV
6162
echo "TARGET=aarch64" >> $GITHUB_ENV
6263
;;
64+
friendlyarm-nanopi-r2s)
65+
echo "BOOTLOADER=nanopi_r2s_boot" >> $GITHUB_ENV
66+
echo "TARGET=aarch64" >> $GITHUB_ENV
67+
;;
6368
*)
6469
echo "Error: Unknown board ${{ inputs.board }}"
6570
exit 1
@@ -144,19 +149,7 @@ jobs:
144149
export BR2_EXTERNAL_INFIX_PATH=$PWD
145150
export RELEASE=""
146151
export INFIX_ID="infix"
147-
148-
# Use the standardized mkimage.sh path for the selected board
149-
# BOARD_SCRIPT="src/board/${{ inputs.board }}/mkimage.sh"
150-
BOARD_SCRIPT="src/board/${{ inputs.board }}/mkimage.sh"
151-
152-
if [ -f "$BOARD_SCRIPT" ]; then
153-
echo "Using board-specific image creation script: $BOARD_SCRIPT"
154-
chmod +x "$BOARD_SCRIPT"
155-
"$BOARD_SCRIPT"
156-
else
157-
echo "Error: Board script $BOARD_SCRIPT not found!"
158-
exit 1
159-
fi
152+
./utils/mkimage.sh ${{ inputs.board }}
160153
161154
- name: Verify created image
162155
run: |
@@ -183,7 +176,7 @@ jobs:
183176
with:
184177
name: sdcard-image-${{ inputs.board }}-${{ env.BOOTLOADER }}
185178
path: |
186-
output/images/*-sdcard.img
179+
output/images/*-sdcard.img*
187180
retention-days: 30
188181

189182
- name: Create checksums
@@ -218,7 +211,7 @@ jobs:
218211
**Artifact Source:** ${{ inputs.use_latest_release && 'Latest Release' || 'Latest Workflow Run' }}
219212
220213
## Created Images
221-
$(find output/images/ -name "*.img" -o -name "*.qcow2" -o -name "*.raw" | xargs ls -lh 2>/dev/null | sed 's/^/- /' || echo "- No images found")
214+
$(find output/images/ -name "*.img*" -o -name "*.qcow2" -o -name "*.raw" | xargs ls -lh 2>/dev/null | sed 's/^/- /' || echo "- No images found")
222215
223216
## Download
224217
The SD card image is available as a workflow artifact above.

board/aarch64/bananapi-bpi-r3/mkimage.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

board/aarch64/friendlyarm-nanopi-r2s/genimage.cfg renamed to board/aarch64/friendlyarm-nanopi-r2s/genimage.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ image var.ext4 {
1919
}
2020
}
2121

22-
image sdcard.img {
22+
image #INFIX_ID##VERSION#-nanopi-r2s-sdcard.img {
2323
hdimage {
2424
partition-table-type = "gpt"
2525
}

board/aarch64/raspberrypi-rpi64/mkimage.sh

Lines changed: 0 additions & 211 deletions
This file was deleted.

configs/mt7986_sd_boot_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="${BR2_EXTERNAL_INFIX_PATH}/board/common/
3131
BR2_TARGET_UBOOT_NEEDS_DTC=y
3232
BR2_TARGET_UBOOT_FORMAT_DTB=y
3333
BR2_TARGET_UBOOT_CUSTOM_DTS_PATH="${BR2_EXTERNAL_INFIX_PATH}/src/board/banana-pi-r3/uboot/*.dtsi"
34+
BR2_PACKAGE_HOST_BMAP_TOOLS=y
3435
BR2_PACKAGE_HOST_GENIMAGE=y
3536
BR2_PACKAGE_HOST_RAUC=y
3637
BR2_PACKAGE_HOST_UBOOT_TOOLS=y

configs/nanopi_r2s_boot_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot.itb"
3737
BR2_TARGET_UBOOT_SPL=y
3838
BR2_TARGET_UBOOT_SPL_NAME="idbloader.img"
3939
BR2_TARGET_UBOOT_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/friendlyarm-nanopi-r2s/uboot/r2s-env.dtsi"
40+
BR2_PACKAGE_HOST_BMAP_TOOLS=y
4041
BR2_PACKAGE_HOST_GENIMAGE=y
4142
BR2_PACKAGE_HOST_RAUC=y
4243
BR2_PACKAGE_HOST_UBOOT_TOOLS=y

configs/rpi4_boot_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ BR2_TARGET_UBOOT_FORMAT_DTB=y
3333
BR2_TARGET_UBOOT_FORMAT_CUSTOM=y
3434
BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="arch/arm/dts/infix-key.dtbo arch/arm/dts/rpi-env.dtbo"
3535
BR2_TARGET_UBOOT_CUSTOM_DTS_PATH="${BR2_EXTERNAL_INFIX_PATH}/src/board/raspberry-pi64/uboot/rpi-env.dtso"
36+
BR2_PACKAGE_HOST_BMAP_TOOLS=y
3637
BR2_PACKAGE_HOST_GENIMAGE=y
3738
BR2_PACKAGE_HOST_RAUC=y
3839
BR2_PACKAGE_HOST_UBOOT_TOOLS=y

0 commit comments

Comments
 (0)