1- name : Create SD Card Images
1+ name : Create SD Card & eMMC Images
22
33on :
44 workflow_dispatch :
@@ -56,21 +56,33 @@ jobs:
5656 raspberrypi-rpi64)
5757 echo "BOOTLOADER=rpi64_boot" >> $GITHUB_ENV
5858 echo "TARGET=aarch64" >> $GITHUB_ENV
59+ echo "BUILD_EMMC=false" >> $GITHUB_ENV
5960 ;;
6061 bananapi-bpi-r3)
61- echo "BOOTLOADER=bpi_r3_boot" >> $GITHUB_ENV
62+ echo "BOOTLOADER_SD=bpi_r3_sd_boot" >> $GITHUB_ENV
63+ echo "BOOTLOADER_EMMC=bpi_r3_emmc_boot" >> $GITHUB_ENV
6264 echo "TARGET=aarch64" >> $GITHUB_ENV
65+ echo "BUILD_EMMC=true" >> $GITHUB_ENV
6366 ;;
6467 friendlyarm-nanopi-r2s)
6568 echo "BOOTLOADER=nanopi_r2s_boot" >> $GITHUB_ENV
6669 echo "TARGET=aarch64" >> $GITHUB_ENV
70+ echo "BUILD_EMMC=false" >> $GITHUB_ENV
6771 ;;
6872 *)
6973 echo "Error: Unknown board ${{ inputs.board }}"
7074 exit 1
7175 ;;
7276 esac
73- echo "Using bootloader: $BOOTLOADER and target: $TARGET for board: ${{ inputs.board }}"
77+ echo "Target: $TARGET for board: ${{ inputs.board }}"
78+ if [ "$BUILD_EMMC" = "true" ]; then
79+ echo "Building both SD and eMMC images"
80+ echo "SD Bootloader: $BOOTLOADER_SD"
81+ echo "eMMC Bootloader: $BOOTLOADER_EMMC"
82+ else
83+ echo "Building SD image only"
84+ echo "Bootloader: $BOOTLOADER"
85+ fi
7486
7587 - name : Download bootloader artifacts
7688 if : ${{ !inputs.use_latest_release }}
@@ -79,16 +91,41 @@ jobs:
7991 gh run list --workflow=build-boot.yml --branch=main --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_boot_run_id
8092 BOOT_RUN_ID=$(cat latest_boot_run_id)
8193
82- gh run download ${BOOT_RUN_ID} --name artifact-${BOOTLOADER} --dir temp_bootloader/
94+ if [ "$BUILD_EMMC" = "true" ]; then
95+ # Download both SD and eMMC bootloaders for boards that support both
96+ echo "Downloading SD bootloader: ${BOOTLOADER_SD}"
97+ gh run download ${BOOT_RUN_ID} --name artifact-${BOOTLOADER_SD} --dir temp_bootloader_sd/
98+ mkdir -p output_sd/images
99+ cd temp_bootloader_sd/
100+ tar -xzf *.tar.gz --strip-components=1 -C ../output_sd/images/
101+ cd ../
102+ rm -rf temp_bootloader_sd/
103+
104+ echo "Downloading eMMC bootloader: ${BOOTLOADER_EMMC}"
105+ gh run download ${BOOT_RUN_ID} --name artifact-${BOOTLOADER_EMMC} --dir temp_bootloader_emmc/
106+ mkdir -p output_emmc/images
107+ cd temp_bootloader_emmc/
108+ tar -xzf *.tar.gz --strip-components=1 -C ../output_emmc/images/
109+ cd ../
110+ rm -rf temp_bootloader_emmc/
83111
84- # Extract bootloader directly to output/images
85- cd temp_bootloader/
86- tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
87- cd ../
88- rm -rf temp_bootloader/
112+ echo "SD bootloader files:"
113+ ls -la output_sd/images/
114+ echo "eMMC bootloader files:"
115+ ls -la output_emmc/images/
116+ else
117+ # Single bootloader for boards that only support SD
118+ gh run download ${BOOT_RUN_ID} --name artifact-${BOOTLOADER} --dir temp_bootloader/
119+
120+ # Extract bootloader directly to output/images
121+ cd temp_bootloader/
122+ tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
123+ cd ../
124+ rm -rf temp_bootloader/
89125
90- echo "Bootloader files extracted to output/images:"
91- ls -la output/images/
126+ echo "Bootloader files extracted to output/images:"
127+ ls -la output/images/
128+ fi
92129 env :
93130 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
94131
@@ -99,90 +136,193 @@ jobs:
99136 gh run list --workflow=164295764 --branch=main --limit=1 --status=success --json databaseId --jq '.[0].databaseId' > latest_infix_run_id
100137 INFIX_RUN_ID=$(cat latest_infix_run_id)
101138
102- gh run download ${INFIX_RUN_ID} --name artifact-${TARGET} --dir temp_infix/
139+ if [ "$BUILD_EMMC" = "true" ]; then
140+ # Copy Infix artifacts to both SD and eMMC output directories
141+ gh run download ${INFIX_RUN_ID} --name artifact-${TARGET} --dir temp_infix/
142+
143+ cd temp_infix/
144+ tar -xzf *.tar.gz --strip-components=1 -C ../output_sd/images/
145+ tar -xzf *.tar.gz --strip-components=1 -C ../output_emmc/images/
146+ cd ../
147+ rm -rf temp_infix/
148+
149+ echo "Infix files extracted to output_sd/images:"
150+ ls -la output_sd/images/
151+ echo "Infix files extracted to output_emmc/images:"
152+ ls -la output_emmc/images/
153+ else
154+ # Single output directory for SD-only boards
155+ gh run download ${INFIX_RUN_ID} --name artifact-${TARGET} --dir temp_infix/
103156
104- # Extract Infix directly to output/images
105- cd temp_infix/
106- tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
107- cd ../
108- rm -rf temp_infix/
157+ # Extract Infix directly to output/images
158+ cd temp_infix/
159+ tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
160+ cd ../
161+ rm -rf temp_infix/
109162
110- echo "Infix files extracted to output/images:"
111- ls -la output/images/
163+ echo "Infix files extracted to output/images:"
164+ ls -la output/images/
165+ fi
112166 env :
113167 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
114168
115169 - name : Download from latest releases
116170 if : ${{ inputs.use_latest_release }}
117171 run : |
118- # Download latest bootloader release
119- gh release download latest-boot --pattern "*${BOOTLOADER}*" --dir temp_bootloader/
120- cd temp_bootloader/
121- tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
122- cd ../
123- rm -rf temp_bootloader/
124-
125- # Download latest Infix release
126- gh release download latest --pattern "*${TARGET}*" --dir temp_infix/
127- cd temp_infix/
128- tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
129- cd ../
130- rm -rf temp_infix/
131-
132- echo "All files extracted to output/images:"
133- ls -la output/images/
172+ if [ "$BUILD_EMMC" = "true" ]; then
173+ # Download both SD and eMMC bootloaders
174+ gh release download latest-boot --pattern "*${BOOTLOADER_SD}*" --dir temp_bootloader_sd/
175+ mkdir -p output_sd/images
176+ cd temp_bootloader_sd/
177+ tar -xzf *.tar.gz --strip-components=1 -C ../output_sd/images/
178+ cd ../
179+ rm -rf temp_bootloader_sd/
180+
181+ gh release download latest-boot --pattern "*${BOOTLOADER_EMMC}*" --dir temp_bootloader_emmc/
182+ mkdir -p output_emmc/images
183+ cd temp_bootloader_emmc/
184+ tar -xzf *.tar.gz --strip-components=1 -C ../output_emmc/images/
185+ cd ../
186+ rm -rf temp_bootloader_emmc/
187+
188+ # Download Infix once and extract to both directories
189+ gh release download latest --pattern "*${TARGET}*" --dir temp_infix/
190+ cd temp_infix/
191+ tar -xzf *.tar.gz --strip-components=1 -C ../output_sd/images/
192+ tar -xzf *.tar.gz --strip-components=1 -C ../output_emmc/images/
193+ cd ../
194+ rm -rf temp_infix/
195+
196+ echo "SD files extracted to output_sd/images:"
197+ ls -la output_sd/images/
198+ echo "eMMC files extracted to output_emmc/images:"
199+ ls -la output_emmc/images/
200+ else
201+ # Download latest bootloader release
202+ gh release download latest-boot --pattern "*${BOOTLOADER}*" --dir temp_bootloader/
203+ cd temp_bootloader/
204+ tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
205+ cd ../
206+ rm -rf temp_bootloader/
207+
208+ # Download latest Infix release
209+ gh release download latest --pattern "*${TARGET}*" --dir temp_infix/
210+ cd temp_infix/
211+ tar -xzf *.tar.gz --strip-components=1 -C ../output/images/
212+ cd ../
213+ rm -rf temp_infix/
214+
215+ echo "All files extracted to output/images:"
216+ ls -la output/images/
217+ fi
134218 env :
135219 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
136220
137221 - name : Verify extracted files
138222 run : |
139- echo "Files available for mkimage.sh:"
140- ls -la output/images/
141- echo ""
142- echo "File types:"
143- file output/images/* || true
223+ if [ "$BUILD_EMMC" = "true" ]; then
224+ echo "Files available for SD image:"
225+ ls -la output_sd/images/
226+ echo ""
227+ echo "Files available for eMMC image:"
228+ ls -la output_emmc/images/
229+ else
230+ echo "Files available for mkimage.sh:"
231+ ls -la output/images/
232+ echo ""
233+ echo "File types:"
234+ file output/images/* || true
235+ fi
144236
145237 - name : Create SD card image
146238 run : |
147- export BINARIES_DIR=$PWD/output/images
239+ if [ "$BUILD_EMMC" = "true" ]; then
240+ export BINARIES_DIR=$PWD/output_sd/images
241+ export BUILD_DIR=$PWD/build
242+ export BR2_EXTERNAL_INFIX_PATH=$PWD
243+ export RELEASE=""
244+ export INFIX_ID="infix"
245+ ./utils/mkimage.sh -t sdcard ${{ inputs.board }}
246+ else
247+ export BINARIES_DIR=$PWD/output/images
248+ export BUILD_DIR=$PWD/build
249+ export BR2_EXTERNAL_INFIX_PATH=$PWD
250+ export RELEASE=""
251+ export INFIX_ID="infix"
252+ ./utils/mkimage.sh ${{ inputs.board }}
253+ fi
254+
255+ - name : Create eMMC image
256+ if : ${{ env.BUILD_EMMC == 'true' }}
257+ run : |
258+ export BINARIES_DIR=$PWD/output_emmc/images
148259 export BUILD_DIR=$PWD/build
149260 export BR2_EXTERNAL_INFIX_PATH=$PWD
150261 export RELEASE=""
151262 export INFIX_ID="infix"
152- ./utils/mkimage.sh ${{ inputs.board }}
263+ ./utils/mkimage.sh -t emmc ${{ inputs.board }}
153264
154- - name : Verify created image
265+ - name : Verify created images
155266 run : |
156- echo "Contents of output/images after mkimage.sh:"
157- ls -lh output/images/
158-
159- # Look for SD card image with pattern: *-sdcard.img
160- if ls output/images/*-sdcard.img 1> /dev/null 2>&1; then
161- echo "Found SD card image(s):"
162- for img in output/images/*-sdcard.img; do
163- echo "- $(basename $img)"
164- file "$img"
165- fdisk -l "$img" 2>/dev/null || true
166- done
267+ if [ "$BUILD_EMMC" = "true" ]; then
268+ echo "SD card image:"
269+ ls -lh output_sd/images/*-sdcard.img* 2>/dev/null || true
270+ if ls output_sd/images/*-sdcard.img 1> /dev/null 2>&1; then
271+ for img in output_sd/images/*-sdcard.img; do
272+ echo "- $(basename $img)"
273+ file "$img"
274+ fdisk -l "$img" 2>/dev/null | head -20
275+ done
276+ fi
277+
278+ echo ""
279+ echo "eMMC image:"
280+ ls -lh output_emmc/images/*-emmc.img* 2>/dev/null || true
281+ if ls output_emmc/images/*-emmc.img 1> /dev/null 2>&1; then
282+ for img in output_emmc/images/*-emmc.img; do
283+ echo "- $(basename $img)"
284+ file "$img"
285+ fdisk -l "$img" 2>/dev/null | head -20
286+ done
287+ fi
288+
289+ # Copy both images to output/images for artifact upload
290+ mkdir -p output/images
291+ cp output_sd/images/*-sdcard.img* output/images/ 2>/dev/null || true
292+ cp output_emmc/images/*-emmc.img* output/images/ 2>/dev/null || true
167293 else
168- echo "No SD card image found matching pattern: *-sdcard.img"
169- echo "Available files:"
170- ls -la output/images/
171- exit 1
294+ echo "Contents of output/images after mkimage.sh:"
295+ ls -lh output/images/
296+
297+ # Look for SD card image with pattern: *-sdcard.img
298+ if ls output/images/*-sdcard.img 1> /dev/null 2>&1; then
299+ echo "Found SD card image(s):"
300+ for img in output/images/*-sdcard.img; do
301+ echo "- $(basename $img)"
302+ file "$img"
303+ fdisk -l "$img" 2>/dev/null || true
304+ done
305+ else
306+ echo "No SD card image found matching pattern: *-sdcard.img"
307+ echo "Available files:"
308+ ls -la output/images/
309+ exit 1
310+ fi
172311 fi
173312
174- - name : Upload SD card image
313+ - name : Upload images as artifacts
175314 uses : actions/upload-artifact@v4
176315 with :
177- name : sdcard-image- ${{ inputs.board }}-${{ env.BOOTLOADER }}
316+ name : images- ${{ inputs.board }}
178317 path : |
179318 output/images/*-sdcard.img*
319+ output/images/*-emmc.img*
180320 retention-days : 30
181321
182322 - name : Create checksums
183323 run : |
184324 cd output/images/
185- for file in *-sdcard.img; do
325+ for file in *-sdcard.img *-emmc.img ; do
186326 if [ -f "$file" ]; then
187327 sha256sum "$file" > "$file.sha256"
188328 fi
@@ -198,11 +338,28 @@ jobs:
198338 prerelease : true
199339 tag : " latest-boot"
200340 token : ${{ secrets.GITHUB_TOKEN }}
201- artifacts : " output/images/*-sdcard.img*"
341+ artifacts : " output/images/*-sdcard.img*,output/images/*-emmc.img* "
202342
203343 - name : Generate summary
204344 run : |
205- cat <<EOF >> $GITHUB_STEP_SUMMARY
345+ if [ "$BUILD_EMMC" = "true" ]; then
346+ cat <<EOF >> $GITHUB_STEP_SUMMARY
347+ # SD Card & eMMC Image Build Complete! 🚀
348+
349+ **Board:** ${{ inputs.board }}
350+ **Target:** ${{ env.TARGET }}
351+ **SD Bootloader:** ${{ env.BOOTLOADER_SD }}
352+ **eMMC Bootloader:** ${{ env.BOOTLOADER_EMMC }}
353+ **Artifact Source:** ${{ inputs.use_latest_release && 'Latest Release' || 'Latest Workflow Run' }}
354+
355+ ## Created Images
356+ $(find output/images/ -name "*.img" -o -name "*.img.bmap" | xargs ls -lh 2>/dev/null | awk '{print "- " $9 " (" $5 ")"}' || echo "- No images found")
357+
358+ ## Download
359+ Both SD card and eMMC images are available as workflow artifacts above and in the latest-boot release.
360+ EOF
361+ else
362+ cat <<EOF >> $GITHUB_STEP_SUMMARY
206363 # SD Card Image Build Complete! 🚀
207364
208365 **Board:** ${{ inputs.board }}
@@ -211,8 +368,9 @@ jobs:
211368 **Artifact Source:** ${{ inputs.use_latest_release && 'Latest Release' || 'Latest Workflow Run' }}
212369
213370 ## Created Images
214- $(find output/images/ -name "*.img* " -o -name "*.qcow2" -o -name "*.raw " | xargs ls -lh 2>/dev/null | sed 's/^/- / ' || echo "- No images found")
371+ $(find output/images/ -name "*.img" -o -name "*.img.bmap " | xargs ls -lh 2>/dev/null | awk '{print "- " $9 " (" $5 ")"} ' || echo "- No images found")
215372
216373 ## Download
217374 The SD card image is available as a workflow artifact above.
218375 EOF
376+ fi
0 commit comments