Skip to content

Commit 72b724a

Browse files
committed
not recreate the flash.img on every build
1 parent ea32c07 commit 72b724a

File tree

4 files changed

+57
-12
lines changed

4 files changed

+57
-12
lines changed

.github/workflows/build_and_push.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: Build and Upload
22

33
on:
44
workflow_dispatch: # This allows you to manually trigger the workflow
5+
inputs:
6+
reflash_bootloader:
7+
description: 'Regenerate flash.img bootloader (WARNING: use only for testing new bootloader)'
8+
required: false
9+
default: 'no'
10+
type: choice
11+
options:
12+
- 'no'
13+
- 'yes'
514

615
jobs:
716
build-and-upload:
@@ -25,6 +34,8 @@ jobs:
2534
python-version: '3.x' # Set up the Python version you need
2635

2736
- name: Run build script
37+
env:
38+
REFLASH_BOOTLOADER: ${{ github.event.inputs.reflash_bootloader || 'no' }}
2839
run: |
2940
chmod +x ./build_image.sh
3041
bash ./build_image.sh desktop

.github/workflows/build_and_push_minimal.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: Build and Upload Minimal Image
22

33
on:
44
workflow_dispatch: # This allows you to manually trigger the workflow
5+
inputs:
6+
reflash_bootloader:
7+
description: 'Regenerate flash.img bootloader (WARNING: use only for testing new bootloader)'
8+
required: false
9+
default: 'no'
10+
type: choice
11+
options:
12+
- 'no'
13+
- 'yes'
514
release:
615
types: [published] # This triggers the workflow when a release is published
716

@@ -59,6 +68,8 @@ jobs:
5968
fi
6069
6170
- name: Run build script
71+
env:
72+
REFLASH_BOOTLOADER: ${{ github.event.inputs.reflash_bootloader || 'no' }}
6273
run: |
6374
chmod +x ./build_image.sh
6475
bash ./build_image.sh server

build_image.sh

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ BUILD_PATH=$DIR/build
77
ARMBIAN_PATH=$BUILD_PATH/armbian-build
88
ARMBIAN_IMAGE_PATH=$ARMBIAN_PATH/output/images
99
BOOTLOADER_IMAGE_PATH=$ARMBIAN_PATH/cache/sources/u-boot-worktree/u-boot-rockchip64/next-dev-v2024.03/
10+
11+
# Pre-tested flash.img location (SPINOR bootloader)
12+
# Using pre-tested bootloader by default to prevent bricking devices
13+
PRETESTED_FLASH_IMG=$DIR/userpatches/flash/flash.img
14+
15+
# Set REFLASH_BOOTLOADER=yes to regenerate flash.img from build instead of using pre-tested
16+
: ${REFLASH_BOOTLOADER:=no}
1017
########################################################
1118
Main() {
1219

@@ -147,19 +154,35 @@ CreateUsbFlashUpdate()
147154
{
148155
echo "Create USB Flash Update files"
149156

150-
echo "copy bootloader to output folder"
151-
# Find rkspi_loader.img dynamically as u-boot version path varies between Armbian releases
152-
RKSPI_LOADER=$(find $BOOTLOADER_IMAGE_PATH -name "rkspi_loader.img" -type f 2>/dev/null | head -n 1)
153-
if [ -z "$RKSPI_LOADER" ]; then
154-
echo "Warning: rkspi_loader.img not found in $BOOTLOADER_IMAGE_PATH"
155-
echo "Searching in alternative locations..."
156-
RKSPI_LOADER=$(find $ARMBIAN_PATH/cache/sources -name "rkspi_loader.img" -type f 2>/dev/null | head -n 1)
157-
fi
158-
if [ -n "$RKSPI_LOADER" ]; then
159-
cp "$RKSPI_LOADER" $BUILD_PATH/flash.img
157+
echo "Preparing bootloader (flash.img)..."
158+
159+
if [ "$REFLASH_BOOTLOADER" = "yes" ]; then
160+
echo "REFLASH_BOOTLOADER=yes: Generating NEW flash.img from build"
161+
echo "WARNING: This is a new bootloader - test carefully before deploying!"
162+
# Find rkspi_loader.img dynamically as u-boot version path varies between Armbian releases
163+
RKSPI_LOADER=$(find $BOOTLOADER_IMAGE_PATH -name "rkspi_loader.img" -type f 2>/dev/null | head -n 1)
164+
if [ -z "$RKSPI_LOADER" ]; then
165+
echo "Warning: rkspi_loader.img not found in $BOOTLOADER_IMAGE_PATH"
166+
echo "Searching in alternative locations..."
167+
RKSPI_LOADER=$(find $ARMBIAN_PATH/cache/sources -name "rkspi_loader.img" -type f 2>/dev/null | head -n 1)
168+
fi
169+
if [ -n "$RKSPI_LOADER" ]; then
170+
cp "$RKSPI_LOADER" $BUILD_PATH/flash.img
171+
echo "New flash.img created from: $RKSPI_LOADER"
172+
else
173+
echo "Error: Could not find rkspi_loader.img"
174+
exit 1
175+
fi
160176
else
161-
echo "Error: Could not find rkspi_loader.img"
162-
exit 1
177+
echo "Using pre-tested flash.img (default safe mode)"
178+
if [ -f "$PRETESTED_FLASH_IMG" ]; then
179+
cp "$PRETESTED_FLASH_IMG" $BUILD_PATH/flash.img
180+
echo "Copied pre-tested flash.img from: $PRETESTED_FLASH_IMG"
181+
else
182+
echo "Error: Pre-tested flash.img not found at $PRETESTED_FLASH_IMG"
183+
echo "Either place a tested flash.img there or set REFLASH_BOOTLOADER=yes to generate new one"
184+
exit 1
185+
fi
163186
fi
164187

165188
echo "Split update file to 1GB parts"

userpatches/flash/flash.img

16 MB
Binary file not shown.

0 commit comments

Comments
 (0)