Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- initfs/skeleton/init 2013-05-16 01:02:00.928739996 +0200
- +++ ../nexus7-moslo/initfs/skeleton/init 2012-12-11 21:23:48.456722344 +0100
- @@ -8,110 +8,51 @@
- # Timo Kokkonen <timo.t.kokkonen@nokia.com>
- # Janne Lääkkö <janne.laakko@nokia.com>
- #
- +# Adaptation for Google Nexus 7 based on the Nokia version:
- +# Copyright 2012 Ruediger Gad <r.c.g@gmx.de>
- +#
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License version 2 as
- # published by the Free Software Foundation.
- INIT_OPTS=
- MMC_DEV="/dev/mmcblk0"
- -ALT_OS_PART="$MMC_DEV"p4
- IP_ARRD="192.168.2.15"
- -# Text2screen wrapper for next lines
- -TTSYI=0 # Where to start
- -TTSX=0
- -TTSY=TTSYI
- -TTS_PIX_PER_CHAR=9
- -TTS_SCALE=2
- -TTSYM=480 # Max y lines
- -TTSXM=830 # Max x lines
- -TTSCM=$(($TTSXM/($TTS_PIX_PER_CHAR*$TTS_SCALE))) # Max char/line
- -TTSI=$(((TTS_PIX_PER_CHAR+1)*TTS_SCALE))
- -
- -ttsr()
- -{
- - TTSY=$TTSYI
- - fb_text2screen -c -B000
- -}
- -
- -tts()
- -{
- - fb_text2screen -s $TTS_SCALE -y $TTSY -t "$1"
- - echo $1
- - let "LINES=1+${#1}/$TTSCM"
- - let "TTSY+=($TTSI*$LINES)"
- - if [ $TTSY -gt $TTSYM ] ; then ttsr ; fi
- -}
- -
- -tts_dot_wait(){
- - TTSX=0
- - for i in 5 4 3 2 1 0; do
- - fb_text2screen -s $TTS_SCALE -y $TTSY -x $TTSX -t "$i "
- - echo -n "$i "
- - let "TTSX+=30"
- - sleep 1
- - done
- - let "LINES=1+6/$TTSCM"
- - let "TTSY+=($TTSI*$LINES)"
- - if [ $TTSY -gt $TTSYM ] ; then ttsr ; fi
- -}
- shell()
- {
- echo "Starting shell..."
- getty 115200 ttyS0 -n -l /bin/sh &
- while : ; do
- - if [ -n "$WD_DEVICE" ]; then
- - echo "30" >&3
- - fi
- - sleep 2
- + sleep 2
- done
- }
- -reboot_to_harmattan()
- -{
- - [ $# -ge 1 ] && TIMEOUT=$1 || TIMEOUT=0;
- - tts "Booting to Harmattan in $TIMEOUT seconds"
- - sleep $TIMEOUT
- - reboot2 s
- -}
- -
- -trap_func()
- -{
- - tts "Trap!"
- - reboot_to_harmattan
- -}
- -
- usb_is_plugged()
- {
- - # type is USB_DCP with wall charger, USB otherwise (including disconnected)
- - if [ "$(cat /sys/class/power_supply/usb/type)" == "USB" ]; then
- - usb=$(cat /sys/class/power_supply/usb/present)
- - return $usb
- - else
- - return 0
- - fi
- + usb=$(cat /sys/class/power_supply/usb/online)
- + return $usb
- }
- wait_mmc()
- {
- TRY=0
- - tts "Waiting for eMMC device..."
- + echo "Waiting for eMMC device..."
- while [ ! -e "$MMC_DEV" -a $TRY -lt 10 ] ; do
- sleep 1
- TRY=$(($TRY+1))
- done
- if [ $TRY == 10 ]; then
- - tts "eMMC device not found!"
- + echo "eMMC device not found!"
- fi
- }
- export_over_usb()
- {
- [ -e "$1" ] && {
- - umount "$1"
- EXPORT_FILE="$1"
- }
- - rmmod g_nokia
- +
- MP_ERR=1
- TRY=0
- while [ "$MP_ERR" -ne "0" -a $TRY -lt 10 ] ; do
- @@ -121,17 +62,17 @@ export_over_usb()
- lsmod |grep -q g_multi
- MP_ERR=$?
- TRY=$(($TRY+1))
- - #tts "Try $TRY ($MP_ERR)"
- + echo "Try $TRY ($MP_ERR)"
- done
- if [ $TRY == 10 ]; then
- - tts "Unable to load the USB modules!"
- + echo "Unable to load the USB modules!"
- else
- [ -n "$EXPORT_FILE" ] && \
- - tts "Rootfs of AlternateOS now exported via USB"
- + echo "Rootfs of AlternateOS now exported via USB"
- ifconfig usb0 $IP_ARRD up
- [ $? -eq 0 ] && \
- - tts "You can telnet into $IP_ARRD" || \
- - tts "Setting IP address failed!"
- + echo "You can telnet into $IP_ARRD" || \
- + echo "Setting IP address failed!"
- fi
- sleep 1
- @@ -142,7 +83,25 @@ export_over_usb()
- done
- }
- -trap "trap_func" 0 2
- +try_extract_rootfs() {
- + ROOTFS_IMAGE="$1"
- + echo "Looking for rootfs image: $ROOTFS_IMAGE"
- +
- + if [ -e "$ROOTFS_IMAGE" ]; then
- + echo "Found rootfs image."
- + echo "Will start to extract rootfs image in 5 seconds. This can take a while."
- + sleep 5s
- + cd "$USERDATA_MOUNT_DIR"
- + tar xvf "$ROOTFS_IMAGE"
- + echo "Rootfs extraction finished."
- +
- + echo "Removing rootfs tarball."
- + rm "$ROOTFS_IMAGE"
- + cd -
- + else
- + echo "No rootfs image found. Doing nothing."
- + fi
- +}
- echo "START SYSTEM"
- @@ -151,131 +110,122 @@ echo "START SYSTEM"
- export PATH=/sbin:/bin:/usr/bin:/usr/sbin
- export MOUNT_DIR=/mnt
- +export USERDATA_MOUNT_DIR=$MOUNT_DIR/userdata
- -echo -n "Doing mounts... "
- +echo "Doing mounts... "
- mount /dev
- mkdir /dev/pts
- mount -a
- cat /proc/mounts > /etc/mtab
- -# Get the device specific configs
- -if [ -f /moslo.config ]; then
- - source /moslo.config
- -fi
- -
- -# If there is Watch dog device set then kick it
- -if [ -n "$WD_DEVICE" ]; then
- - # Kick the watch dog
- - exec 3>$WD_DEVICE
- - echo "30" >&3
- -fi
- +ALT_OS_PART="${MMC_DEV}p$(ls /dev/mmcblk0p* | wc -l)"
- +echo "Found userdata partition at: $ALT_OS_PART"
- # adjust kernel to minimize memory consumption,
- # flushing of memory card buffers
- # and optimize IO pressure
- #TODO fix pty/max and dirty ratio in kernel configuration
- +echo "Setting kernel and system settings."
- echo 256 > /proc/sys/kernel/threads-max || \
- - tts "Set fail for kernel thread-max"
- + echo "Set fail for kernel thread-max"
- echo 8192 > /proc/sys/fs/file-max || \
- - tts "Set fail for kernel file-max"
- + echo "Set fail for kernel file-max"
- echo 1 > /proc/sys/vm/swappiness || \
- - tts "Set fail for swappiness"
- + echo "Set fail for swappiness"
- echo 5 > /proc/sys/vm/page-cluster || \
- - tts "Set fail for page-cluster"
- + echo "Set fail for page-cluster"
- echo 500 > /proc/sys/vm/dirty_expire_centisecs || \
- - tts "Set fail for expire_centisecs"
- + echo "Set fail for expire_centisecs"
- echo 60 > /proc/sys/vm/dirty_background_ratio || \
- - tts "Set fail for dirty_background_ratio"
- + echo "Set fail for dirty_background_ratio"
- echo 65536 > /proc/sys/net/core/rmem_default || \
- - tts "Set fail for rmem_default"
- + echo "Set fail for rmem_default"
- echo 16384 > /proc/sys/net/core/wmem_default || \
- - tts "Set fail for wmem_default"
- + echo "Set fail for wmem_default"
- #Run mdev
- +echo "Running mdev..."
- mdev -s
- -
- #Set mdev as hotplug manager
- echo /bin/mdev > /proc/sys/kernel/hotplug
- +#Start services
- +echo "Starting syslogd..."
- syslogd &
- -
- -/sbin/init_preps.sh
- -
- -# Start telnetd service
- +echo "Starting telnetd..."
- telnetd -l/bin/sh
- # Start shell for console use
- +echo "Starting shell..."
- shell &
- -# Clear screen and display welcome message
- -ttsr
- VERSION=$(cat /etc/moslo-version)
- -tts " Welcome to MOSLO v$VERSION"
- -tts " check wiki.merproject.org/wiki/Nemo"
- -tts ""
- +echo " Welcome to MOSLO v$VERSION"
- +echo " check wiki.merproject.org/wiki/Nemo"
- +echo ""
- # Wait for one second for eMMC to settle
- wait_mmc
- usb_is_plugged
- if [ $? -eq 1 ]; then
- - if [ ! -b "$ALT_OS_PART" ]; then
- - tts "Repartitioning MMC for AlternateOS."
- - tts "Do not unplug USB or poweroff the device!!!"
- - autopartition.sh create $MMC_DEV > /var/log/repartition.log
- - case $? in
- - 0)
- - tts "Re-partitioning successful!"
- - ;;
- - 1)
- - tts "ERR: Re-partitioning failed! No partition created."
- - ;;
- - *)
- - tts "FATAL: Re-partitioning failed! You might be in trouble!"
- - tts "You can telnet in the device to try to debug!"
- - ;;
- - esac
- - fi
- + echo "Trying to export storage via USB."
- # Export AlternateOS partition via USB
- export_over_usb "$ALT_OS_PART"
- fi
- -mount $ALT_OS_PART $MOUNT_DIR
- -if [ $? -ne 0 ]; then
- - tts "Mounting AlternateOS failed. Not able to boot that."
- - reboot_to_harmattan 5
- -fi
- +echo "Mounting $ALT_OS_PART to $USERDATA_MOUNT_DIR."
- +mkdir -p "$USERDATA_MOUNT_DIR"
- +mount "$ALT_OS_PART" "$USERDATA_MOUNT_DIR"
- +
- +echo "Everything should be mounted now."
- +echo "Free space is as follows:"
- +df -h
- +
- +echo "Content of $USERDATA_MOUNT_DIR is:"
- +ls $USERDATA_MOUNT_DIR
- +
- +# We support gzip and bzip2 rootfs image tarballs.
- +# Note: rootfs.tar.* should resolve to a single file.
- +try_extract_rootfs "$USERDATA_MOUNT_DIR/rootfs.tar.bz2"
- +try_extract_rootfs "$USERDATA_MOUNT_DIR/rootfs.tar.gz"
- # Try to load AlternateOS kernel
- -kexec_load $MOUNT_DIR
- +kexec_load $USERDATA_MOUNT_DIR
- if [ $? -eq 0 ]; then
- - tts "Found AlternateOS kernel."
- - tts "Autoboot to AlternateOS in 15 seconds"
- - tts ""
- - tts "Press: VolumeUp button to boot to Harmattan"
- - tts " VolumeDown button to boot to AlternateOS."
- - # Check if keycode 115 is emitted
- - evkey -u -t 15000 /dev/input/event4 | grep -q -w 115
- - if [ $? -eq 0 ]; then
- - reboot_to_harmattan 0
- - else
- + echo "Found AlternateOS kernel."
- + echo "Trying to boot kernel in 5 seconds."
- + sleep 5s
- +# Lines starting with ## had been commented for now but may be used
- +# later again. Hence we keep em here but in a way we can identify
- +# that we might use these later.
- +## echo "Autoboot to AlternateOS in 15 seconds"
- +## echo ""
- +## echo "Press: VolumeUp button to boot to Harmattan"
- +## echo " VolumeDown button to boot to AlternateOS."
- +## # Check if keycode 115 is emitted
- +## evkey -u -t 15000 /dev/input/event4 | grep -q -w 115
- +## if [ $? -eq 0 ]; then
- +## reboot_to_harmattan 0
- +## else
- # Set disable PM features and set cpu clock to resemble POR
- - disable_pm
- +## disable_pm
- kexec -e
- - tts "kexec failed: $?"
- - tts "Failed to boot /boot/bzImage"
- - fi
- + echo "kexec failed: $?"
- + echo "Failed to boot /boot/bzImage"
- +## fi
- else
- - tts "Unable to load AlternateOS kernel."
- + echo "Unable to load AlternateOS kernel."
- fi
- -reboot_to_harmattan 5
- +##reboot_to_harmattan 5
- # exit would trap and start a new shell again, so stay in the loop
- # forever
- while true; do
- sleep 99999
- done
- +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement