hiby: r1_patcher: fix possible boot hang and flash failures

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit b25f59a98ab493cbc4061423f59ae7760e53af01
Author: Roman Artiukhin <[email protected]>
Date:   Mon Jan 19 18:49:31 2026 +0200

    hiby: r1_patcher: fix  possible boot hang and flash failures
    
    - Sort image parts for deterministic results.
    - Ensure bootloader.r1 is correctly named and has +x permissions.
    
    Change-Id: I391c935d75e5079010fc91d3614d9221d34e4c6b

diff --git a/tools/r1_patcher/r1_patcher.sh b/tools/r1_patcher/r1_patcher.sh
index 69b8407a7b..973ca28179 100755
--- a/tools/r1_patcher/r1_patcher.sh
+++ b/tools/r1_patcher/r1_patcher.sh
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+#Prerequisites:
+#sudo apt update && sudo apt install -y p7zip-full squashfs-tools genisoimage coreutils
+
 if [[ $# -ne 2 ]]; then
     echo 'usage: ./r1_patcher.sh r1.upt bootloader.r1' >&2
     exit 1
@@ -48,7 +51,8 @@ unsquashfs -f -d $workingdir_in/rootfs/extracted $workingdir_in/rootfs/rootfs.sq
 ################################################################################
 
 # copy 'bootloader'
-cp $2 $workingdir_in/rootfs/extracted/usr/bin/
+cp "$2" "$workingdir_in/rootfs/extracted/usr/bin/bootloader.r1"
+chmod 0755 "$workingdir_in/rootfs/extracted/usr/bin/bootloader.r1"
 
 # copy modified 'hibyplayer.sh' script
 cp hiby_player.sh $workingdir_in/rootfs/extracted/usr/bin/
@@ -58,10 +62,9 @@ chmod 0755 $workingdir_in/rootfs/extracted/usr/bin/hiby_player.sh
 ### rebuild
 ################################################################################
 
-mkdir "$workingdir_out/image_contents"
-mkdir "$workingdir_out/image_contents/ota_v0"
+mkdir -p "$workingdir_out/image_contents/ota_v0"
 
-mksquashfs $workingdir_in/rootfs/extracted $workingdir_out/rootfs.squashfs -comp lzo
+mksquashfs $workingdir_in/rootfs/extracted $workingdir_out/rootfs.squashfs -comp lzo -all-root
 
 cd "$workingdir_out/image_contents/ota_v0"
 
@@ -74,12 +77,11 @@ md5=$rootfs_md5
 
 ota_md5_rootfs="ota_md5_rootfs.squashfs.$md5"
 
-parts=`find . -name 'rootfs.squashfs.*'`
-for part in $parts; do
-	md5next=($(md5sum $part))
-	echo $md5next >> $ota_md5_rootfs
-	mv $part "$part.$md5"
-	md5=$md5next
+for part in $(ls rootfs.squashfs.[0-9]* | sort); do
+    md5next=($(md5sum $part))
+    echo $md5next >> $ota_md5_rootfs
+    mv $part "$part.$md5"
+    md5=$md5next
 done
 
 # xImage
@@ -91,12 +93,11 @@ md5=$ximage_md5
 
 ota_md5_xImage="ota_md5_xImage.$md5"
 
-parts=`find . -name 'xImage.*'`
-for part in $parts; do
-        md5next=($(md5sum $part))
-        echo $md5next >> $ota_md5_xImage
-        mv $part "$part.$md5"
-        md5=$md5next
+for part in $(ls xImage.[0-9]* | sort); do
+    md5next=($(md5sum $part))
+    echo $md5next >> $ota_md5_xImage
+    mv $part "$part.$md5"
+    md5=$md5next
 done
 
 # ota_update.in
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.