summaryrefslogtreecommitdiff
path: root/utils/ypr0tools/files/etc
diff options
context:
space:
mode:
Diffstat (limited to 'utils/ypr0tools/files/etc')
-rw-r--r--utils/ypr0tools/files/etc/mods/safe_mode.rawbin0 -> 230400 bytes
-rwxr-xr-xutils/ypr0tools/files/etc/mods/safe_mode.sh111
-rwxr-xr-xutils/ypr0tools/files/etc/profile66
3 files changed, 177 insertions, 0 deletions
diff --git a/utils/ypr0tools/files/etc/mods/safe_mode.raw b/utils/ypr0tools/files/etc/mods/safe_mode.raw
new file mode 100644
index 0000000000..1c1aa61dd1
--- /dev/null
+++ b/utils/ypr0tools/files/etc/mods/safe_mode.raw
Binary files differ
diff --git a/utils/ypr0tools/files/etc/mods/safe_mode.sh b/utils/ypr0tools/files/etc/mods/safe_mode.sh
new file mode 100755
index 0000000000..122b2eabfe
--- /dev/null
+++ b/utils/ypr0tools/files/etc/mods/safe_mode.sh
@@ -0,0 +1,111 @@
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
11CustomIMG="/mnt/media1/safe_mode.raw"
12DefIMG="/etc/mods/safe_mode.raw"
13
14timer=0
15# Seconds before turning the device OFF
16timeout=2
17
18shutdown () {
19 sync
20 reboot
21}
22
23cableDaemon () {
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
44var=$(dd if=/dev/r0Btn bs=4 count=1)
45# Here a workaround to detect \x08 byte :S
46var2=$(echo -e -n "\x08")
47if [[ "$var" = "$var2" ]]
48then
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
109else
110 return 0
111fi
diff --git a/utils/ypr0tools/files/etc/profile b/utils/ypr0tools/files/etc/profile
new file mode 100755
index 0000000000..4ba61d7535
--- /dev/null
+++ b/utils/ypr0tools/files/etc/profile
@@ -0,0 +1,66 @@
1export PS1='\u@\h \w$ '
2export PS2='> '
3export PS3='? '
4export PS4='[$LINENO]+'
5
6export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
7export LD_LIBRARY_PATH=/mnt/media1/Lib:/mnt/media1/Lib/ExtraLib:/usr/lib
8export FSL_OMX_COMPONENT_REGISTRY="/Sysdata/OpenMaxIL/ComponentRegistry.txt"
9export FSL_OMX_MAX_INDEX_SIZE=1048576
10export MALLOC_CHECK_=0
11
12ulimit -s unlimited
13hwclock -s
14
15alias ls='ls --color=auto'
16alias ll='ls -l --color=auto'
17
18# Start with lorenzo92's safe mode
19SCRIPT="/etc/mods/safe_mode.sh"
20if [ -f $SCRIPT ]
21then
22 /bin/sh $SCRIPT
23 # it returns 1 if usb was connected
24 if [ "$?" = "1" ]
25 then
26 sync
27 sleep 1
28 reboot
29 fi
30fi
31
32if [ -e "/mnt/media1/r0" ]
33then
34 MAINFILE="/mnt/media1/r0"
35elif [ -f "/mnt/media0/r0" ]
36then
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
45else
46 MAINFILE="/usr/local/bin/r0"
47fi
48
49# source the rockbox loader script
50SOURCE="/mnt/media0/.rockbox/rockbox.sh"
51[ -f $SOURCE ] && . $SOURCE
52
53# source user script if available
54SOURCE="/mnt/media0/rc.user"
55[ -f $SOURCE ] && . $SOURCE
56
57# finally call the entry point
58if [ -e $MAINFILE ]
59then
60 chmod 777 $MAINFILE
61 $MAINFILE Application AppMain
62 rm -f /mnt/media1/r0_media0
63 sync
64# sleep 5
65 reboot
66fi