summaryrefslogtreecommitdiff
path: root/utils/ypr0tools/patch-firmware.sh
diff options
context:
space:
mode:
Diffstat (limited to 'utils/ypr0tools/patch-firmware.sh')
-rwxr-xr-xutils/ypr0tools/patch-firmware.sh65
1 files changed, 58 insertions, 7 deletions
diff --git a/utils/ypr0tools/patch-firmware.sh b/utils/ypr0tools/patch-firmware.sh
index 879b3f879d..acc1b48631 100755
--- a/utils/ypr0tools/patch-firmware.sh
+++ b/utils/ypr0tools/patch-firmware.sh
@@ -11,19 +11,21 @@
11# 11#
12# * Script to patch an unpacked Samsung YP-R0 firmware file */ 12# * Script to patch an unpacked Samsung YP-R0 firmware file */
13# Copyright (C) 2011 Thomas Martitz 13# Copyright (C) 2011 Thomas Martitz
14# Copyright (C) 2013 Lorenzo Miori
14###################################################################### 15######################################################################
15# bail out early 16# bail out early
16set -e 17set -e
17 18
18if [ $# -lt 1 ] || [ $# -gt 2 ]; then 19if [ $# -lt 1 ] || [ $# -gt 2 ]; then
19 echo "Usage: $0 <files path> [path to unpacked rom]" 20 echo "Usage: $0 <files path> [path to unpacked rom]"
20 echo "\t<files path> is expected to have a rootfs layout and to contain" 21 echo "\t<files path> is expected to have a special resources and rootfs layout"
21 echo "\tonly the files to overwrite (plain cp -r is used)"
22 exit 1 22 exit 1
23fi 23fi
24 24
25MODEL="unknown"
25FILES=${1%/} 26FILES=${1%/}
26FILES=${FILES:-"/"} 27FILES=${FILES:-"/"}
28COMMON_FILES="$FILES/common"
27DIR=${2:-"."} 29DIR=${2:-"."}
28DIR=${DIR%/} 30DIR=${DIR%/}
29ROOTFS=$DIR/rootfs 31ROOTFS=$DIR/rootfs
@@ -31,6 +33,35 @@ CRAMFS=$DIR/cramfs-fsl.rom
31 33
32# sanity checks 34# sanity checks
33 35
36for subdir in common r0 r1
37do
38 if [ ! -d "$FILES/$subdir" ]
39 then
40 echo "Missing $FILES/$subdir. Invalid $FILES layout."
41 exit 1
42 fi
43done
44
45if [ ! -e "$FILES/r1/etc/safemode/cable_detect" ]
46then
47 echo "Couldn't find cable_detect binary (try 'make' or select a valid layout directory)"
48 exit 1
49fi
50
51for image in pre_smode.raw post_smode.raw safemode.raw
52do
53 if [ ! -e "$FILES/r1/etc/safemode/$image" ]
54 then
55 echo "Missing r1 .raw image file (try 'make'): $image"
56 exit 1
57 fi
58 if [ ! -e "$FILES/r0/etc/safemode/$image" ]
59 then
60 echo "Missing r0 .raw image file (try 'make'): $image"
61 exit 1
62 fi
63done
64
34# this needs to be run as root! 65# this needs to be run as root!
35if [ $(whoami) != "root" ] 66if [ $(whoami) != "root" ]
36then 67then
@@ -55,13 +86,33 @@ fi
55 86
56echo "Extracting cramfs image" 87echo "Extracting cramfs image"
57 88
58[ ! -e $ROOTFS ] || rmdir -p $ROOTFS 89[ ! -e $ROOTFS ] || rm -R $ROOTFS
59cramfs-1.1/cramfsck -x $ROOTFS $CRAMFS 90cramfs-1.1/cramfsck -x $ROOTFS $CRAMFS
60 91
61echo "Patching rootfs" 92# now we can detect player version
62echo "cp -r $FILES/* $ROOTFS/" 93# NOTE: order is important here, since ironically
63cp -r $FILES/.rockbox $ROOTFS/ 94# r1's ROM contains also r0's executables
64cp -r $FILES/* $ROOTFS/ 95if [ -e "$ROOTFS/usr/local/bin/r1" ]
96then
97 MODEL="r1"
98else
99 if [ -e "$ROOTFS/usr/local/bin/r0" ]
100 then
101 MODEL="r0"
102 fi
103fi
104
105echo "$MODEL ROM found."
106
107echo "Patching rootfs (common files)"
108echo "cp -r $COMMON_FILES/* $ROOTFS/"
109cp -r $COMMON_FILES/.rockbox $ROOTFS/
110cp -r $COMMON_FILES/* $ROOTFS/
111
112echo "Patching rootfs ($MODEL files)"
113MODEL_FILES="$FILES/$MODEL"
114echo "cp -r $MODEL_FILES/* $ROOTFS/"
115cp -r $MODEL_FILES/* $ROOTFS/
65 116
66echo "Packing new cramfs image" 117echo "Packing new cramfs image"
67cramfs-1.1/mkcramfs $ROOTFS $CRAMFS 118cramfs-1.1/mkcramfs $ROOTFS $CRAMFS