diff options
15 files changed, 412 insertions, 146 deletions
diff --git a/utils/ypr0tools/Makefile b/utils/ypr0tools/Makefile index 3efdc61443..d4715bdca8 100644 --- a/utils/ypr0tools/Makefile +++ b/utils/ypr0tools/Makefile | |||
@@ -1,20 +1,41 @@ | |||
1 | DEFINES= | 1 | .PHONY: all clean dirs bmp2rb |
2 | CC=gcc | 2 | CFLAGS += -O1 -g -std=c99 -W -Wall $(DEFINES) |
3 | LD=gcc | 3 | PROGS = bmp2rb fwcrypt fwdecrypt |
4 | CFLAGS=-g -std=c99 -W -Wall $(DEFINES) | 4 | CROSS_COMPILE = arm-ypr0-linux-gnueabi- |
5 | LDFLAGS= | 5 | R1_SAFEMODE_DIR = files/r1/etc/safemode |
6 | BINS=fwcrypt fwdecrypt | 6 | R0_SAFEMODE_DIR = files/r0/etc/safemode |
7 | DIRS = $(R1_SAFEMODE_DIR) $(R0_SAFEMODE_DIR) | ||
8 | R1_IMAGES = $(subst .bmp,.raw,$(addprefix $(R1_SAFEMODE_DIR)/,$(notdir $(wildcard files/images/r1/*.bmp)))) | ||
9 | R0_IMAGES = $(subst .bmp,.raw,$(addprefix $(R0_SAFEMODE_DIR)/,$(notdir $(wildcard files/images/r0/*.bmp)))) | ||
10 | BMP2RB = ../../tools/bmp2rb | ||
7 | 11 | ||
8 | all: $(BINS) | 12 | all: $(R1_SAFEMODE_DIR)/cable_detect $(PROGS) $(R1_IMAGES) $(R0_IMAGES) |
9 | 13 | $(MAKE) -C cramfs-1.1 | |
10 | %.o: %.c | ||
11 | $(CC) $(CFLAGS) -c -o $@ $< | ||
12 | 14 | ||
13 | fwdecrypt: fwdecrypt.o common.o ../../tools/fwpatcher/md5.o | 15 | fwdecrypt: fwdecrypt.o common.o ../../tools/fwpatcher/md5.o |
14 | $(LD) -o $@ $^ $(LDFLAGS) | ||
15 | 16 | ||
16 | fwcrypt: fwcrypt.o common.o ../../tools/fwpatcher/md5.o | 17 | fwcrypt: fwcrypt.o common.o ../../tools/fwpatcher/md5.o |
17 | $(LD) -o $@ $^ $(LDFLAGS) | 18 | |
19 | $(BMP2RB): | ||
20 | $(MAKE) -C ../../tools/ bmp2rb | ||
21 | |||
22 | $(R1_SAFEMODE_DIR)/cable_detect: cable_detect.c $(R1_SAFEMODE_DIR) | ||
23 | $(CROSS_COMPILE)$(CC) $(CFLAGS) $< -o $@ | ||
24 | |||
25 | $(R1_SAFEMODE_DIR)/%.raw: files/images/r1/%.bmp $(BMP2RB) $(R1_SAFEMODE_DIR) | ||
26 | $(BMP2RB) -r -f 9 $< > $@ | ||
27 | |||
28 | $(R0_SAFEMODE_DIR)/%.raw: files/images/r0/%.bmp $(BMP2RB) $(R0_SAFEMODE_DIR) | ||
29 | $(BMP2RB) -r -f 9 $< > $@ | ||
30 | |||
31 | $(DIRS): | ||
32 | $(SILENT)mkdir -p $@ | ||
33 | |||
34 | dirs: $(DIRS) | ||
35 | |||
36 | bmp2rb: $(BMP2RB) | ||
18 | 37 | ||
19 | clean: | 38 | clean: |
20 | rm -fr *.o $(BINS) | 39 | $(MAKE) -C cramfs-1.1 clean |
40 | rm -f *.o fwdecrypt fwcrypt | ||
41 | rm -rf $(R1_SAFEMODE_DIR)/../../etc $(R0_SAFEMODE_DIR)/../../etc | ||
diff --git a/utils/ypr0tools/cable_detect.c b/utils/ypr0tools/cable_detect.c new file mode 100644 index 0000000000..57679d4b79 --- /dev/null +++ b/utils/ypr0tools/cable_detect.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Samsung YP-R1 runtime USB cable detection | ||
10 | * | ||
11 | * Copyright (C) 2013 Lorenzo Miori | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include <sys/ioctl.h> | ||
24 | #include <fcntl.h> | ||
25 | #include <unistd.h> | ||
26 | |||
27 | #define IOCTL_PMU_MAGIC 'A' | ||
28 | |||
29 | #define E_IOCTL_PMU_GET_BATT_LVL 0 | ||
30 | #define E_IOCTL_PMU_GET_CHG_STATUS 1 | ||
31 | #define E_IOCTL_PMU_IS_EXT_PWR 2 | ||
32 | #define E_IOCTL_PMU_STOP_CHG 3 | ||
33 | #define E_IOCTL_PMU_START_CHG 4 | ||
34 | #define E_IOCTL_PMU_IS_EXT_PWR_OVP 5 | ||
35 | #define E_IOCTL_PMU_LCD_DIM_CTRL 6 | ||
36 | #define E_IOCTL_PMU_CORE_CTL_HIGH 7 | ||
37 | #define E_IOCTL_PMU_CORE_CTL_LOW 8 | ||
38 | #define E_IOCTL_PMU_TSP_USB_PWR_OFF 9 | ||
39 | |||
40 | #define IOCTL_PMU_GET_BATT_LVL _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_GET_BATT_LVL) | ||
41 | #define IOCTL_PMU_GET_CHG_STATUS _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_GET_CHG_STATUS) | ||
42 | #define IOCTL_PMU_IS_EXT_PWR _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_IS_EXT_PWR) | ||
43 | #define IOCTL_PMU_STOP_CHG _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_STOP_CHG) | ||
44 | #define IOCTL_PMU_START_CHG _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_START_CHG) | ||
45 | #define IOCTL_PMU_IS_EXT_PWR_OVP _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_IS_EXT_PWR_OVP) | ||
46 | #define IOCTL_PMU_LCD_DIM_CTRL _IOW(IOCTL_PMU_MAGIC, E_IOCTL_PMU_LCD_DIM_CTRL, int) | ||
47 | #define IOCTL_PMU_CORE_CTL_HIGH _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_CORE_CTL_HIGH) | ||
48 | #define IOCTL_PMU_CORE_CTL_LOW _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_CORE_CTL_LOW) | ||
49 | #define IOCTL_PMU_TSP_USB_PWR_OFF _IO(IOCTL_PMU_MAGIC, E_IOCTL_PMU_TSP_USB_PWR_OFF) | ||
50 | |||
51 | /* | ||
52 | * This is a very simple program that runs on device. | ||
53 | * It returns error code either 0 when (power/usb) cable | ||
54 | * is not connected or >= 1 if connected. | ||
55 | */ | ||
56 | int main(void) | ||
57 | { | ||
58 | int state = -1; | ||
59 | int dev = open("/dev/r1Pmu", O_RDONLY); | ||
60 | state = ioctl(dev, IOCTL_PMU_IS_EXT_PWR); | ||
61 | close(dev); | ||
62 | return state; | ||
63 | } | ||
diff --git a/utils/ypr0tools/files/.rockbox/README b/utils/ypr0tools/files/common/.rockbox/README index f0e306e196..f0e306e196 100644 --- a/utils/ypr0tools/files/.rockbox/README +++ b/utils/ypr0tools/files/common/.rockbox/README | |||
diff --git a/utils/ypr0tools/files/Playlists/README b/utils/ypr0tools/files/common/Playlists/README index f0e306e196..f0e306e196 100644 --- a/utils/ypr0tools/files/Playlists/README +++ b/utils/ypr0tools/files/common/Playlists/README | |||
diff --git a/utils/ypr0tools/files/etc/profile b/utils/ypr0tools/files/common/etc/profile index 9fa1505544..5a51167ac1 100755 --- a/utils/ypr0tools/files/etc/profile +++ b/utils/ypr0tools/files/common/etc/profile | |||
@@ -15,8 +15,8 @@ hwclock -s | |||
15 | alias ls='ls --color=auto' | 15 | alias ls='ls --color=auto' |
16 | alias ll='ls -l --color=auto' | 16 | alias ll='ls -l --color=auto' |
17 | 17 | ||
18 | # Start with lorenzo92's safe mode | 18 | # Start with safe mode |
19 | SCRIPT="/etc/mods/safe_mode.sh" | 19 | SCRIPT="/etc/safemode/smode" |
20 | if [ -f $SCRIPT ] | 20 | if [ -f $SCRIPT ] |
21 | then | 21 | then |
22 | /bin/sh $SCRIPT | 22 | /bin/sh $SCRIPT |
@@ -29,24 +29,16 @@ then | |||
29 | fi | 29 | fi |
30 | fi | 30 | fi |
31 | 31 | ||
32 | if [ -e "/mnt/media1/r0" ] | 32 | # Ironically, r1's ROM contains a lot of r0's executables, including the main one. |
33 | # So we need to check against r1 before! | ||
34 | if [ -e "/usr/local/bin/r1" ] | ||
33 | then | 35 | then |
34 | MAINFILE="/mnt/media1/r0" | 36 | MAINFILE="/usr/local/bin/r1" |
35 | elif [ -f "/mnt/media0/r0" ] | ||
36 | then | ||
37 | # copy to media1 since USB wouldn't work | ||
38 | cp /mnt/media0/r0 /mnt/media1/r0_media0 | ||
39 | if [ "$?" = "0" ] | ||
40 | then # perhaps cp failed due to insufficient storage or so | ||
41 | MAINFILE="/mnt/media1/r0_media0" | ||
42 | else | ||
43 | MAINFILE="/usr/local/bin/r0" | ||
44 | fi | ||
45 | else | 37 | else |
46 | MAINFILE="/usr/local/bin/r0" | 38 | MAINFILE="/usr/local/bin/r0" |
47 | fi | 39 | fi |
48 | 40 | ||
49 | # Parameters for r0 | 41 | # Parameters for the application |
50 | MAINFILE_ARGV="Application AppMain" | 42 | MAINFILE_ARGV="Application AppMain" |
51 | 43 | ||
52 | # source the rockbox loader script | 44 | # source the rockbox loader script |
diff --git a/utils/ypr0tools/files/common/etc/safemode/smode b/utils/ypr0tools/files/common/etc/safemode/smode new file mode 100755 index 0000000000..f94d09a26d --- /dev/null +++ b/utils/ypr0tools/files/common/etc/safemode/smode | |||
@@ -0,0 +1,250 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ###################################################################### | ||
4 | # __________ __ ___. | ||
5 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
6 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
7 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
8 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
9 | # \/ \/ \/ \/ \/ | ||
10 | # | ||
11 | # * Safe Mode for Samsung YP-R0 / YP-R1 * | ||
12 | # * Copyright (C) 2013 Lorenzo Miori and VanniX | ||
13 | ###################################################################### | ||
14 | |||
15 | # 0 = R0 ; 1 = R1 | ||
16 | PLATFORM=0 | ||
17 | BUTTON_DEVICE="/dev/r0Btn" | ||
18 | PMK=$(echo -e -n "\x01") # same for both devices | ||
19 | STORAGES="/dev/stl3,/dev/stl2,/dev/mmcblk0" | ||
20 | |||
21 | MODE="normal" | ||
22 | |||
23 | if [ $# -eq 1 ] | ||
24 | then | ||
25 | MODE=$1 | ||
26 | fi | ||
27 | |||
28 | # rather simple but effective check | ||
29 | # different key codes to trigger safe mode | ||
30 | if [ -e "/usr/local/bin/r1" ] | ||
31 | then | ||
32 | # running on YP-R1 model | ||
33 | BACK=$(echo -e -n "\x02") | ||
34 | PLATFORM=1 | ||
35 | BUTTON_DEVICE="/dev/r1Button" | ||
36 | STORAGES="/dev/stl3,/dev/stl2" | ||
37 | else | ||
38 | BACK=$(echo -e -n "\x08") | ||
39 | PLATFORM=0 | ||
40 | BUTTON_DEVICE="/dev/r0Btn" | ||
41 | STORAGES="/dev/stl3,/dev/stl2,/dev/mmcblk0" | ||
42 | fi | ||
43 | |||
44 | power_pressed() | ||
45 | { | ||
46 | VAR=$(dd if=$BUTTON_DEVICE bs=4 count=1) | ||
47 | [[ "$VAR" = "$PMK" ]] | ||
48 | return $? | ||
49 | } | ||
50 | |||
51 | cable_disconnected() | ||
52 | { | ||
53 | if [ $PLATFORM -eq 0 ] | ||
54 | then | ||
55 | /usr/local/bin/minird 0x0a | grep -q 0x00 | ||
56 | return $? | ||
57 | else | ||
58 | /etc/safemode/cable_detect | ||
59 | return $? | ||
60 | fi | ||
61 | } | ||
62 | |||
63 | enable_display() | ||
64 | { | ||
65 | echo -n "0" > /sys/devices/platform/afe.0/bli | ||
66 | echo -n "1" > /sys/class/graphics/fb0/blank | ||
67 | echo -n "0" >> /sys/class/graphics/fb0/blank | ||
68 | echo -n "1" > /sys/devices/platform/afe.0/bli | ||
69 | } | ||
70 | |||
71 | display_image() | ||
72 | { | ||
73 | cat $1 > "/dev/fb0" | ||
74 | } | ||
75 | |||
76 | if [ $MODE != "forced" ] | ||
77 | then | ||
78 | KEY=$(dd if=$BUTTON_DEVICE bs=4 count=1) | ||
79 | if [[ "$KEY" != "$BACK" ]]; then | ||
80 | # do not enter safe mode and continue normal boot | ||
81 | exit 0 | ||
82 | fi | ||
83 | fi | ||
84 | |||
85 | # Here we entered safe mode, so first clean the display | ||
86 | # and turn on backlight at minimum level | ||
87 | enable_display | ||
88 | |||
89 | # there are different ROMs around... | ||
90 | if [ -e "/etc/safemode/safemode.raw" ] | ||
91 | then | ||
92 | DefIMG="/etc/safemode/safemode.raw" | ||
93 | else | ||
94 | DefIMG="/etc/mods/safe_mode.raw" | ||
95 | fi | ||
96 | RbtIMG="/etc/safemode/post_smode.raw" | ||
97 | PreIMG="/etc/safemode/pre_smode.raw" | ||
98 | |||
99 | NOUSB=true | ||
100 | |||
101 | if cable_disconnected | ||
102 | then | ||
103 | |||
104 | display_image $PreIMG | ||
105 | |||
106 | while $NOUSB | ||
107 | do | ||
108 | |||
109 | # User aborts safe mode before mounting anything, just exit | ||
110 | # and continue normal boot | ||
111 | if power_pressed | ||
112 | then | ||
113 | sleep 1 | ||
114 | if power_pressed | ||
115 | then | ||
116 | exit 1 | ||
117 | fi | ||
118 | fi | ||
119 | |||
120 | if cable_disconnected | ||
121 | then | ||
122 | echo "USB not connected - Waiting" | ||
123 | else | ||
124 | sleep 1 | ||
125 | if cable_disconnected | ||
126 | then | ||
127 | echo "USB first check OK - Waiting" | ||
128 | else | ||
129 | sleep 1 | ||
130 | if cable_disconnected | ||
131 | then | ||
132 | echo "USB second check OK - Waiting" | ||
133 | else | ||
134 | NOUSB=false | ||
135 | USB=true | ||
136 | fi | ||
137 | fi | ||
138 | fi | ||
139 | done | ||
140 | else | ||
141 | while $NOUSB | ||
142 | do | ||
143 | if cable_disconnected | ||
144 | then | ||
145 | echo "USB not connected - Waiting" | ||
146 | else | ||
147 | sleep 1 | ||
148 | if cable_disconnected | ||
149 | then | ||
150 | echo "USB first check OK - Waiting" | ||
151 | else | ||
152 | NOUSB=false | ||
153 | USB=true | ||
154 | fi | ||
155 | fi | ||
156 | done | ||
157 | fi | ||
158 | |||
159 | display_image $DefIMG | ||
160 | |||
161 | echo "Enabling usb storage..." | ||
162 | lsmod | grep g_file_storage | ||
163 | if [ $? == 0 ] | ||
164 | then | ||
165 | umount /mnt/media1/dev/gadget | ||
166 | fi | ||
167 | |||
168 | umount /mnt/media1 | ||
169 | umount /mnt/media0 | ||
170 | |||
171 | lsmod | grep rfs | ||
172 | if [ $? == 0 ] | ||
173 | then | ||
174 | rmmod rfs | ||
175 | fi | ||
176 | |||
177 | lsmod | grep g_file_storage | ||
178 | if [ $? == 0 ] | ||
179 | then | ||
180 | rmmod gadgetfs | ||
181 | rmmod g_file_storage | ||
182 | rmmod arcotg_udc | ||
183 | fi | ||
184 | |||
185 | lsmod | grep g_serial | ||
186 | if [ $? == 0 ] | ||
187 | then | ||
188 | rmmod g_serial | ||
189 | fi | ||
190 | |||
191 | lsmod | grep g_file_storage | ||
192 | if [ $? != 0 ] | ||
193 | then | ||
194 | modprobe g-file-storage file=$STORAGES removable=1 | ||
195 | fi | ||
196 | |||
197 | SAFE=true | ||
198 | while $SAFE | ||
199 | do | ||
200 | if power_pressed | ||
201 | then | ||
202 | sleep 1 | ||
203 | if power_pressed | ||
204 | then | ||
205 | SAFE=false | ||
206 | fi | ||
207 | fi | ||
208 | done | ||
209 | |||
210 | echo "Removing loaded modules..." | ||
211 | rmmod g_file_storage | ||
212 | rmmod arcotg_udc | ||
213 | |||
214 | display_image $RbtIMG | ||
215 | |||
216 | USB=true | ||
217 | |||
218 | while $USB | ||
219 | do | ||
220 | if cable_disconnected | ||
221 | then | ||
222 | sleep 1 | ||
223 | if cable_disconnected | ||
224 | then | ||
225 | if cable_disconnected | ||
226 | then | ||
227 | sleep 1 | ||
228 | if cable_disconnected | ||
229 | then | ||
230 | USB=false | ||
231 | else | ||
232 | echo "USB connected - Waiting" | ||
233 | USB=true | ||
234 | fi | ||
235 | else | ||
236 | echo "USB connected - Waiting" | ||
237 | USB=true | ||
238 | fi | ||
239 | else | ||
240 | echo "USB connected - Waiting" | ||
241 | USB=true | ||
242 | fi | ||
243 | else | ||
244 | echo "USB connected - Waiting" | ||
245 | USB=true | ||
246 | fi | ||
247 | done | ||
248 | |||
249 | #power key pressed for almost 2 sec and cable disconnected. Power off! | ||
250 | exit 1 | ||
diff --git a/utils/ypr0tools/files/etc/mods/safe_mode.sh b/utils/ypr0tools/files/etc/mods/safe_mode.sh deleted file mode 100755 index 122b2eabfe..0000000000 --- a/utils/ypr0tools/files/etc/mods/safe_mode.sh +++ /dev/null | |||
@@ -1,111 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # YP-R0 Safe Mode!! | ||
4 | # - Part of the "Device Rescue Kit", modded ROM v2.20 and onwards | ||
5 | # Version: v0.3 | ||
6 | # v0.2 - initial version | ||
7 | # v0.3 - USB cable check implemented | ||
8 | # by lorenzo92 aka Memory | ||
9 | # memoryS60@gmail.com | ||
10 | |||
11 | CustomIMG="/mnt/media1/safe_mode.raw" | ||
12 | DefIMG="/etc/mods/safe_mode.raw" | ||
13 | |||
14 | timer=0 | ||
15 | # Seconds before turning the device OFF | ||
16 | timeout=2 | ||
17 | |||
18 | shutdown () { | ||
19 | sync | ||
20 | reboot | ||
21 | } | ||
22 | |||
23 | cableDaemon () { | ||
24 | cd /usr/local/bin | ||
25 | while [ 1 ] | ||
26 | do | ||
27 | if [ $timer -gt $timeout ] | ||
28 | then | ||
29 | shutdown | ||
30 | fi | ||
31 | |||
32 | if ./minird 0x0a | grep -q 0x00 | ||
33 | then | ||
34 | timer=$(($timer+1)) | ||
35 | else | ||
36 | timer=0 | ||
37 | fi | ||
38 | sleep 1 | ||
39 | done | ||
40 | } | ||
41 | |||
42 | # Back button is a \x08\x00\x00\x00 string... | ||
43 | # ...since bash removes null bytes for us, we must only care the single byte | ||
44 | var=$(dd if=/dev/r0Btn bs=4 count=1) | ||
45 | # Here a workaround to detect \x08 byte :S | ||
46 | var2=$(echo -e -n "\x08") | ||
47 | if [[ "$var" = "$var2" ]] | ||
48 | then | ||
49 | echo "Safe mode (USB) activated..." | ||
50 | # Put the backlight at the minimum level: no energy waste, please ;) | ||
51 | # Using low level interface | ||
52 | |||
53 | cd /usr/local/bin | ||
54 | ./afewr 0x1b 0x3 0x8 | ||
55 | |||
56 | # Long press reset time 5 secs | ||
57 | [ -e /etc/mods/reset_time_mod.sh ] && /bin/sh /etc/mods/reset_time_mod.sh | ||
58 | |||
59 | # Clear the screen and show a nice picture :D | ||
60 | |||
61 | echo -n "1" > /sys/class/graphics/fb0/blank | ||
62 | echo -n "0" >> /sys/class/graphics/fb0/blank | ||
63 | # echo -n "1" > /sys/class/graphics/fb2/blank | ||
64 | # echo -n "0" >> /sys/class/graphics/fb2/blank | ||
65 | if [ -e $CustomIMG ] | ||
66 | then | ||
67 | cat $CustomIMG > "/dev/fb0" | ||
68 | else | ||
69 | cat $DefIMG > "/dev/fb0" | ||
70 | fi | ||
71 | |||
72 | # Here the real USB connection stuff | ||
73 | # This is slightly modified by me; it was contained in the cramfs shipped with | ||
74 | # YP-R0 opensource package... | ||
75 | |||
76 | lsmod | grep g_file_storage | ||
77 | if [ $? == 0 ] | ||
78 | then | ||
79 | umount /mnt/media1/dev/gadget | ||
80 | fi | ||
81 | #if [ -d /mnt/media0 ] | ||
82 | #then | ||
83 | umount /mnt/media1 | ||
84 | umount /mnt/media0 | ||
85 | #umount /mnt/mmc | ||
86 | #fi | ||
87 | lsmod | grep rfs | ||
88 | if [ $? == 0 ] | ||
89 | then | ||
90 | rmmod rfs | ||
91 | fi | ||
92 | lsmod | grep g_file_storage | ||
93 | if [ $? == 0 ] | ||
94 | then | ||
95 | rmmod gadgetfs | ||
96 | rmmod g_file_storage | ||
97 | rmmod arcotg_udc | ||
98 | fi | ||
99 | lsmod | grep g_file_storage | ||
100 | if [ $? != 0 ] | ||
101 | then | ||
102 | modprobe g-file-storage file=/dev/stl3,/dev/stl2,/dev/mmcblk0 removable=1 | ||
103 | fi | ||
104 | |||
105 | # Let's implement the check if usb cable is still inserted or not... | ||
106 | cableDaemon | ||
107 | |||
108 | return 1 | ||
109 | else | ||
110 | return 0 | ||
111 | fi | ||
diff --git a/utils/ypr0tools/files/images/r0/post_smode.bmp b/utils/ypr0tools/files/images/r0/post_smode.bmp new file mode 100644 index 0000000000..5f09fcd54c --- /dev/null +++ b/utils/ypr0tools/files/images/r0/post_smode.bmp | |||
Binary files differ | |||
diff --git a/utils/ypr0tools/files/images/r0/pre_smode.bmp b/utils/ypr0tools/files/images/r0/pre_smode.bmp new file mode 100644 index 0000000000..42978842e9 --- /dev/null +++ b/utils/ypr0tools/files/images/r0/pre_smode.bmp | |||
Binary files differ | |||
diff --git a/utils/ypr0tools/files/etc/mods/safe_mode.raw b/utils/ypr0tools/files/images/r0/safemode.bmp index 1c1aa61dd1..410642024e 100644 --- a/utils/ypr0tools/files/etc/mods/safe_mode.raw +++ b/utils/ypr0tools/files/images/r0/safemode.bmp | |||
Binary files differ | |||
diff --git a/utils/ypr0tools/files/images/r1/post_smode.bmp b/utils/ypr0tools/files/images/r1/post_smode.bmp new file mode 100644 index 0000000000..cd713a8725 --- /dev/null +++ b/utils/ypr0tools/files/images/r1/post_smode.bmp | |||
Binary files differ | |||
diff --git a/utils/ypr0tools/files/images/r1/pre_smode.bmp b/utils/ypr0tools/files/images/r1/pre_smode.bmp new file mode 100644 index 0000000000..f6fd8f3fa7 --- /dev/null +++ b/utils/ypr0tools/files/images/r1/pre_smode.bmp | |||
Binary files differ | |||
diff --git a/utils/ypr0tools/files/images/r1/safemode.bmp b/utils/ypr0tools/files/images/r1/safemode.bmp new file mode 100644 index 0000000000..79da24f742 --- /dev/null +++ b/utils/ypr0tools/files/images/r1/safemode.bmp | |||
Binary files differ | |||
diff --git a/utils/ypr0tools/files/lib/modules/si4709.ko b/utils/ypr0tools/files/r0/lib/modules/si4709.ko index e2990d2b2d..e2990d2b2d 100755 --- a/utils/ypr0tools/files/lib/modules/si4709.ko +++ b/utils/ypr0tools/files/r0/lib/modules/si4709.ko | |||
Binary files differ | |||
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 |