Tweak filesystem/SDcard cache parameters
[xdandroid:rootfs.git] / init
1 #!/bin/sh
2 fail() {
3         /bin/echo "Failed"
4                 /bin/echo "$1"
5                 exec /bin/sh
6 }
7
8 /bin/mount -o remount,rw / /
9
10 PATH=/sbin:/system/sbin:/bin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin
11
12 /bin/echo "Rootfs loaded."
13
14 /bin/mount -t proc proc /proc
15 /bin/mount -t sysfs sys /sys
16
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
22
23 /bin/mount | grep mtd
24 notnand=$?
25
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
30 fi
31
32 partition=mmcblk0p1
33
34 # Try unpartitioned card
35 if [ ! -d /sys/block/mmcblk0/$partition ] ; then
36         partition=mmcblk0
37 fi
38
39 if [ -f /sys/class/vogue_hw/gsmphone ] ; then
40         echo "GSM phone found"
41 fi
42
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."
47
48 if [ ! -d /sdcard/cache ] ; then
49         mkdir /sdcard/cache
50 fi
51
52 #mkdir -m 0777 /cache
53 mount /sdcard/cache /cache
54
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
57         CARD_PATH="andboot"
58 fi;
59 if [ -d /sdcard/$CARD_PATH ] ; then
60         card=/sdcard/$CARD_PATH
61 else
62         card=/sdcard
63 fi
64
65
66 if [ $notnand = "1" ] ; then
67     
68     if [ -f $card/data.gz ] ; then
69             echo "Please wait... extracting Data Image"
70             if [ -f $card/data.img ] ; then
71                     rm $card/data.img
72             fi
73             gzip -df $card/data.gz
74             [ $? -eq 0 ] || fail "Failed to extract Data Image"
75             mv $card/data $card/data.img
76             echo "done"
77     fi
78     
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
85     else
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"
93             fi
94
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
99
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"
105     fi
106 fi
107
108 if [ -f "$card/update.zip" ] && [ ! -f "/sdcard/cache/recovery/intent" ] && [ -z "$SQUASH" ]
109 then
110         RECOVERYCARD=$(echo $card | sed -e 's:/sdcard/:SDCARD\::')
111
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
117         exec /init.android
118 fi
119
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
123
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
129         fi
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)
132 fi
133
134 if [ ! -d $card/media ] ; then
135         echo You have no media folder, please extract the resources to your SD card android folder
136 fi
137
138 CHK_ROOT=etc/wifi/Fw1251r1c.bin
139 if [ ! -f /system/$CHK_ROOT -o /init.$CHK_ROOT -nt /system/$CHK_ROOT ]; then
140         NEW_ROOT=1
141 else
142         NEW_ROOT=0
143 fi
144
145 if [ $NEW_ROOT -eq 1 ]; then
146         cp -ar /init.etc/* /system/etc
147 fi
148
149 LCDDENSITY=`/bin/grep -o "lcd.density=.*" /proc/cmdline | /bin/sed -e "s/.*lcd.density=//g" -e "s/ .*//g"`
150
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
157                 else
158                         sed -i /lcd_density/s/=.*/=$LCDDENSITY/ /system/etc/default.prop
159                 fi
160         fi
161 fi
162
163 mount /sdcard/cache /tmp
164
165 KAISER=0
166 DIAMOND=0
167 WIFI_TI=0
168 WIFI_BCM=0
169 XPERIA=0
170 WVGA=0
171 HW=`cat /proc/cpuinfo | grep Hardware`
172 case "$HW" in
173     *Kaiser*)
174         echo "KAISER detected"
175         HW=KAISER
176         KAISER=1
177         WIFI_TI=1
178         ;;
179     *Polaris*)
180         echo "POLARIS detected"
181         HW=POLARIS
182         KAISER=1
183         WIFI_TI=1
184         ;;
185     *Diamond*)
186         echo "DIAMOND detected"
187         HW=DIAMOND
188         DIAMOND=1
189         WIFI_TI=1
190         ;;
191     *Raphael*)
192         echo "RAPHAEL detected"
193         HW=RAPHAEL
194         DIAMOND=1
195         WIFI_TI=1
196         ;;
197     *blackstone*)
198         echo "BLACKSTONE detected"
199         HW=BLACKSTONE
200         DIAMOND=1
201         WIFI_TI=1
202         WVGA=1
203         ;;
204     *Topaz*)
205         echo "TOPAZ detected"
206         HW=TOPAZ
207         DIAMOND=1
208         WIFI_TI=1
209         WVGA=1
210         ;;
211     *Kovsky*)
212         echo "XPERIA detected"
213         HW=KOVSKY
214         XPERIA=1
215         WIFI_TI=1
216         WVGA=1
217         ;;
218     *Rhodium*)
219         echo "RHODIUM detected"
220         HW=RHODIUM
221         DIAMOND=1
222         WIFI_BCM=1
223         WVGA=1
224         ;;
225     *)
226         echo "VOGUE detected"
227         HW=VOGUE
228         ;;
229 esac
230
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
234
235 RCSCRIPT=""
236 RCCONFIG=""
237
238 echo "Checking for build type..."
239 if [ -f /system/hero.build ] ; then
240         echo "Hero build detected"
241         RCSCRIPT="hero"
242         RCCONFIG="hero"
243         ln /data/app_s /system/app
244
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
250
251 elif [ -f /system/eclair.build ] ; then
252         echo "Eclair build detected"
253         RCSCRIPT="eclair"
254         RCCONFIG="eclair"
255         mount --bind /lib/eclair/hw /system/lib/hw
256
257 elif [ -f /system/froyo.build ] ; then
258         echo "Froyo build detected"
259         RCSCRIPT="froyo"
260         RCCONFIG="froyo"
261         mount --bind /lib/froyo/hw /system/lib/hw
262
263 elif [ -f /system/gingerbread.build ] ; then
264         echo "Gingerbread build detected"
265         RCSCRIPT="gingerbread"
266         RCCONFIG="gingerbread"
267
268 elif [ -f /system/tattoo.build ] ; then
269         echo "Tattoo build detected"
270         RCSCRIPT="tattoo"
271         RCCONFIG="tattoo"
272
273 elif [ -f /system/donut.build ] ; then
274         echo "Donut build detected"
275         RCSCRIPT="donut"
276         RCCONFIG="donut"
277         mount --bind /lib/donut/hw /system/lib/hw
278
279 elif [ -d /system/lib/donut ] ; then
280         echo "Donut build detected"
281         RCSCRIPT="donut"
282         RCCONFIG="donut"
283
284 elif [ -f /system/xrom.build ] ; then
285         echo "xROM build detected"
286         RCSCRIPT="xrom"
287         RCCONFIG="xrom"
288
289 elif [ -f /system/rogers.build ] ; then
290         echo "Rogers build detected"
291         RCSCRIPT="rogers"
292         RCCONFIG="rogers"
293
294 elif [ -f /system/cyanogen.build ] ; then
295         echo "cyanogen experimental detected.....eating donuts"
296         RCSCRIPT="cyanogen"
297         RCCONFIG="cyanogen"
298
299 elif [ -f /system/custom.build ] ; then
300         echo "Custom init.rc detected"
301         cp /system/sysinit.rc /build.cfg/init.sysinit.rc
302         RCCONFIG="hero"
303         RCSCRIPT="sysinit"
304         
305 else
306         echo "Unknown Android build. Assuming Ion variant"
307         RCSCRIPT="ion"
308         RCCONFIG="ion"
309
310         # for the fake sensors library
311         mount /lib/hw /system/lib/hw -o loop
312         chmod 666 /dev/input/event0
313
314         if [ $DIAMOND -eq 1 ] ; then
315                 RCCONFIG="ion.diamond"
316         fi
317 fi
318
319 if [ $KAISER -eq 1 ] ; then
320         RCSCRIPT="$RCSCRIPT.kaiser"
321 fi
322
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
329                 else
330                         sed -i /lcd_density/s/=.*/=$LCDDENSITY/ /system/etc/default.prop
331                 fi
332         fi
333 fi
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
340                 else
341                         sed -i /hwrotation/s/=.*/=180/ /system/etc/default.prop
342                 fi
343         fi
344 fi
345 echo "using $card/conf/$RCCONFIG.user.conf"
346
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
350 fi
351
352 #Assume this rootfs.img will be used only on "good" devices
353 #Meaning raph/diam/blac/
354
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
358 #chmod 4755 /bin/su
359 #mkdir -m 0777 /smodem
360 mknod /dev/urandom c 1 9
361 if [ -d /data/dropbear/ ] ; then
362         echo "Starting SSH"
363         mknod /dev/random c 1 8
364         /bin/dropbear -r /data/dropbear/dropbear_rsa_host_key -s
365 fi
366
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`
372         else
373                 echo "Modules already unpacked for this kernel version -- skipping installation of $card/modules-$(uname -r).tar.gz"
374         fi
375
376         if [ -f /system/etc/wifi/wlan.ko ]; then
377         cp -R /system/etc/wifi/* /lib/modules/
378         rm /system/etc/wifi/wlan.ko
379         depmod
380         fi
381
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
385         fi
386 fi
387
388 if [ -f /system/eclair.build ]
389 then
390         mount --bind /lib/eclair/libhardware_legacy.so /system/lib/libhardware_legacy.so
391 fi
392
393 # fix PPP data device name
394 if [ $NEW_ROOT -eq 1 ]; then
395         if [ -f /dev/smd7 ]; then
396                 PPPDEV=/dev/smd7
397         else
398                 PPPDEV=/dev/smd1
399         fi
400         sed -i s,PPPDEV,$PPPDEV, /system/etc/init.rc
401 fi
402
403
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
406
407         if [ $NEW_ROOT -eq 1 ]; then
408                 # init.rc: fix wpa_supplicant service
409                 sed -i s/-Dtiwlan0/-Dwext/ /system/etc/init.rc
410
411                 # 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
414         fi
415
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)
422
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
426                         rm /tmp/tempcal
427                 
428                         if grep nocrc= /data/wifi-nvram.txt 2>&1 > /dev/null;then 
429                                 break
430                         fi;
431                 done
432                 rm /dev/mtd0ro
433                 rmmod mtdchar
434                 if [ "$SKIP" = "5744" ];then
435                         echo "CDMA Rhodium detected"
436                 fi;
437                 if [ "$SKIP" = "4736" ];then
438                         echo "GSM Rhodium detected"
439                 fi;
440
441         fi
442 fi
443
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
448                 fi
449         fi
450 done
451
452 if [ -f "$card/conf/$RCCONFIG.user.conf" ]; then
453         /bin/userinit.sh -c "$card/conf/$RCCONFIG.user.conf"
454 else
455         echo "No user config files ($RCCONFIG) found on sdcard"
456 fi
457
458 mount -tdebugfs none /dbgfs
459 #Activate baclight control
460 echo 3 > /sys/class/htc_hw/test
461 #Smooth scroll
462 echo 40 >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
463 #Activate full charging
464 echo 2 > /dbgfs/htc_battery/charger_state
465
466 echo 1024 > /dbgfs/micropklt_dbg/sleep_leds
467
468 if [ $NEW_ROOT -eq 1 ]; then
469 KBD=`sed 's/.*physkeyboard=\([0-9a-z_]*\).*/\1/' /proc/cmdline`
470 case "$KBD" in
471     fuse)
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
476         ;;
477     raph)
478         echo "USING NEW RAPH LAYOUT"
479         cp -f /init.etc/keymaps/raphfix_microp-keypad.kcm.bin /system/usr/keychars/microp-keypad.kcm.bin
480         ;;
481     nordic_raph)
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
484         ;;
485     german_raph)
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
488         ;;
489     swiss_raph)
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
492         ;;
493     tilt2)
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
498         ;;
499     rhod210)
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
504         ;;
505     rhod100_de)
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
510         ;;
511     rhod100_fr)
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
516         ;;
517     rhod100_it)
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
522         ;;
523     rhod100_uk)
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
528         ;;
529     rhod100_nordic)
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
534         ;;
535     rhod400)
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
540         ;;
541     rhod500)
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
546         ;;
547     kovsq)
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
551         ;;
552     kovsa)
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
556         ;;
557     *)
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
562         ;;
563 esac
564
565 fi
566
567 mount -o remount,ro /system
568
569 for i in /sys/class/input/input* ; do
570         if [ "`cat $i/name`" = "tssc-manager" ] ; then
571                 touchscreendir=$i
572                 echo "Touchscreen device directory is $i"
573         fi
574 done
575
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
580 else
581         mkdir /dev/graphics
582         mknod /dev/graphics/fb0 c 29 0
583         clear
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.)"
587         tssc-calibrate
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"
591         else
592                 echo "Touchscreen Calibration Successful; Saving..."
593                 cat $touchscreendir/calibration_points > $card/ts-calibration
594         fi
595 fi
596
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
601
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
605
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
610
611 exec /init.android