2011-03-13 13:17:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Quick and dirty NAND init by Rajko
|
|
|
|
# modified by rafpigna to add ext data mount
|
|
|
|
# modified to increase speed and I/O
|
|
|
|
# modified to support some configs on boot
|
|
|
|
# 20 jan 2011
|
|
|
|
#
|
|
|
|
# please if you use my work, send me a line
|
|
|
|
# and write my name somewhere
|
|
|
|
# v2 - 1 Feb 2011
|
|
|
|
#
|
|
|
|
# modified to add a2sd support from Dark Tremor
|
|
|
|
# so that the phone doesn't boot loop and users
|
|
|
|
# can change on the fly
|
|
|
|
# 22 Fen 2010 - arif-ali
|
|
|
|
|
|
|
|
fail() {
|
|
|
|
echo "Failed"
|
|
|
|
echo "$1"
|
|
|
|
exec /bin/sh
|
|
|
|
}
|
|
|
|
|
|
|
|
exec_init() {
|
|
|
|
# cleanup
|
|
|
|
umount /system
|
|
|
|
umount /data
|
|
|
|
sleep 1
|
|
|
|
umount /bootsdcard
|
|
|
|
rmdir /bootsdcard
|
|
|
|
# execute android init
|
|
|
|
exec /init.android
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Booting linux from NAND partitions"
|
|
|
|
|
|
|
|
mount -t proc proc /proc
|
|
|
|
mount -t sysfs sys /sys
|
|
|
|
mkdir -m 0777 /dev/block
|
|
|
|
mknod -m 0666 /dev/block/mmcblk0 b 179 0
|
|
|
|
mknod -m 0666 /dev/block/mmcblk0p1 b 179 1
|
|
|
|
mknod -m 0666 /dev/block/mmcblk0p2 b 179 2
|
|
|
|
# wait for sdcard
|
|
|
|
while [ ! -b /dev/block/mmcblk0 ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Configure Devices
|
|
|
|
MAKEDEVS
|
|
|
|
|
|
|
|
PATH=/sbin:/bin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin
|
|
|
|
|
|
|
|
|
|
|
|
echo "Mounting debugfs"
|
|
|
|
mount -t debugfs none /dbgfs
|
|
|
|
echo "Activating backlight control..."
|
|
|
|
echo 3 > /sys/class/htc_hw/test
|
|
|
|
echo "Enabling smooth scrolling..."
|
|
|
|
echo 40 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
|
|
|
|
echo "Activating full charging..."
|
|
|
|
echo 2 > /dbgfs/htc_battery/charger_state
|
|
|
|
echo 1024 > /dbgfs/micropklt_dbg/sleep_leds
|
|
|
|
echo "+++++++ Tweaking MMC read-ahead by Rafpigna +++++++"
|
|
|
|
mmcfolder="/sys/devices/platform/msm_sdcc.2/mmc_host/mmc1"
|
|
|
|
cd $mmcfolder
|
|
|
|
folderlist=`ls -1`
|
|
|
|
mmcresult=`echo $folderlist | grep -o '\bmmc1:\w*' | sed 's/mmc1://'`
|
|
|
|
echo 32 > /sys/devices/platform/msm_sdcc.2/mmc_host/mmc1/mmc1:$mmcresult/block/mmcblk0/queue/read_ahead_kb
|
|
|
|
echo "+++++++ Auto-off keyled backlight by Rafpigna +++++++"
|
|
|
|
echo 0 > /sys/devices/platform/btn_backlight_manager/auto_off
|
|
|
|
|
|
|
|
|
|
|
|
####################################################
|
|
|
|
###### configs on boot ############################
|
|
|
|
###### idea by Dandiest, modified by me (rafpigna) #
|
|
|
|
####################################################
|
|
|
|
|
|
|
|
#first, mount sd card
|
|
|
|
# assume single partition, if found partition 1 use that
|
|
|
|
echo "+++++++ STARTING UPDATE SCRIPT +++++++"
|
|
|
|
echo "+++++++ MOUNTING SD CARD +++++++"
|
|
|
|
sdcard_partition=mmcblk0
|
|
|
|
[ -d /sys/block/mmcblk0/mmcblk0p1 ] && sdcard_partition=mmcblk0p1
|
|
|
|
# run fsck
|
|
|
|
# dosfsck -y /dev/block/$sdcard_partition
|
|
|
|
# mount sdcard
|
|
|
|
mkdir -m 0700 /bootsdcard
|
|
|
|
mount -t vfat -o fmask=0111,dmask=0000,rw,utf8,noatime,nodiratime /dev/block/$sdcard_partition /bootsdcard || bootsdcard=0
|
|
|
|
sleep 1
|
|
|
|
if [ $bootsdcard -eq 0 ]; then
|
|
|
|
# cleanup
|
|
|
|
rmdir /bootsdcard
|
|
|
|
rm -f /dev/block/mmcblk0
|
|
|
|
rm -f /dev/block/mmcblk0p1
|
|
|
|
rm -f /dev/block/mmcblk0p2
|
|
|
|
# run init
|
|
|
|
exec_init
|
|
|
|
fi
|
|
|
|
|
|
|
|
# prepare
|
|
|
|
data_dir=/bootsdcard
|
|
|
|
init_log=/bootsdcard/init.log
|
|
|
|
update_dir=/bootsdcard/updates
|
|
|
|
|
|
|
|
# clear previous init.log
|
|
|
|
if [ -f $init_log ]; then
|
|
|
|
rm -f $init_log
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "+++++++ READING CONFIG FILE +++++++"
|
|
|
|
# read config file
|
|
|
|
config_file=$data_dir/config.txt
|
|
|
|
if [ -f $config_file ]; then
|
|
|
|
config=`awk -v RS='\r\n' -v ORS=' ' 1 $config_file`
|
|
|
|
gps_zone=`echo $config | grep -o '\bgps_zone=\w*' | sed 's/gps_zone=//'`
|
|
|
|
ppp_mode=`echo $config | grep -o '\bppp_mode=\w*' | sed 's/ppp_mode=//'`
|
|
|
|
sd_boost=`echo $config | grep -o '\bsd_boost=\w*' | sed 's/sd_boost=//'`
|
|
|
|
a2sd_mode=`echo $config | grep -o '\ba2sd_mode=\w*' | sed 's/a2sd_mode=//'`
|
|
|
|
fi
|
|
|
|
|
|
|
|
#write the values to logfile to have possibility to check if they are right
|
|
|
|
echo "gps_zone" >> $init_log
|
|
|
|
echo $gps_zone >> $init_log
|
|
|
|
echo "ppp_mode" >> $init_log
|
|
|
|
echo $ppp_mode >> $init_log
|
|
|
|
echo "sd_boost" >> $init_log
|
|
|
|
echo $sd_boost >> $init_log
|
|
|
|
echo "a2sd_mode" >> $init_log
|
|
|
|
echo $a2sd_mode >> $init_log
|
|
|
|
|
|
|
|
|
|
|
|
# load default value
|
2011-03-23 22:16:01 +00:00
|
|
|
[ -z $ppp_mode ] && ppp_mode=0
|
2011-03-13 13:17:33 +00:00
|
|
|
[ -z $sd_boost ] && sd_boost=0
|
2011-03-23 22:16:01 +00:00
|
|
|
[ -z $a2sd_mode ] && a2sd_mode="dalvik"
|
|
|
|
[ -z $gps_zone ] && gps_zone="us"
|
2011-03-13 13:17:33 +00:00
|
|
|
|
|
|
|
echo "+++++++ MOUNTING MTD SYSTEM +++++++"
|
|
|
|
# define partitions
|
|
|
|
system_partition=`grep system /proc/mtd | cut -d: -f1 | sed 's/mtd/mtdblock/'`
|
|
|
|
mount -t yaffs2 -o rw /dev/block/$system_partition /system >> $init_log
|
|
|
|
data_partition=`grep userdata /proc/mtd | cut -d: -f1 | sed 's/mtd/mtdblock/'`
|
|
|
|
mount -t yaffs2 -o rw /dev/block/$data_partition /data >> $init_log
|
|
|
|
echo "+++++++ MOUNTED MTD SYSTEM +++++++" >> $init_log
|
|
|
|
|
|
|
|
|
|
|
|
#20 jan 2011
|
|
|
|
#ext3 can be mounted as ext4 with that option improving performances without major drawbacks
|
|
|
|
#reference: https://wiki.archlinux.org/index.php/Ext4#Mounting_ext3_Partitions_as_ext4_Without_Converting
|
|
|
|
|
|
|
|
#if second partition exists, mount it as data. if not exists, uncomment line in init.rc to mount data on yaffs
|
|
|
|
#also init.rc must be changed to mount /data on nand userdata if ext partition does not exists
|
|
|
|
if [ -d /sys/block/mmcblk0/mmcblk0p2 ] ; then
|
|
|
|
echo "Ext partition found. Mounting data on EXT"
|
|
|
|
echo "Ext partition found. Mounting data on EXT" >> $init_log
|
|
|
|
|
|
|
|
# Added by arif-ali
|
|
|
|
# set a2sd mode
|
|
|
|
if [ "$a2sd_mode" == "a2sd" ]; then
|
|
|
|
echo "+++++++ a2sd ACTVATED +++++++" >> $init_log
|
|
|
|
echo "+++++++ a2sd ACTVATED +++++++"
|
|
|
|
rm -rf /data/.noa2sd
|
|
|
|
rm -rf /data/.dalvikcache
|
|
|
|
elif [ "$a2sd_mode" == "dalvik" ]; then
|
|
|
|
echo "+++++++ dalvik a2sd ACTVATED +++++++" >> $init_log
|
|
|
|
echo "+++++++ dalvik a2sd ACTVATED +++++++"
|
|
|
|
rm -rf /data/.noa2sd
|
|
|
|
touch /data/.dalvikcache
|
|
|
|
elif [ "$a2sd_mode" == "data" ]; then
|
|
|
|
echo "+++++++ data a2sd ACTVATED +++++++" >> $init_log
|
|
|
|
echo "+++++++ data a2sd ACTVATED +++++++"
|
|
|
|
rm -rf /data/.noa2sd
|
|
|
|
touch /data/.dalvikcache
|
|
|
|
touch /data/.datasd
|
|
|
|
elif [ "$a2sd_mode" == "none" ]; then
|
|
|
|
touch /data/.noa2sd
|
|
|
|
echo "+++++++ a2sd DEACTVATED - running from NAND +++++++" >> $init_log
|
|
|
|
echo "+++++++ a2sd DEACTVATED - running from NAND +++++++"
|
|
|
|
else
|
|
|
|
echo "+++++++ Default a2sd ACTVATED +++++++" >> $init_log
|
|
|
|
echo "+++++++ Default a2sd ACTVATED +++++++"
|
|
|
|
rm -rf /data/.noa2sd
|
2011-03-23 22:16:01 +00:00
|
|
|
rm -rf /data/.datasd
|
2011-03-13 13:17:33 +00:00
|
|
|
touch /data/.dalvikcache
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Added by rafpigna
|
|
|
|
# if [ $sd_boost -eq 1 ] ; then
|
|
|
|
# echo "+++++++ SD BOOST ACTIVE +++++++"
|
|
|
|
# echo "+++++++ SD BOOST ACTIVE +++++++" >> $init_log
|
|
|
|
# /bin/tune2fs -O ^has_journal /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# e2fsck -y -v -f /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# /bin/tune2fs -O ^huge_file /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# e2fsck -y -v -f /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# /bin/tune2fs -l /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# else
|
|
|
|
# echo "+++++++ SD BOOST NOT ACTIVE +++++++"
|
|
|
|
# echo "+++++++ SD BOOST NOT ACTIVE +++++++" >> $init_log
|
|
|
|
# /bin/tune2fs -O has_journal /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# e2fsck -y -v -f /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# /bin/tune2fs -O huge_file /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# e2fsck -y -v -f /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# /bin/tune2fs -l /dev/block/mmcblk0p2 >> $init_log
|
|
|
|
# fi
|
|
|
|
|
|
|
|
echo "+++++++ MOUNTED DATA ON EXT +++++++"
|
|
|
|
echo "+++++++ MOUNTED DATA ON EXT +++++++" >> $init_log
|
|
|
|
else
|
|
|
|
echo "Ext partition not found. disabling a2sd"
|
|
|
|
echo "Ext partition not found. disabling a2sd" >> $init_log
|
|
|
|
sed -i 's|#mount yaffs2 mtd@userdata /data nosuid nodev noatime nodiratime|mount yaffs2 mtd@userdata /data nosuid nodev noatime nodiratime|' /init.rc
|
|
|
|
echo "+++++++ MOUNTED DATA ON NAND +++++++" >> $init_log
|
|
|
|
echo "+++++++ MOUNTED DATA ON NAND +++++++"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set gps zone
|
|
|
|
if [ "$gps_zone" != "" ]; then
|
|
|
|
current_gps_zone=`awk -F"=" '/NTP_SERVER/ {print $2}' /system/etc/gps.conf`
|
|
|
|
[ "$gps_zone.pool.ntp.org" != "$current_gps_zone" ] && sed -i "s/$current_gps_zone/$gps_zone.pool.ntp.org/g" /system/etc/gps.conf
|
|
|
|
echo "+++++++ GPS ZONE CHANGED +++++++" >> $init_log
|
|
|
|
echo "+++++++ GPS ZONE CHANGED +++++++"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set ppp or rmnet
|
|
|
|
if [ $ppp_mode -eq 1 ] ; then
|
|
|
|
sed -i 's/nand_init .*/nand_init /' /init.rc
|
|
|
|
#sed -i 's|insmod /system/lib/modules/msm_rmnet.ko|#insmod /system/lib/modules/msm_rmnet.ko|' /system/etc/init.d/01modules
|
|
|
|
touch /system/ppp
|
|
|
|
echo "+++++++ PPP MODE ACTIVATED +++++++" >> $init_log
|
|
|
|
echo "+++++++ PPP MODE ACTIVATED +++++++"
|
|
|
|
else
|
|
|
|
sed -i 's/nand_init .*/nand_init rmnet_mode /' /init.rc
|
|
|
|
#sed -i 's|#insmod /system/lib/modules/msm_rmnet.ko|insmod /system/lib/modules/msm_rmnet.ko|' /system/etc/init.d/01modules
|
|
|
|
echo "+++++++ RMNET MODE ACTIVATED +++++++"
|
|
|
|
echo "+++++++ RMNET MODE ACTIVATED +++++++" >> $init_log
|
|
|
|
rm -rf /system/ppp
|
|
|
|
fi
|
|
|
|
|
|
|
|
####################################################
|
|
|
|
###### configs on boot ############################
|
|
|
|
###### idea by Dandiest, modified by me (rafpigna) #
|
|
|
|
####################################################
|
|
|
|
###################### END #########################
|
|
|
|
|
|
|
|
######################################################
|
|
|
|
# boot into Android
|
|
|
|
# init shell finally done
|
|
|
|
######################################################
|
|
|
|
exec_init
|