diff options
Diffstat (limited to 'utils/ypr0tools/patch-firmware.sh')
-rwxr-xr-x | utils/ypr0tools/patch-firmware.sh | 65 |
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 |
16 | set -e | 17 | set -e |
17 | 18 | ||
18 | if [ $# -lt 1 ] || [ $# -gt 2 ]; then | 19 | if [ $# -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 |
23 | fi | 23 | fi |
24 | 24 | ||
25 | MODEL="unknown" | ||
25 | FILES=${1%/} | 26 | FILES=${1%/} |
26 | FILES=${FILES:-"/"} | 27 | FILES=${FILES:-"/"} |
28 | COMMON_FILES="$FILES/common" | ||
27 | DIR=${2:-"."} | 29 | DIR=${2:-"."} |
28 | DIR=${DIR%/} | 30 | DIR=${DIR%/} |
29 | ROOTFS=$DIR/rootfs | 31 | ROOTFS=$DIR/rootfs |
@@ -31,6 +33,35 @@ CRAMFS=$DIR/cramfs-fsl.rom | |||
31 | 33 | ||
32 | # sanity checks | 34 | # sanity checks |
33 | 35 | ||
36 | for subdir in common r0 r1 | ||
37 | do | ||
38 | if [ ! -d "$FILES/$subdir" ] | ||
39 | then | ||
40 | echo "Missing $FILES/$subdir. Invalid $FILES layout." | ||
41 | exit 1 | ||
42 | fi | ||
43 | done | ||
44 | |||
45 | if [ ! -e "$FILES/r1/etc/safemode/cable_detect" ] | ||
46 | then | ||
47 | echo "Couldn't find cable_detect binary (try 'make' or select a valid layout directory)" | ||
48 | exit 1 | ||
49 | fi | ||
50 | |||
51 | for image in pre_smode.raw post_smode.raw safemode.raw | ||
52 | do | ||
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 | ||
63 | done | ||
64 | |||
34 | # this needs to be run as root! | 65 | # this needs to be run as root! |
35 | if [ $(whoami) != "root" ] | 66 | if [ $(whoami) != "root" ] |
36 | then | 67 | then |
@@ -55,13 +86,33 @@ fi | |||
55 | 86 | ||
56 | echo "Extracting cramfs image" | 87 | echo "Extracting cramfs image" |
57 | 88 | ||
58 | [ ! -e $ROOTFS ] || rmdir -p $ROOTFS | 89 | [ ! -e $ROOTFS ] || rm -R $ROOTFS |
59 | cramfs-1.1/cramfsck -x $ROOTFS $CRAMFS | 90 | cramfs-1.1/cramfsck -x $ROOTFS $CRAMFS |
60 | 91 | ||
61 | echo "Patching rootfs" | 92 | # now we can detect player version |
62 | echo "cp -r $FILES/* $ROOTFS/" | 93 | # NOTE: order is important here, since ironically |
63 | cp -r $FILES/.rockbox $ROOTFS/ | 94 | # r1's ROM contains also r0's executables |
64 | cp -r $FILES/* $ROOTFS/ | 95 | if [ -e "$ROOTFS/usr/local/bin/r1" ] |
96 | then | ||
97 | MODEL="r1" | ||
98 | else | ||
99 | if [ -e "$ROOTFS/usr/local/bin/r0" ] | ||
100 | then | ||
101 | MODEL="r0" | ||
102 | fi | ||
103 | fi | ||
104 | |||
105 | echo "$MODEL ROM found." | ||
106 | |||
107 | echo "Patching rootfs (common files)" | ||
108 | echo "cp -r $COMMON_FILES/* $ROOTFS/" | ||
109 | cp -r $COMMON_FILES/.rockbox $ROOTFS/ | ||
110 | cp -r $COMMON_FILES/* $ROOTFS/ | ||
111 | |||
112 | echo "Patching rootfs ($MODEL files)" | ||
113 | MODEL_FILES="$FILES/$MODEL" | ||
114 | echo "cp -r $MODEL_FILES/* $ROOTFS/" | ||
115 | cp -r $MODEL_FILES/* $ROOTFS/ | ||
65 | 116 | ||
66 | echo "Packing new cramfs image" | 117 | echo "Packing new cramfs image" |
67 | cramfs-1.1/mkcramfs $ROOTFS $CRAMFS | 118 | cramfs-1.1/mkcramfs $ROOTFS $CRAMFS |