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
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
28 # Try unpartitioned card
29 if [ ! -d /sys/block/mmcblk0/$partition ] ; then
33 if [ -f /sys/class/vogue_hw/gsmphone ] ; then
34 echo "GSM phone found"
37 #mkdir -m 0777 /sdcard
38 #fsck already done in initrd
39 mount -t vfat -o fmask=0000,dmask=0000,rw,flush,relatime,utf8 /dev/block/$partition /sdcard
40 [ $? -eq 0 ] || fail "Failed to mount the SD card. Cannot continue."
42 if [ ! -d /sdcard/cache ] ; then
47 mount /sdcard/cache /cache
49 CARD_PATH=`/bin/grep -o "rel_path=.*" /proc/cmdline | /bin/sed -e "s/.*rel_path=//g" -e "s/ .*//g"`
50 if [ "$CARD_PATH" = "" ];then
53 if [ -d /sdcard/$CARD_PATH ] ; then
54 card=/sdcard/$CARD_PATH
60 if [ $notnand = "1" ] ; then
62 if [ -f $card/data.gz ] ; then
63 echo "Please wait... extracting Data Image"
64 if [ -f $card/data.img ] ; then
67 gzip -df $card/data.gz
68 [ $? -eq 0 ] || fail "Failed to extract Data Image"
69 mv $card/data $card/data.img
73 if [ -d /sys/block/mmcblk0/mmcblk0p4 ] && /bin/grep -q -v no_partitions /proc/cmdline ; then
74 echo "Using partitioned system"
75 /bin/e2fsck -y /dev/block/mmcblk0p3
76 mount -t ext2 -o ro,relatime /dev/block/mmcblk0p3 /system
77 /bin/e2fsck -y /dev/block/mmcblk0p4
78 mount -t ext2 -o relatime /dev/block/mmcblk0p4 /data
80 echo "Using loopback filesystems"
81 if [ ! -f $card/data.img ] ; then
82 echo "Creating a new Data store"
83 dd if=/dev/zero of=$card/data.img bs=1048576 count=256
84 [ $? -eq 0 ] || fail "Failed to allocate the storage"
85 mke2fs -F $card/data.img
86 [ $? -eq 0 ] || fail "Failed to format the storage"
89 losetup /dev/block/loop0 $card/data.img
90 [ $? -eq 0 ] || fail "Failed to find data.img on SD Card"
91 e2fsck -y /dev/block/loop0
92 mount -t ext2 -o relatime /dev/block/loop0 /data
94 if [ -f $card/system.ext2 ] ; then
95 echo "Using uncompressed system"
96 losetup /dev/block/loop1 $card/system.ext2
97 [ $? -eq 0 ] || fail "Failed to reach system.ext2 on SD Card"
98 e2fsck -y /dev/block/loop1
99 mount -t ext2 -o relatime /dev/block/loop1 /system
100 [ $? -eq 0 ] || fail "Failed to mount /system"
102 [ -f $card/system.sqsh ] ; then
103 echo "Using SquashFS system"
104 losetup /dev/block/loop1 $card/system.sqsh
105 [ $? -eq 0 ] || fail "Failed to find system.sqsh on SD Card"
106 mount -t squashfs -o ro,relatime /dev/block/loop1 /system
107 [ $? -eq 0 ] || fail "Failed to mount /system"
110 losetup /dev/block/loop1 $card/system.img
111 [ $? -eq 0 ] || fail "Failed to find system.img on SD Card"
112 mount -t cramfs -o ro,relatime /dev/block/loop1 /system
113 [ $? -eq 0 ] || fail "Failed to mount /system"
118 if [ -f "$card/update.zip" ] && [ ! -f "/sdcard/cache/recovery/intent" ] && [ -z "$SQUASH" ]
120 RECOVERYCARD=$(echo $card | sed -e 's:/sdcard/:SDCARD\::')
122 echo "STARTING OTA UPDATE SYSTEM"
123 cp /init.cfg/init.recovery.rc /etc/init.rc
124 mkdir /cache/recovery
125 echo "--update_package=${RECOVERYCARD}/update.zip" >/cache/recovery/command
126 echo "--send_intent=complete" >>/cache/recovery/command
130 # If not updating, ensure old recovery.intent and update.zip files are removed so we can update again later.
131 rm -f /sdcard/cache/recovery/intent
132 rm -f $card/update.zip
134 if [ -d $card/AndroidApps ] ; then
135 echo Copying Applications
136 if [ ! -d /data/app ] ; then
137 mkdir -m 0771 /data/app
138 chown -R 1000:1000 /data/app
140 (cd $card/AndroidApps; for i in *; do if [ "$i" -nt "/data/app/$i" ]; then \
141 cp "$i" /data/app; fi done)
144 if [ ! -d $card/media ] ; then
145 echo You have no media folder, please extract the resources to your SD card android folder
151 if [ ! -d /data/etc ]; then
152 /bin/mkdir -m 0755 /data/etc
153 /bin/mkdir -p -m 0700 /data/mnt/secure
154 mkdir -m 0770 /data/shared_prefs
155 chown 1000:1000 /data/shared_prefs
159 CHK_SYS=etc/event-log-tags
160 if [ ! -f /data/$CHK_SYS -o /system/$CHK_SYS -nt /data/$CHK_SYS ]; then
163 CHK_ROOT=etc/wifi/Fw1251r1c.bin
164 if [ ! -f /data/$CHK_ROOT -o /init.$CHK_ROOT -nt /data/$CHK_ROOT ]; then
169 mount --bind /data/mnt/secure /mnt/secure
170 mount /data/shared_prefs /shared_prefs
172 if [ $NEW_SYSTEM -eq 1 ]; then
173 cp -ar /system/etc/* /data/etc
175 if [ $NEW_ROOT -eq 1 ]; then
176 cp -ar /init.etc/* /data/etc
181 LCDDENSITY=`/bin/grep -o "lcd.density=.*" /proc/cmdline | /bin/sed -e "s/.*lcd.density=//g" -e "s/ .*//g"`
183 if [ "$LCDDENSITY" != "" ] ; then
184 DENS2=`grep lcd_density /etc/default.prop | sed -e 's/.*=//'`
185 if [ "$LCDDENSITY" != "$DENS2" ]; then
186 echo Setting ro.sf.lcd_density=$LCDDENSITY
187 if [ -z "$DENS2" ]; then
188 echo "ro.sf.lcd_density=$LCDDENSITY" >> /etc/default.prop
190 sed -i /lcd_density/s/=.*/=$LCDDENSITY/ /etc/default.prop
195 mount /sdcard/cache /tmp
203 HW=`cat /proc/cpuinfo | grep Hardware`
206 echo "KAISER detected"
212 echo "POLARIS detected"
218 echo "DIAMOND detected"
224 echo "RAPHAEL detected"
230 echo "BLACKSTONE detected"
237 echo "TOPAZ detected"
244 echo "XPERIA detected"
251 echo "RHODIUM detected"
258 echo "VOGUE detected"
263 ### Fix su on some builds...
264 mount --bind /bin/su /system/bin/su 2> /dev/null
265 mount --bind /bin/su /system/xbin/su 2> /dev/null
270 echo "Checking for build type..."
271 if [ -f /system/hero.build ] ; then
272 echo "Hero build detected"
275 ln /data/app_s /system/app
277 elif [ -f /system/eclairhero.build ] ; then
278 echo "HERO 2.1 BUILD DETECTED -- ECLAIR"
279 RCSCRIPT="eclairhero"
280 RCCONFIG="eclairhero"
281 mount --bind /lib/eclair/hw /system/lib/hw
283 elif [ -f /system/eclair.build ] ; then
284 echo "Eclair build detected"
287 mount --bind /lib/eclair/hw /system/lib/hw
289 elif [ -f /system/froyo.build ] ; then
290 echo "Froyo build detected"
293 mount --bind /lib/froyo/hw /system/lib/hw
295 # vold: Fix sdcard device location for CDMA boards (thanks paalsteek)
296 if [ $NEW_SYSTEM -eq 1 -a -d /sys/devices/platform/msm_sdcc.3 ]; then
297 /bin/sed -i -e 's:/devices/platform/msm_sdcc\.2:/devices/platform/msm_sdcc.3:g' /etc/vold.fstab
300 elif [ -f /system/gingerbread.build ] ; then
301 echo "Gingerbread build detected"
302 RCSCRIPT="gingerbread"
303 RCCONFIG="gingerbread"
305 # vold: Fix sdcard device location for CDMA boards (thanks paalsteek)
306 if [ $NEW_SYSTEM -eq 1 -a -d /sys/devices/platform/msm_sdcc.3 ]; then
307 /bin/sed -i -e 's:/devices/platform/msm_sdcc\.2:/devices/platform/msm_sdcc.3:g' /etc/vold.fstab
310 elif [ -f /system/tattoo.build ] ; then
311 echo "Tattoo build detected"
315 elif [ -f /system/donut.build ] ; then
316 echo "Donut build detected"
319 mount --bind /lib/donut/hw /system/lib/hw
321 elif [ -d /system/lib/donut ] ; then
322 echo "Donut build detected"
326 elif [ -f /system/xrom.build ] ; then
327 echo "xROM build detected"
331 elif [ -f /system/rogers.build ] ; then
332 echo "Rogers build detected"
336 elif [ -f /system/cyanogen.build ] ; then
337 echo "cyanogen experimental detected.....eating donuts"
341 elif [ -f /system/custom.build ] ; then
342 echo "Custom init.rc detected"
343 cp /system/sysinit.rc /build.cfg/init.sysinit.rc
348 echo "Unknown Android build. Assuming Ion variant"
352 # for the fake sensors library
353 mount /lib/hw /system/lib/hw -o loop
354 chmod 666 /dev/input/event0
356 if [ $DIAMOND -eq 1 ] ; then
357 RCCONFIG="ion.diamond"
361 if [ $KAISER -eq 1 ] ; then
362 RCSCRIPT="$RCSCRIPT.kaiser"
365 if [ $NEW_ROOT -eq 1 -a $XPERIA -eq 1 ] ; then
366 echo "ro.sf.hwrotation=180" >> /etc/default.prop
368 echo "using /init.$RCSCRIPT.rc as init.rc"
369 echo "using $card/conf/$RCCONFIG.user.conf"
371 if [ $NEW_ROOT -eq 1 ]; then
372 cp "/init.cfg/init.$RCSCRIPT.rc" /etc/init.rc
375 #Assume this rootfs.img will be used only on "good" devices
376 #Meaning raph/diam/blac/
378 # echo /dev/block/mmcblk0p2 > /sys/devices/platform/usb_mass_storage/lun0/file
379 ifconfig usb0 192.168.20.1 up
380 busybox telnetd -b 192.168.20.1 -l /bin/sh
382 #mkdir -m 0777 /smodem
383 mknod /dev/urandom c 1 9
384 if [ -d /data/dropbear/ ] ; then
386 mknod /dev/random c 1 8
387 /bin/dropbear -r /data/dropbear/dropbear_rsa_host_key -s
390 if [ "$WIFI_TI" = "1" ] || [ "$WIFI_BCM" = "1" ];then
391 if [ -e "$card/modules-$(uname -r).tar.gz" ] && ! `strings /data/modules/mac80211.ko 2>/dev/null | grep -q "vermagic=$(uname -r)"`; then
392 echo "Installing $card/modules-$(uname -r).tar.gz"
393 if [ ! -d "/data/modules" ] ; then
396 tar xzf $card/modules-$(uname -r).tar.gz -C /data/modules
397 ln -s /data/modules /data/modules/`uname -r`
399 echo "Modules already unpacked for this kernel version -- skipping installation of $card/modules-$(uname -r).tar.gz"
402 mount --bind /data/modules /lib/modules
403 mount --bind /data/modules /system/lib/modules
405 if [ -f /etc/wifi/wlan.ko ]; then
406 cp -R /etc/wifi/* /data/modules/
411 if [ "`grep -c ^wifi /etc/default.prop`" != "2" ]; then
412 echo "wifi.interface = wlan0" >> /etc/default.prop
413 echo "wifi.supplicant_scan_interval = 45" >> /etc/default.prop
417 if [ -f /system/eclair.build ]
419 mount --bind /lib/eclair/libhardware_legacy.so /system/lib/libhardware_legacy.so
422 # fix PPP data device name
423 if [ $NEW_ROOT -eq 1 ]; then
424 if [ -f /dev/smd7 ]; then
429 sed -i s,PPPDEV,$PPPDEV, /etc/init.rc
432 if [ "$WIFI_TI" = "1" ];then
433 ip link set dev tiwlan0 name wlan0
436 if [ "$WIFI_BCM" = "1" ] ;then
437 ip link set dev eth0 name wlan0
439 # fyi: firmware is loaded from /etc/wifi/bcm432x/bcm4325-rtecdc.bin, nvram from /data/wifi-nvram.txt
441 if [ $NEW_ROOT -eq 1 ]; then
442 # init.rc: fix wpa_supplicant service
443 sed -i s/-Dtiwlan0/-Dwext/ /etc/init.rc
446 sed -i s/user\ wifi/#user\ wifi/ /etc/init.rc
447 sed -i s/group\ wifi/#group\ wifi/ /etc/init.rc
450 # extract nvram (todo: clean this up/integrate with TI calibration)
451 if [ ! -e /data/wifi-nvram.txt ]; then
452 for SKIP in 5744 4736;do
453 insmod /lib/modules/mtdchar.ko
454 mknod /dev/mtd0ro c 90 1
455 mkdir /lib/modules/$(uname -r)
457 dd if=/dev/mtd0ro of=/tmp/tempcal bs=8192 count=1 skip=$SKIP
460 rmdir /lib/modules/$(uname -r)
461 dd if=/tmp/tempcal of=/data/wifi-nvram.txt bs=1 count=466
464 if grep nocrc= /data/wifi-nvram.txt 2>&1 > /dev/null;then
468 if [ "$SKIP" = "5744" ];then
469 echo "CDMA Rhodium detected"
471 if [ "$SKIP" = "4736" ];then
472 echo "GSM Rhodium detected"
478 if [ -f "$card/local.prop" -a "$card/local.prop" -nt /data/local.prop ]; then
479 cp "$card/local.prop" /data/local.prop
482 if [ -f "$card/conf/$RCCONFIG.user.conf" ]; then
483 /bin/userinit.sh -c "$card/conf/$RCCONFIG.user.conf"
485 echo "No user config files ($RCCONFIG) found on sdcard"
488 mount -tdebugfs none /dbgfs
489 #Activate baclight control
490 echo 3 > /sys/class/htc_hw/test
492 echo 40 >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
493 #Activate full charging
494 echo 2 > /dbgfs/htc_battery/charger_state
496 echo 1024 > /dbgfs/micropklt_dbg/sleep_leds
498 if [ $NEW_ROOT -eq 1 ]; then
499 KBD=`sed 's/.*physkeyboard=\([0-9a-z_]*\).*/\1/' /proc/cmdline`
502 echo "USING RAPH110|FUZE LAYOUT"
503 cp -f /init.etc/keymaps/fuze_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
504 cp -f /init.etc/keymaps/fuze_microp-keypad.kl /etc/keymaps/microp-keypad.kl
505 cp -f /init.etc/keymaps/fuze_raph_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
508 echo "USING NEW RAPH LAYOUT"
509 cp -f /init.etc/keymaps/raphfix_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
512 echo "USING NEW NORDIC RAPH LAYOUT"
513 cp -f /init.etc/keymaps/raphfix_microp-keypad-swedish.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
516 echo "USING NEW GERMAN RAPH LAYOUT"
517 cp -f /init.etc/keymaps/microp-german.keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
520 echo "USING NEW SWISS RAPH LAYOUT"
521 cp -f /init.etc/keymaps/microp-swiss.keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
524 echo "USING EXPERIMENTAL TILT2 LAYOUT"
525 cp -f /init.etc/keymaps/tilt2_microp-keypad.kl /etc/keymaps/microp-keypad.kl
526 cp -f /init.etc/keymaps/tilt2_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
527 cp -f /init.etc/keymaps/tilt2_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
530 echo "USING EXPERIMENTAL RHOD210 LAYOUT"
531 cp -f /init.etc/keymaps/rhod210_microp-keypad.kl /etc/keymaps/microp-keypad.kl
532 cp -f /init.etc/keymaps/rhod210_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
533 cp -f /init.etc/keymaps/rhod210_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
536 echo "USING RHOD100 DE LAYOUT"
537 cp -f /init.etc/keymaps/rhod100_de_microp-keypad.kl /etc/keymaps/microp-keypad.kl
538 cp -f /init.etc/keymaps/rhod100_de_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
539 cp -f /init.etc/keymaps/rhod100_de_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
542 echo "USING RHOD100 FR LAYOUT"
543 cp -f /init.etc/keymaps/rhod100_fr_microp-keypad.kl /etc/keymaps/microp-keypad.kl
544 cp -f /init.etc/keymaps/rhod100_fr_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
545 cp -f /init.etc/keymaps/rhod100_fr_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
548 echo "USING RHOD100 IT LAYOUT"
549 cp -f /init.etc/keymaps/rhod100_it_microp-keypad.kl /etc/keymaps/microp-keypad.kl
550 cp -f /init.etc/keymaps/rhod100_it_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
551 cp -f /init.etc/keymaps/rhod100_it_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
554 echo "USING RHOD100 UK LAYOUT"
555 cp -f /init.etc/keymaps/rhod100_uk_microp-keypad.kl /etc/keymaps/microp-keypad.kl
556 cp -f /init.etc/keymaps/rhod100_uk_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
557 cp -f /init.etc/keymaps/rhod100_uk_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
560 echo "USING RHOD100 NORDIC LAYOUT"
561 cp -f /init.etc/keymaps/rhod100_nordic_microp-keypad.kl /etc/keymaps/microp-keypad.kl
562 cp -f /init.etc/keymaps/rhod100_nordic_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
563 cp -f /init.etc/keymaps/rhod100_nordic_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
566 echo "USING EXPERIMENTAL RHOD400 LAYOUT"
567 cp -f /init.etc/keymaps/rhod400_microp-keypad.kl /etc/keymaps/microp-keypad.kl
568 cp -f /init.etc/keymaps/rhod400_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
569 cp -f /init.etc/keymaps/rhod400_navi_pad.kl /etc/keymaps/raph_navi_pad.kl #does not exist, just following example
572 echo "USING EXPERIMENTAL RHOD500 LAYOUT"
573 cp -f /init.etc/keymaps/rhod500_microp-keypad.kl /etc/keymaps/microp-keypad.kl
574 cp -f /init.etc/keymaps/rhod500_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
575 cp -f /init.etc/keymaps/rhod500_navi_pad.kl /etc/keymaps/raph_navi_pad.kl #does not exist, just following example
578 echo "USING KOVSKY QWERTY LAYOUT"
579 cp -f /init.etc/keymaps/kovsky-qwerty.kl /etc/keymaps/microp-keypad.kl
580 cp -f /init.etc/keymaps/kovsky-qwerty.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
583 echo "USING KOVSKY AZERTY LAYOUT"
584 cp -f /init.etc/keymaps/kovsky-azerty.kl /etc/keymaps/microp-keypad.kl
585 cp -f /init.etc/keymaps/kovsky-azerty.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
588 echo "USING OLD KEYMAP"
589 cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
590 cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kl /etc/keymaps/microp-keypad.kl
591 cp -f /init.etc/keymaps/oldqwerty_raph_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
595 cp -af /init.etc/keymaps/qwerty.kcm.bin /init.etc/keymaps/qwerty.kl /etc/keymaps/
598 mount --bind /etc/keymaps /system/usr/keychars
599 mount --bind /etc/keymaps /system/usr/keylayout
601 for i in /sys/class/input/input* ; do
602 if [ "`cat $i/name`" = "tssc-manager" ] ; then
604 echo "Touchscreen device directory is $i"
608 if [ -f $card/ts-calibration ] ; then
609 echo "Using Saved Touchscreen Calibration"
610 echo 128,128,1903,128,128,1907,1903,1907,1024,1024 > $touchscreendir/calibration_screen
611 cat $card/ts-calibration > $touchscreendir/calibration_points
614 mknod /dev/graphics/fb0 c 29 0
616 echo; echo; echo; echo; echo; echo; echo; echo "Calibrating Touchscreen:"
617 echo "Click the Five Targets in order -- Top Left, Top Right, Middle, Bottom Left, Bottom Right"
618 echo "(Tap lightly. The screen is quite sensitive.)"
620 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
621 if [ $? -eq 0 ] ; then
622 echo "Touchscreen Calibration Failed"
624 echo "Touchscreen Calibration Successful; Saving..."
625 cat $touchscreendir/calibration_points > $card/ts-calibration
629 mkdir /dev/msm_camera
630 mknod /dev/msm_camera/control0 c 250 0
631 mknod /dev/msm_camera/config0 c 250 1
632 mknod /dev/msm_camera/frame0 c 250 2
634 # Generate a "serial number" for the Android system to identify the device.
635 # Put it in /data so it survives reboots. Won't survive a factory reset, though.
636 [ -f "/data/serialno" ] || echo -e `cat /dev/urandom | tr -dc 'A-Z0-9' | fold -w 12 | head -n 1` >/data/serialno
638 SERIALNO=$(cat /data/serialno)
639 cp /proc/cmdline /tmp/cmdline
640 sed -i -e "s:$: androidboot.serialno=${SERIALNO}:" /tmp/cmdline
641 mount --bind /tmp/cmdline /proc/cmdline