8 /bin/mount -o remount,rw / /
10 PATH=/sbin:/system/sbin:/bin:/system/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
17 echo 2048 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
18 echo 7 > /proc/sys/vm/laptop_mode
19 echo 90 > /proc/sys/vm/dirty_ratio
20 echo 60000 > /proc/sys/vm/dirty_expire_centisecs
21 echo 60000 > /proc/sys/vm/dirty_writeback_centisecs
26 if [ $notnand = "0" ] ; then
27 echo "running from NAND"
28 /bin/mount -t yaffs2 /dev/block/mtdblock2 /system
29 /bin/mount -t yaffs2 /dev/block/mtdblock3 /data
34 # Try unpartitioned card
35 if [ ! -d /sys/block/mmcblk0/$partition ] ; then
39 if [ -f /sys/class/vogue_hw/gsmphone ] ; then
40 echo "GSM phone found"
43 #mkdir -m 0777 /sdcard
44 #fsck already done in initrd
45 mount -t vfat -o fmask=0000,dmask=0000,rw,flush,relatime,utf8 /dev/block/$partition /sdcard
46 [ $? -eq 0 ] || fail "Failed to mount the SD card. Cannot continue."
48 if [ ! -d /sdcard/cache ] ; then
53 mount /sdcard/cache /cache
55 CARD_PATH=`/bin/grep -o "rel_path=.*" /proc/cmdline | /bin/sed -e "s/.*rel_path=//g" -e "s/ .*//g"`
56 if [ "$CARD_PATH" = "" ];then
59 if [ -d /sdcard/$CARD_PATH ] ; then
60 card=/sdcard/$CARD_PATH
66 if [ $notnand = "1" ] ; then
68 if [ -f $card/data.gz ] ; then
69 echo "Please wait... extracting Data Image"
70 if [ -f $card/data.img ] ; then
73 gzip -df $card/data.gz
74 [ $? -eq 0 ] || fail "Failed to extract Data Image"
75 mv $card/data $card/data.img
79 if [ -d /sys/block/mmcblk0/mmcblk0p4 ] && /bin/grep -q -v no_partitions /proc/cmdline ; then
80 echo "Using partitioned system"
81 /bin/e2fsck -y /dev/block/mmcblk0p3
82 mount -t ext2 -o relatime /dev/block/mmcblk0p3 /system
83 /bin/e2fsck -y /dev/block/mmcblk0p4
84 mount -t ext2 -o relatime /dev/block/mmcblk0p4 /data
86 echo "Using loopback filesystems"
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"
95 losetup /dev/block/loop0 $card/data.img
96 [ $? -eq 0 ] || fail "Failed to find data.img on SD Card"
97 e2fsck -y /dev/block/loop0
98 mount -t ext2 -o relatime /dev/block/loop0 /data
100 losetup /dev/block/loop1 $card/system.ext2
101 [ $? -eq 0 ] || fail "Failed to reach system.ext2 on SD Card"
102 e2fsck -y /dev/block/loop1
103 mount -t ext2 -o relatime /dev/block/loop1 /system
104 [ $? -eq 0 ] || fail "Failed to mount /system"
108 if [ -f "$card/update.zip" ] && [ ! -f "/sdcard/cache/recovery/intent" ] && [ -z "$SQUASH" ]
110 RECOVERYCARD=$(echo $card | sed -e 's:/sdcard/:SDCARD\::')
112 echo "STARTING OTA UPDATE SYSTEM"
113 cp /init.cfg/init.recovery.rc /etc/init.rc
114 mkdir /cache/recovery
115 echo "--update_package=${RECOVERYCARD}/update.zip" >/cache/recovery/command
116 echo "--send_intent=complete" >>/cache/recovery/command
120 # If not updating, ensure old recovery.intent and update.zip files are removed so we can update again later.
121 rm -f /sdcard/cache/recovery/intent
122 rm -f $card/update.zip
124 if [ -d $card/AndroidApps ] ; then
125 echo Copying Applications
126 if [ ! -d /data/app ] ; then
127 mkdir -m 0771 /data/app
128 chown -R 1000:1000 /data/app
130 (cd $card/AndroidApps; for i in *; do if [ ! -f "/data/app/$i" -o "$i" -nt "/data/app/$i" ]; then \
131 cp "$i" /data/app; fi done)
134 if [ ! -d $card/media ] ; then
135 echo You have no media folder, please extract the resources to your SD card android folder
138 CHK_ROOT=etc/wifi/Fw1251r1c.bin
139 if [ ! -f /system/$CHK_ROOT -o /init.$CHK_ROOT -nt /system/$CHK_ROOT ]; then
145 if [ $NEW_ROOT -eq 1 ]; then
146 cp -ar /init.etc/* /system/etc
149 LCDDENSITY=`/bin/grep -o "lcd.density=.*" /proc/cmdline | /bin/sed -e "s/.*lcd.density=//g" -e "s/ .*//g"`
151 if [ "$LCDDENSITY" != "" ] ; then
152 DENS2=`grep lcd_density /system/etc/default.prop | sed -e 's/.*=//'`
153 if [ "$LCDDENSITY" != "$DENS2" ]; then
154 echo Setting ro.sf.lcd_density=$LCDDENSITY
155 if [ -z "$DENS2" ]; then
156 echo "ro.sf.lcd_density=$LCDDENSITY" >> /system/etc/default.prop
158 sed -i /lcd_density/s/=.*/=$LCDDENSITY/ /system/etc/default.prop
163 mount /sdcard/cache /tmp
171 HW=`cat /proc/cpuinfo | grep Hardware`
174 echo "KAISER detected"
180 echo "POLARIS detected"
186 echo "DIAMOND detected"
192 echo "RAPHAEL detected"
198 echo "BLACKSTONE detected"
205 echo "TOPAZ detected"
212 echo "XPERIA detected"
219 echo "RHODIUM detected"
226 echo "VOGUE detected"
231 ### Fix su on some builds...
232 mount --bind /bin/su /system/bin/su 2> /dev/null
233 mount --bind /bin/su /system/xbin/su 2> /dev/null
238 echo "Checking for build type..."
239 if [ -f /system/hero.build ] ; then
240 echo "Hero build detected"
243 ln /data/app_s /system/app
245 elif [ -f /system/eclairhero.build ] ; then
246 echo "HERO 2.1 BUILD DETECTED -- ECLAIR"
247 RCSCRIPT="eclairhero"
248 RCCONFIG="eclairhero"
249 mount --bind /lib/eclair/hw /system/lib/hw
251 elif [ -f /system/eclair.build ] ; then
252 echo "Eclair build detected"
255 mount --bind /lib/eclair/hw /system/lib/hw
257 elif [ -f /system/froyo.build ] ; then
258 echo "Froyo build detected"
261 mount --bind /lib/froyo/hw /system/lib/hw
263 elif [ -f /system/gingerbread.build ] ; then
264 echo "Gingerbread build detected"
265 RCSCRIPT="gingerbread"
266 RCCONFIG="gingerbread"
268 elif [ -f /system/tattoo.build ] ; then
269 echo "Tattoo build detected"
273 elif [ -f /system/donut.build ] ; then
274 echo "Donut build detected"
277 mount --bind /lib/donut/hw /system/lib/hw
279 elif [ -d /system/lib/donut ] ; then
280 echo "Donut build detected"
284 elif [ -f /system/xrom.build ] ; then
285 echo "xROM build detected"
289 elif [ -f /system/rogers.build ] ; then
290 echo "Rogers build detected"
294 elif [ -f /system/cyanogen.build ] ; then
295 echo "cyanogen experimental detected.....eating donuts"
299 elif [ -f /system/custom.build ] ; then
300 echo "Custom init.rc detected"
301 cp /system/sysinit.rc /build.cfg/init.sysinit.rc
306 echo "Unknown Android build. Assuming Ion variant"
310 # for the fake sensors library
311 mount /lib/hw /system/lib/hw -o loop
312 chmod 666 /dev/input/event0
314 if [ $DIAMOND -eq 1 ] ; then
315 RCCONFIG="ion.diamond"
319 if [ $KAISER -eq 1 ] ; then
320 RCSCRIPT="$RCSCRIPT.kaiser"
323 if [ "$LCDDENSITY" != "" ] ; then
324 DENS2=`grep lcd_density /system/etc/default.prop | sed -e 's/.*=//'`
325 if [ "$LCDDENSITY" != "$DENS2" ]; then
326 echo Setting ro.sf.lcd_density=$LCDDENSITY
327 if [ -z "$DENS2" ]; then
328 echo "ro.sf.lcd_density=$LCDDENSITY" >> /system/etc/default.prop
330 sed -i /lcd_density/s/=.*/=$LCDDENSITY/ /system/etc/default.prop
334 if [ $XPERIA -eq 1 ] ; then
335 ROT=`grep hwrotation /system/etc/default.prop | sed -e 's/.*=//'`
336 if [ "$ROT" != 180 ]; then
337 echo Setting ro.sf.hwrotation=180
338 if [ -z "$ROT" ]; then
339 echo "ro.sf.hwrotation=180" >> /system/etc/default.prop
341 sed -i /hwrotation/s/=.*/=180/ /system/etc/default.prop
345 echo "using $card/conf/$RCCONFIG.user.conf"
347 if [ $NEW_ROOT -eq 1 ]; then
348 echo "using /init.$RCSCRIPT.rc as init.rc"
349 cp "/init.cfg/init.$RCSCRIPT.rc" /system/etc/init.rc
352 #Assume this rootfs.img will be used only on "good" devices
353 #Meaning raph/diam/blac/
355 # echo /dev/block/mmcblk0p2 > /sys/devices/platform/usb_mass_storage/lun0/file
356 ifconfig usb0 192.168.20.1 up
357 busybox telnetd -b 192.168.20.1 -l /bin/sh
359 #mkdir -m 0777 /smodem
360 mknod /dev/urandom c 1 9
361 if [ -d /data/dropbear/ ] ; then
363 mknod /dev/random c 1 8
364 /bin/dropbear -r /data/dropbear/dropbear_rsa_host_key -s
367 if [ "$WIFI_TI" = "1" ] || [ "$WIFI_BCM" = "1" ];then
368 if [ -e "$card/modules-$(uname -r).tar.gz" ] && ! `strings /lib/modules/mac80211.ko 2>/dev/null | grep -q "vermagic=$(uname -r)"`; then
369 echo "Installing $card/modules-$(uname -r).tar.gz"
370 tar xzf $card/modules-$(uname -r).tar.gz -C /lib/modules
371 ln -s /lib/modules /lib/modules/`uname -r`
373 echo "Modules already unpacked for this kernel version -- skipping installation of $card/modules-$(uname -r).tar.gz"
376 if [ -f /system/etc/wifi/wlan.ko ]; then
377 cp -R /system/etc/wifi/* /lib/modules/
378 rm /system/etc/wifi/wlan.ko
382 if [ "`grep -c ^wifi /system/etc/default.prop`" != "2" ]; then
383 echo "wifi.interface = wlan0" >> /system/etc/default.prop
384 echo "wifi.supplicant_scan_interval = 45" >> /system/etc/default.prop
388 if [ -f /system/eclair.build ]
390 mount --bind /lib/eclair/libhardware_legacy.so /system/lib/libhardware_legacy.so
393 # fix PPP data device name
394 if [ $NEW_ROOT -eq 1 ]; then
395 if [ -f /dev/smd7 ]; then
400 sed -i s,PPPDEV,$PPPDEV, /system/etc/init.rc
404 if [ "$WIFI_BCM" = "1" ] ;then
405 # fyi: firmware is loaded from /data/etc/wifi/bcm432x/bcm4325-rtecdc.bin, nvram from /data/wifi-nvram.txt
407 if [ $NEW_ROOT -eq 1 ]; then
408 # init.rc: fix wpa_supplicant service
409 sed -i s/-Dtiwlan0/-Dwext/ /system/etc/init.rc
412 sed -i s/user\ wifi/#user\ wifi/ /system/etc/init.rc
413 sed -i s/group\ wifi/#group\ wifi/ /system/etc/init.rc
416 # extract nvram (todo: clean this up/integrate with TI calibration)
417 if [ ! -e /data/wifi-nvram.txt ]; then
418 insmod /lib/modules/mtdchar.ko
419 mknod /dev/mtd0ro c 90 1
420 for SKIP in 5744 4736;do
421 mkdir /lib/modules/$(uname -r)
423 dd if=/dev/mtd0ro of=/tmp/tempcal bs=8192 count=1 skip=$SKIP
424 rmdir /lib/modules/$(uname -r)
425 dd if=/tmp/tempcal of=/data/wifi-nvram.txt bs=1 count=466
428 if grep nocrc= /data/wifi-nvram.txt 2>&1 > /dev/null;then
434 if [ "$SKIP" = "5744" ];then
435 echo "CDMA Rhodium detected"
437 if [ "$SKIP" = "4736" ];then
438 echo "GSM Rhodium detected"
444 for i in local.prop eri.xml serialno; do
445 if [ -f "$card/$i" ]; then
446 if [ ! -f /data/$i -o "$card/$i" -nt /data/$i ]; then
447 cp "$card/$i" /data/$i
452 if [ -f "$card/conf/$RCCONFIG.user.conf" ]; then
453 /bin/userinit.sh -c "$card/conf/$RCCONFIG.user.conf"
455 echo "No user config files ($RCCONFIG) found on sdcard"
458 mount -tdebugfs none /dbgfs
459 #Activate baclight control
460 echo 3 > /sys/class/htc_hw/test
462 echo 40 >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
463 #Activate full charging
464 echo 2 > /dbgfs/htc_battery/charger_state
466 echo 1024 > /dbgfs/micropklt_dbg/sleep_leds
468 if [ $NEW_ROOT -eq 1 ]; then
469 KBD=`sed 's/.*physkeyboard=\([0-9a-z_]*\).*/\1/' /proc/cmdline`
472 echo "USING RAPH110|FUZE LAYOUT"
473 cp -f /init.etc/keymaps/fuze_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
474 cp -f /init.etc/keymaps/fuze_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
475 cp -f /init.etc/keymaps/fuze_raph_navi_pad.kl /system/usr/keylayout/raph_navi_pad.kl
478 echo "USING NEW RAPH LAYOUT"
479 cp -f /init.etc/keymaps/raphfix_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
482 echo "USING NEW NORDIC RAPH LAYOUT"
483 cp -f /init.etc/keymaps/raphfix_microp-keypad-swedish.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
486 echo "USING NEW GERMAN RAPH LAYOUT"
487 cp -f /init.etc/keymaps/microp-german.keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
490 echo "USING NEW SWISS RAPH LAYOUT"
491 cp -f /init.etc/keymaps/microp-swiss.keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
494 echo "USING EXPERIMENTAL TILT2 LAYOUT"
495 cp -f /init.etc/keymaps/tilt2_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
496 cp -f /init.etc/keymaps/tilt2_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
497 cp -f /init.etc/keymaps/tilt2_navi_pad.kl /system/usr/keylayout/raph_navi_pad.kl
500 echo "USING EXPERIMENTAL RHOD210 LAYOUT"
501 cp -f /init.etc/keymaps/rhod210_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
502 cp -f /init.etc/keymaps/rhod210_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
503 cp -f /init.etc/keymaps/rhod210_navi_pad.kl /system/usr/keylayout/gpio-keys.kl
506 echo "USING RHOD100 DE LAYOUT"
507 cp -f /init.etc/keymaps/rhod100_de_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
508 cp -f /init.etc/keymaps/rhod100_de_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
509 cp -f /init.etc/keymaps/rhod100_de_navi_pad.kl /system/usr/keylayout/gpio-keys.kl
512 echo "USING RHOD100 FR LAYOUT"
513 cp -f /init.etc/keymaps/rhod100_fr_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
514 cp -f /init.etc/keymaps/rhod100_fr_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
515 cp -f /init.etc/keymaps/rhod100_fr_navi_pad.kl /system/usr/keylayout/gpio-keys.kl
518 echo "USING RHOD100 IT LAYOUT"
519 cp -f /init.etc/keymaps/rhod100_it_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
520 cp -f /init.etc/keymaps/rhod100_it_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
521 cp -f /init.etc/keymaps/rhod100_it_navi_pad.kl /system/usr/keylayout/gpio-keys.kl
524 echo "USING RHOD100 UK LAYOUT"
525 cp -f /init.etc/keymaps/rhod100_uk_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
526 cp -f /init.etc/keymaps/rhod100_uk_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
527 cp -f /init.etc/keymaps/rhod100_uk_navi_pad.kl /system/usr/keylayout/gpio-keys.kl
530 echo "USING RHOD100 NORDIC LAYOUT"
531 cp -f /init.etc/keymaps/rhod100_nordic_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
532 cp -f /init.etc/keymaps/rhod100_nordic_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
533 cp -f /init.etc/keymaps/rhod100_nordic_navi_pad.kl /system/usr/keylayout/gpio-keys.kl
536 echo "USING EXPERIMENTAL RHOD400 LAYOUT"
537 cp -f /init.etc/keymaps/rhod400_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
538 cp -f /init.etc/keymaps/rhod400_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
539 cp -f /init.etc/keymaps/rhod400_navi_pad.kl /system/usr/keylayout/gpio-keys.kl #does not exist, just following example
542 echo "USING EXPERIMENTAL RHOD500 LAYOUT"
543 cp -f /init.etc/keymaps/rhod500_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
544 cp -f /init.etc/keymaps/rhod500_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
545 cp -f /init.etc/keymaps/rhod500_navi_pad.kl /system/usr/keylayout/gpio-keys.kl #does not exist, just following example
548 echo "USING KOVSKY QWERTY LAYOUT"
549 cp -f /init.etc/keymaps/kovsky-qwerty.kl /system/usr/keylayout/microp-keypad.kl
550 cp -f /init.etc/keymaps/kovsky-qwerty.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
553 echo "USING KOVSKY AZERTY LAYOUT"
554 cp -f /init.etc/keymaps/kovsky-azerty.kl /system/usr/keylayout/microp-keypad.kl
555 cp -f /init.etc/keymaps/kovsky-azerty.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
558 echo "USING OLD KEYMAP"
559 cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
560 cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kl /system/usr/keylayout/microp-keypad.kl
561 cp -f /init.etc/keymaps/oldqwerty_raph_navi_pad.kl /system/usr/keylayout/gpio-keys.kl
567 mount -o remount,ro /system
569 for i in /sys/class/input/input* ; do
570 if [ "`cat $i/name`" = "tssc-manager" ] ; then
572 echo "Touchscreen device directory is $i"
576 if [ -f $card/ts-calibration ] ; then
577 echo "Using Saved Touchscreen Calibration"
578 echo 128,128,1903,128,128,1907,1903,1907,1024,1024 > $touchscreendir/calibration_screen
579 cat $card/ts-calibration > $touchscreendir/calibration_points
582 mknod /dev/graphics/fb0 c 29 0
584 echo; echo; echo; echo; echo; echo; echo; echo "Calibrating Touchscreen:"
585 echo "Click the Five Targets in order -- Top Left, Top Right, Middle, Bottom Left, Bottom Right"
586 echo "(Tap lightly. The screen is quite sensitive.)"
588 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
589 if [ $? -eq 0 ] ; then
590 echo "Touchscreen Calibration Failed"
592 echo "Touchscreen Calibration Successful; Saving..."
593 cat $touchscreendir/calibration_points > $card/ts-calibration
597 mkdir /dev/msm_camera
598 mknod /dev/msm_camera/control0 c 250 0
599 mknod /dev/msm_camera/config0 c 250 1
600 mknod /dev/msm_camera/frame0 c 250 2
602 # Generate a "serial number" for the Android system to identify the device.
603 # Put it in /data so it survives reboots. Won't survive a factory reset, though.
604 [ -f "/data/serialno" ] || echo -e `cat /dev/urandom | tr -dc 'A-Z0-9' | fold -w 12 | head -n 1` >/data/serialno
606 SERIALNO=$(cat /data/serialno)
607 cp /proc/cmdline /tmp/cmdline
608 sed -i -e "s:$: androidboot.serialno=${SERIALNO}:" /tmp/cmdline
609 mount --bind /tmp/cmdline /proc/cmdline