8 /bin/mount -o remount,rw / /
10 PATH=/sbin:/system/sbin:/system/bin:/bin:/system/xbin:/system/xbin/bb:/data/local/bin
12 /bin/echo "Rootfs loaded."
14 /bin/mount -t proc proc /proc
15 /bin/mount -t sysfs sys /sys
20 if [ $notnand = "0" ] ; then
21 echo "running from NAND"
22 /bin/mount -t yaffs2 /dev/block/mtdblock2 /system
23 /bin/mount -t yaffs2 /dev/block/mtdblock3 /data
29 # Try unpartitioned card
30 if [ ! -d /sys/block/mmcblk0/$partition ] ; then
34 if [ -f /sys/class/vogue_hw/gsmphone ] ; then
35 echo "GSM phone found"
38 #mkdir -m 0777 /sdcard
39 #fsck already done in initrd
40 mount -t vfat -o fmask=0000,dmask=0000,rw,flush,noatime,nodiratime /dev/block/$partition /sdcard
41 [ $? -eq 0 ] || fail "Failed to mount the SD card. Cannot continue."
43 if [ ! -d /sdcard/cache ] ; then
48 mount /sdcard/cache /cache
50 if [ -d /sdcard/android ] ; then
57 if [ $notnand = "1" ] ; then
59 if [ -f $card/data.gz ] ; then
60 echo "Please wait... extracting Data Image"
61 if [ -f $card/data.img ] ; then
64 gzip -df $card/data.gz
65 [ $? -eq 0 ] || fail "Failed to extract Data Image"
66 mv $card/data $card/data.img
71 echo "Checking for partition..."
72 if [ -d /sys/block/mmcblk0/mmcblk0p2 ] ; then
74 if [ -d /sys/block/mmcblk0/mmcblk0p3 ] ; then
79 if [ -f $card/backupsystem/installedsystem.sqsh -o -f $card/backupsystem/installedsystem.img -o -f $card/backupsystem.ext2 ]; then
80 echo "Partitioned Build Detected"
85 if [ $PARTITIONED -lt 2 ] ; then
87 if [ ! -f $card/data.img ] ; then
88 echo "Creating a new Data store"
89 dd if=/dev/zero of=$card/data.img bs=1048576 count=256
90 [ $? -eq 0 ] || fail "Failed to allocate the storage"
91 mke2fs -F $card/data.img
92 [ $? -eq 0 ] || fail "Failed to format the storage"
96 if [ $PARTITIONED -lt 2 ] ; then
97 losetup /dev/block/loop0 $card/data.img
98 [ $? -eq 0 ] || fail "Failed to find data.img on SD Card"
99 e2fsck -y /dev/block/loop0
100 mount -t ext2 -o noatime,nodiratime,sync /dev/block/loop0 /data
102 e2fsck -y /dev/block/mmcblk0p3
103 mount -t ext2 -o noatime,nodiratime /dev/block/mmcblk0p3 /data
105 [ $? -eq 0 ] || fail "Failed to mount /data"
107 if [ $PARTITIONED -eq 0 ] ; then
108 if [ -f $card/system.ext2 ] ; then
109 echo "Using uncompressed system"
110 losetup /dev/block/loop1 $card/system.ext2
111 [ $? -eq 0 ] || fail "Failed to reach system.ext2 on SD Card"
112 e2fsck -y /dev/block/loop1
113 mount -t ext2 -o noatime,nodiratime /dev/block/loop1 /system
114 [ $? -eq 0 ] || fail "Failed to mount /system"
116 [ -f $card/system.sqsh ] ; then
117 echo "Using SquashFS system"
118 losetup /dev/block/loop1 $card/system.sqsh
119 [ $? -eq 0 ] || fail "Failed to find system.sqsh on SD Card"
120 mount -t squashfs -o ro,noatime,nodiratime /dev/block/loop1 /system
121 [ $? -eq 0 ] || fail "Failed to mount /system"
123 losetup /dev/block/loop1 $card/system.img
124 [ $? -eq 0 ] || fail "Failed to find system.img on SD Card"
125 mount -t cramfs -o ro,noatime,nodiratime /dev/block/loop1 /system
126 [ $? -eq 0 ] || fail "Failed to mount /system"
129 echo "Using partitioned system"
130 e2fsck -y /dev/block/mmcblk0p2
131 mount -t ext2 -o ro,noatime,nodiratime /dev/block/mmcblk0p2 /system
132 [ $? -eq 0 ] || fail "Failed to mount /system"
136 if [ -d /sdcard/AndroidApps ] ; then
137 echo Copying Applications
138 if [ ! -d /data/app ] ; then
139 mkdir -m 0771 /data/app
141 /bin/cp /sdcard/AndroidApps/* /data/app
142 chown -R 1000:1000 /data/app
145 if [ ! -d /sdcard/android/media ] ; then
146 echo You have no media folder, please extract the resources to your SD card android folder
149 SQLITE3="/bin/sqlite3"
150 DB="/data/data/com.android.providers.telephony/databases/telephony.db"
152 if [ "`$SQLITE3 $DB 'SELECT numeric FROM carriers;' | grep 310995`" != "310995" ] ; then
153 echo Creating android apn
154 "$SQLITE3" "$DB" "INSERT INTO carriers VALUES(NULL, 'Android' , '310995' , '310' , '995' , 'internet' , '*' , '*' , '*' , NULL, NULL, NULL, NULL, 'null' , 'default' , 1);"
157 echo No telephony database. You must have a new data file. I will check for the android apn on the next reboot
160 /bin/rm -rf /data/etc
161 /bin/mkdir -m 0755 /data/etc
163 cp -a /system/etc/* /etc
164 cp -ar /init.etc/* /etc/
166 LCDDENSITY=`/bin/grep -o "lcd.density=.*" /proc/cmdline | /bin/sed -e "s/.*lcd.density=//g" -e "s/ .*//g"`
168 if [ "$LCDDENSITY" != "" ] ; then
169 echo "ro.sf.lcd_density=$LCDDENSITY" >> /etc/default.prop
170 echo Setting ro.sf.lcd_density=$LCDDENSITY
173 if [ ! -d /data/shared_prefs ] ; then
174 mkdir -m 0770 /data/shared_prefs
176 chmod 0770 /data/shared_prefs
177 chown 1000:1000 /data/shared_prefs
178 mount /data/shared_prefs /shared_prefs
180 mount /sdcard/cache /tmp
182 cp /system/build.prop /tmp/build.prop
185 ### Is this a Kaiser?
186 if [ "`cat /proc/cpuinfo|grep -o Kaiser`" = "Kaiser" ]; then
187 echo "KAISER detected"
189 sed -i s/^#wifi/wifi/ /tmp/build.prop
190 if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
191 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
192 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
194 mount --bind /etc/wifi /system/lib/modules
195 elif [ "`cat /proc/cpuinfo|grep -o Polaris`" = "Polaris" ]; then
196 echo "POLARIS detected"
198 sed -i s/^#wifi/wifi/ /tmp/build.prop
199 if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
200 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
201 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
203 mount --bind /etc/wifi /system/lib/modules
204 elif [ "`cat /proc/cpuinfo|grep -o Diamond`" = "Diamond" ]; then
205 echo "DIAMOND detected"
207 sed -i s/^#wifi/wifi/ /tmp/build.prop
208 if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
209 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
210 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
212 mount --bind /etc/wifi /system/lib/modules
213 elif [ "`cat /proc/cpuinfo|grep -o Raphael`" = "Raphael" ]; then
214 echo "RAPHAEL detected"
216 sed -i s/^#wifi/wifi/ /tmp/build.prop
217 if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
218 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
219 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
221 mount --bind /etc/wifi /system/lib/modules
222 elif [ "`cat /proc/cpuinfo|grep -o blackstone`" = "blackstone" ]; then
223 echo "BLACKSTONE detected"
225 sed -i s/^#wifi/wifi/ /tmp/build.prop
226 if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
227 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
228 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
230 mount --bind /etc/wifi /system/lib/modules
231 elif [ "`cat /proc/cpuinfo|grep -o Topaz`" = "Topaz" ]; then
232 echo "TOPAZ detected"
234 sed -i s/^#wifi/wifi/ /tmp/build.prop
235 if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
236 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
237 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
239 mount --bind /etc/wifi /system/lib/modules
240 elif [ "`cat /proc/cpuinfo|grep -o Rhodium`" = "Rhodium" ]; then
241 echo "RHODIUM detected"
243 sed -i s/^#wifi/wifi/ /tmp/build.prop
244 if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
245 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
246 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
248 mount --bind /etc/wifi /system/lib/modules
250 echo "VOGUE detected"
251 sed -i s/^wifi/#wifi/ /tmp/build.prop
254 mount --bind /tmp/build.prop /system/build.prop
256 ### Fix su on some builds...
257 mount --bind /bin/su /system/bin/su
258 mount --bind /bin/su /system/xbin/su
263 echo "Checking for build type..."
264 if [ -f /system/hero.build ] ; then
265 echo "Hero build detected"
268 ln /data/app_s /system/app
270 elif [ -f /system/eclairhero.build ] ; then
271 echo "HERO 2.1 BUILD DETECTED -- ECLAIR"
272 RCSCRIPT="eclairhero"
273 RCCONFIG="eclairhero"
275 elif [ -f /system/eclair.build ] ; then
276 echo "Eclair build detected"
280 elif [ -f /system/tattoo.build ] ; then
281 echo "Tattoo build detected"
285 elif [ -f /system/donut.build ] ; then
286 echo "Donut build detected"
290 elif [ -d /system/lib/donut ] ; then
291 echo "Donut build detected"
295 elif [ -f /system/xrom.build ] ; then
296 echo "xROM build detected"
300 elif [ -f /system/rogers.build ] ; then
301 echo "Rogers build detected"
305 elif [ -f /system/cyanogen.build ] ; then
306 echo "cyanogen experimental detected.....eating donuts"
310 elif [ -f /system/custom.build ] ; then
311 echo "Custom init.rc detected"
312 cp /system/sysinit.rc /build.cfg/init.sysinit.rc
317 echo "Unknown Android build. Assuming Ion variant"
321 # for the fake sensors library
322 mount /lib/hw /system/lib/hw -o loop
323 chmod 666 /dev/input/event0
325 if [ $DIAMOND -eq 1 ] ; then
326 RCCONFIG="ion.diamond"
330 if [ $KAISER -eq 1 ] ; then
331 RCSCRIPT="$RCSCRIPT.kaiser"
334 echo "using /init.$RCSCRIPT.rc as init.rc"
335 echo "using $card/conf/$RCCONFIG.user.conf"
337 cp "/init.cfg/init.$RCSCRIPT.rc" /etc/init.rc
339 #Assume this rootfs.img will be used only on "good" devices
340 #Meaning raph/diam/blac/
342 # echo /dev/block/mmcblk0p2 > /sys/devices/platform/usb_mass_storage/lun0/file
343 ifconfig usb0 192.168.20.1 up
344 busybox telnetd -b 192.168.20.1 -l /bin/sh
346 #mkdir -m 0777 /smodem
349 if [ "$DIAMOND" = "1" ];then
350 if [ -e "/sdcard/modules-$(uname -r).tar.gz" ] ;then
352 mount --bind /data/modules /lib/modules
353 tar xzf /sdcard/modules-$(uname -r).tar.gz -C /lib/modules
355 for i in xvmalloc ramzswap;do
360 sed -i s/^#wifi/wifi/ /tmp/build.prop
361 if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
362 echo "wifi.interface = wlan0" >> /tmp/build.prop
363 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
365 mount --bind /etc/wifi /system/lib/modules
369 if [ -f "$card/conf/$RCCONFIG.user.conf" ]; then
370 /bin/userinit.sh -c "$card/conf/$RCCONFIG.user.conf"
372 echo "No user config files ($RCCONFIG) found on sdcard"
375 mount -tdebugfs none /dbgfs
376 #Activate baclight control
377 echo 3 > /sys/class/htc_hw/test
379 echo 40 >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
380 #Activate full charging
381 echo 2 > /dbgfs/htc_battery/charger_state
383 echo 1 > /dbgfs/htcraphaelmmc_dbg/wifi_pwr
384 echo 1 > /dbgfs/htcraphaelmmc_dbg/wifi_cd
385 echo 1024 > /dbgfs/micropklt_dbg/sleep_leds
387 if /bin/grep -c 'physkeyboard=fuze' /proc/cmdline >/dev/null ; then
388 echo "USING RAPH110|FUZE LAYOUT"
389 cp -f /init.etc/keymaps/fuze_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
390 cp -f /init.etc/keymaps/fuze_microp-keypad.kl /etc/keymaps/microp-keypad.kl
391 cp -f /init.etc/keymaps/fuze_raph_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
392 elif /bin/grep -c 'physkeyboard=raph' /proc/cmdline >/dev/null ; then
393 echo "USING NEW RAPH LAYOUT"
394 cp -f /init.etc/keymaps/raphfix_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
395 elif /bin/grep -c 'physkeyboard=tilt2' /proc/cmdline >/dev/null ; then
396 echo "USING EXPERIMENTAL TILT2 LAYOUT"
397 cp -f /init.etc/keymaps/tilt2_microp-keypad.kl /etc/keymaps/microp-keypad.kl
398 cp -f /init.etc/keymaps/tilt2_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
399 cp -f /init.etc/keymaps/tilt2_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
400 elif /bin/grep -c 'physkeyboard=rhod210' /proc/cmdline >/dev/null ; then
401 echo "USING EXPERIMENTAL RHOD210 LAYOUT"
402 cp -f /init.etc/keymaps/rhod210_microp-keypad.kl /etc/keymaps/microp-keypad.kl
403 cp -f /init.etc/keymaps/rhod210_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
404 cp -f /init.etc/keymaps/rhod210_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
406 echo "USING OLD KEYMAP"
407 cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
408 cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kl /etc/keymaps/microp-keypad.kl
409 cp -f /init.etc/keymaps/oldqwerty_raph_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
412 for i in /sys/class/input/input* ; do
413 if [ "`cat $i/name`" = "tssc-manager" ] ; then
415 echo "Touchscreen device directory is $i"
419 if [ -f $card/ts-calibration ] ; then
420 echo "Using Saved Touchscreen Calibration"
421 echo 128,128,1903,128,128,1907,1903,1907,1024,1024 > $touchscreendir/calibration_screen
422 cat $card/ts-calibration > $touchscreendir/calibration_points
425 mknod /dev/graphics/fb0 c 29 0
427 echo; echo; echo; echo; echo; echo; echo; echo "Calibrating Touchscreen:"
428 echo "Click the Five Targets in order -- Top Left, Top Right, Middle, Bottom Left, Bottom Right"
429 echo "(Tap lightly. The screen is quite sensitive.)"
431 echo 0,0,0,0,0,0,0,0,0,0 | cmp -s $touchscreendir/calibration_points # determine if calibration is still null -- means failed calibration
432 if [ $? -eq 0 ] ; then
433 echo "Touchscreen Calibration Failed"
435 echo "Touchscreen Calibration Successful; Saving..."
436 cat $touchscreendir/calibration_points > $card/ts-calibration