|
From: <ke...@us...> - 2007-03-09 20:25:44
|
Revision: 899
http://svn.sourceforge.net/hackndev/?rev=899&view=rev
Author: keddar
Date: 2007-03-09 12:24:34 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
l4p: init script and kernel config (not only) for BFUGarux addition
Added Paths:
-----------
linux4palm/BFUGarux/init/
linux4palm/BFUGarux/init/linuxrc
linux4palm/BFUGarux/init/live-lib
Added: linux4palm/BFUGarux/init/linuxrc
===================================================================
--- linux4palm/BFUGarux/init/linuxrc (rev 0)
+++ linux4palm/BFUGarux/init/linuxrc 2007-03-09 20:24:34 UTC (rev 899)
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+export PATH="/bin:/sbin"
+
+. $PREFIX/live-lib
+
+do_banner
+#do_insmod_base
+
+do_initial_mnt
+
+do_cmdline_check
+do_bfu_check
+do_cmdline_show
+
+do_insmod_base
+
+do_ramdisk
+do_kernel_init
+
+do_stowaway
+
+do_network_init
+
+$DEBUGCMD
+
+do_start_default
+
+#do_usb_power 0 # MAYBE is req. with Win2k ? TEST: WXP on 2pc = OK
+#do_usb_power 1
+
+do_plug_mod
+do_unionfs
+#do_aufs
+$DEBUGCMD
+
+do_load_live_changes
+do_unioncopy
+do_rootcopy
+
+do_mmc_move
+$DEBUGCMD
+
+do_chroot
Property changes on: linux4palm/BFUGarux/init/linuxrc
___________________________________________________________________
Name: svn:executable
+ *
Added: linux4palm/BFUGarux/init/live-lib
===================================================================
--- linux4palm/BFUGarux/init/live-lib (rev 0)
+++ linux4palm/BFUGarux/init/live-lib 2007-03-09 20:24:34 UTC (rev 899)
@@ -0,0 +1,1159 @@
+#!/bin/sh
+# info: this live-lib is based on Farcallers Garux 0.6.1 (based on linux-live.org)
+# kEdAR.palmlinux.cz
+
+######### RELEASE INFO
+. $PREFIX/relinfo
+KERNEL_VER="2.6.20-hnd0"
+
+######### MISC PARAMS
+## DEFAULT BACKLIGHT (fix for 0 backlight in some cases)
+LCDBLDEF="40"
+
+######### UNIONFS PARAMS
+UNION=/union
+MEMORY=/memory
+MOUNTDIR=mnt
+CHANGES=$MEMORY/changes
+IMAGES=$MEMORY/images
+COPY2RAM=$MEMORY/copy2ram
+
+######### for MMC PARAMS
+MMC_MNT=$MEMORY/mmc
+MMC_MNT_ROOT=/mnt/mmc
+MMC_MNTNEW="$UNION/mnt/mmc"
+LINUX2RAM=/linux2ram ### replaced with BFU if found... (DON'T USE /$LINUX2RAM :)
+CMD_MMC="$MMC_MNT$LINUX2RAM/cmdline"
+LIVE_CHANGES="$MMC_MNT/live_changes.squashfs"
+
+######### REFLASH PARAMS
+BIN2FLASH="$MMC_MNT_ROOT/bin2flash"
+MTD_FREE_MD5="41d2e2c0c0edfccf76fa1c3e38bc1cf2 -"
+MTD_PROC_MD5="14208aa9a7579355d19537326f22da8b -"
+PREFIX="/mnt/live" # used after pivot_root
+
+######### LOGGING FUNCTIONS
+C_OFF="\033[0;0m"
+C_GRE="\033[01;32m"
+C_BLU="\033[01;34m"
+C_YEL="\033[01;33m"
+C_RED="\033[01;41m"
+C_REDY="\033[01;33;41m"
+C_REDW="\033[01;37;41m"
+C_WHIT="\033[01;37m"
+INFO=" ${C_YEL}*${C_WHIT}"
+WARN=" ${C_GRE}*${C_YEL}"
+ERRO=" ${C_REDY}*${C_REDW}"
+
+## efetchall used for critical part, show info also if SilentBoot is used
+efetchall() {
+ echo -e " ${C_WHIT}>> $1${C_OFF}"
+}
+
+## don't show if SilentBoot is used
+efetch() {
+ if [ "$SILENT" = "" ]; then echo -e " ${C_WHIT}>> $1${C_OFF}"; fi
+}
+
+einfo() {
+ echo -e "$INFO $1${C_OFF}"
+}
+
+ewarn() {
+ echo -e "$WARN $1${C_OFF}"
+}
+
+eerr() {
+ echo -e "$ERRO $1${C_OFF}"
+}
+
+edie() {
+ eerr "$1"
+ echo -e "\n"
+ eerr "System Halted."
+ while [ 1 -eq 1 ]; do
+ /bin/sleep 1000000
+ done
+}
+
+do_die() {
+ if [ $? -ne 0 ]; then
+ edie "Failed"
+ fi
+}
+
+do_die_msg() {
+ if [ $? -ne 0 ]; then
+ edie "$1"
+ fi
+}
+
+######### COMMON FUNCTIONS
+do_banner() {
+ echo
+ einfo "Linux4Palm ${C_BLU}http://www.hackndev.com/${C_OFF}"
+ einfo "Release codename : ${C_RED}${L4P_RELEASE}${C_OFF}"
+ einfo "Version : $L4P_VERSION"
+ einfo "Kernel : $KERNEL_VER"
+ einfo "Bootloader: $BOOTL"
+ einfo "Unofficial rev.: ${C_GRE}$UNOFF${C_OFF}"
+ einfo "Unofficial homepage : http://kedar.palmlinux.cz\n\n"
+}
+
+## insert base kernel modules
+do_insmod_base() {
+ ewarn "Loading core modules"
+ if [ -e /lib/modules/$KERNEL_VER/kernel/fs/aufs/aufs.ko ]; then
+ efetchall "aufs" ### change efetchall to efetch after test aufs...
+ modprobe aufs
+ else
+ efetch "unionfs"
+ modprobe unionfs
+ fi
+ if [ -e /lib/modules/$KERNEL_VER/kernel/arch/arm/mach-pxa/palmt3/palmt3_battery.ko ]; then
+ efetch "palmt3_battery"
+ modprobe palmt3_battery
+ fi
+ if [ -e /lib/modules/$KERNEL_VER/kernel/drivers/i2c/chips/tps65010.ko ]; then
+ efetch "tps65010"
+ modprobe tps65010
+ fi
+ if [ -e /lib/modules/$KERNEL_VER/kernel/fs/squashfs/squashfs.ko ]; then
+ efetch "squashfs"
+ modprobe squashfs
+ fi
+
+ efetch "gpioed"
+ modprobe gpioed
+ do_die_msg "modprobe gpioed failed"
+}
+
+## probe modules from modules-???.squashfs, after unionfs is created
+do_insmod_ext() {
+ ewarn "Probing some modules from real root"
+ modprobe -s -q tsc2101
+ $DEBUGCMD
+}
+
+## mount initial filesystems
+do_initial_mnt() {
+# /union unionfs
+# /memory/ is tmpfs (50% RAM ~32Mb)
+# rootfs rootfs (sqashfs dump)
+# changes/ changed files in rootfs
+# mnt/root/ bound to /
+ ewarn "Mounting initial filesystems"
+ mount -t proc none /proc
+ mount -t sysfs sysfs /sys
+}
+
+## mount ramdisk as tmpfs (used ram in real = used space in ramdisk !)
+do_ramdisk() {
+ ewarn "Mounting Ramdisk..."
+ RAMSIZE="$BFURAMDiskSize"
+ if [ "$RAMSIZE" = "" ]; then RAMSIZE="`cmdline_value ramsize`"; fi
+ if [ "$RAMSIZE" = "" ]; then RAMSIZE="80%"; fi
+ mount -t tmpfs -o size=$RAMSIZE tmpfs $MEMORY
+ efetch "mounted with max size $RAMSIZE"
+}
+
+## some settings for kernel
+do_kernel_init() {
+ ewarn "Kernel settings..."
+ efetch "enabling dynamic tick timer"
+ echo 1 > /sys/devices/system/timer/timer0/dyn_tick
+ do_lcdbl_set
+}
+
+## set backlight, read from cmdline(mmc) or use default value 40
+do_lcdbl_set() {
+ efetch "current backlight: `cat /sys/class/backlight/pxapwm-bl/brightness`"
+ if [ "$LCDBL" != "" ]; then
+ efetch "setting backlight from cmdline..."
+ echo $LCDBL >/sys/class/backlight/pxapwm-bl/brightness
+ else
+ efetch "setting backlight to init default: $LCDBLDEF"
+ echo $LCDBLDEF >/sys/class/backlight/pxapwm-bl/brightness
+ fi
+ efetch "backlight after set: `cat /sys/class/backlight/pxapwm-bl/brightness`"
+}
+
+## power on usb port, used for usb network
+do_usb_power() {
+ if [ $1 -eq 1 ]; then
+ efetch "Powering on USB"
+ echo "h 85" > /proc/gpioed 2>/dev/null
+ else
+ efetch "Powering off USB"
+ echo "l 53" > /proc/gpioed $SILENT0
+ echo "l 85" > /proc/gpioed $SILENT0
+ fi
+}
+
+## power on serial port, used for ext.keyboard
+do_serial_power() {
+ if [ $1 -eq 1 ]; then
+ efetch "Powering on serial"
+ echo "l 35" > /proc/gpioed $SILENT0
+ echo "h 35" > /proc/gpioed $SILENT0
+ else
+ efetch "Powering off serial"
+ echo "l 35" > /proc/gpioed $SILENT0
+ fi
+}
+
+## initialize usb network interface
+do_network_init() {
+ if [ "$usenet" != "0" ]; then
+ ewarn "Initializing network"
+ do_usb_power 0
+ modprobe -s -q g_ether
+ do_die_msg "modprobe g_ether failed"
+ do_usb_power 1
+ fi
+}
+
+## network configure in text mode - not used for BFUSettings
+do_network_conf() {
+ ewarn "Configure network:"
+ einfo "Press 'Center' for network as\n\tHost: 192.168.0.1/24\n\tPalm: 192.161.0.231/24"
+ einfo "Press 'Address(c)', 'Center' for network as\n\tHost: 10.0.7.1/24\n\tPalm: 10.0.7.231/24"
+ ewarn "Don't forget to apply network configuration\n\t on your host before continue..."
+ read netpref
+ if [ "$netpref" = "c" ]; then
+ NET_HOST_IP="10.0.7.1"
+ NET_PALM_IP="10.0.7.231"
+ NET_NETMASK="255.255.255.0"
+ else
+ NET_HOST_IP="192.168.0.1"
+ NET_PALM_IP="192.168.0.231"
+ NET_NETMASK="255.255.255.0"
+ fi
+ unset netpref
+ export NET_HOST_IP NET_PALM_IP NET_NETMASK
+ ewarn "Configuring network"
+ ifconfig usb0 $NET_PALM_IP netmask $NET_NETMASK up
+ do_die_msg "ifconfig failed for \"$NET_PALM_IP netmask $NET_NETMASK\""
+ route del default gw $NET_HOST_IP 2>/dev/null
+ route add default gw $NET_HOST_IP
+ if [ $? -ne 0 ]; then
+ eerr "failed routing\n\t$NET_HOST_IP\n\trestart configure.."
+ do_configure
+ fi
+ sleep 2
+}
+
+## configure network
+do_network_def() {
+ if [ "$usenet" != "0" ]; then
+ ## set default net
+ NET_HOST_IP="192.168.0.1"
+ NET_PALM_IP="192.168.0.231"
+ NET_NETMASK="255.255.255.0"
+ if [ "$BFUPalmIP" != "" ]; then ## if BFUSettings present, replace previous defaults
+ NET_HOST_IP="$BFUPCIP"
+ NET_PALM_IP="$BFUPalmIP"
+ NET_NETMASK="$BFUNetMask"
+ fi
+ export NET_HOST_IP NET_PALM_IP NET_NETMASK
+ ewarn "Configuring network"
+ efetch "PalmIP: $NET_PALM_IP"
+ efetch "HostIP: $NET_HOST_IP"
+ efetch "Mask: $NET_NETMASK"
+ if [ "$NET_NETMASK" = "255.255.255.255" ]; then
+ efetch "pointopoint used"
+ ifconfig usb0 $NET_PALM_IP pointopoint $NET_HOST_IP netmask $NET_NETMASK up
+ do_die_msg "ifconfig failed for \"$NET_PALM_IP pointopoint $NET_HOST_IP\""
+ else
+ ifconfig usb0 $NET_PALM_IP netmask $NET_NETMASK up
+ do_die_msg "ifconfig failed for \"$NET_PALM_IP netmask $NET_NETMASK\""
+ fi
+ route add default gw $NET_HOST_IP
+ if [ $? -ne 0 ]; then
+ eerr "failed routing\n\t$NET_HOST_IP\n\t(re)start configure.."
+ do_configure
+ fi
+ fi
+}
+
+## select file with list of modules for boot, if not found create modlist-all.txt from all squashfs files
+do_select_modlist() {
+ if [ "`ls $MMC_MNT$LINUX2RAM/modlist*.txt`" != "" ]; then
+ modporadi="1"
+ CWD=`pwd` ### xxx
+ cd $MMC_MNT$LINUX2RAM ###
+ for modtxt in `ls -1 modlist*.txt` ; do
+ if [ "$modporadi" = "$BFUModList" ]; then
+ MODLIST="$modtxt"
+ export MODLIST
+ return 0
+ else
+ modporadi=$(($modporadi+1))
+ fi
+ done
+ unset modtxt
+ cd $CWD ###
+ else
+ if [ -e "$MMC_MNT$LINUX2RAM" ]; then
+ efetch "modlist: $MODLIST - NOT FOUND/OR SELECTED"
+ efetch "make modlist-all.txt in memory..."
+ efetch "... from $LINUX2RAM/*.squashfs"
+ CWD=`pwd`
+ cd $MMC_MNT$LINUX2RAM
+ ls -1 *.squashfs >"$MEMORY/modlist-all.txt"
+ cd $CWD
+ MODLIST="modlist-all.txt"
+ export MODLIST
+ else
+ einfo "Directory $LINUX2RAM NOT FOUND :-("
+ fi
+ fi
+}
+
+
+## choice default start:
+## - if found config cmdline - run old textmode configure
+## - if BFUSource is empty - run default configured => SD-GPE-NET192
+## - in other case - run BFUSettings configure
+do_start_default() {
+ echo
+ if [ `cmdline_parameter config` ]; then
+ if [ `cmdline_parameter mmc` ]; then do_mmc_mount; fi
+ do_configure
+ else
+ if [ "$BFUSource" = "" ]; then
+ ewarn "Start Default: SD/MMC-GPE"
+ BFUPalmIP="" ## reset -> do_network_def use default
+ do_network_def
+ MODLIST="modlist-gpe.txt"
+ do_mmc_mount
+ do_get_modules_mmc
+ else
+ do_configure_bfu
+ fi
+ fi
+}
+
+## old configure on linux side in text mode
+do_configure() {
+ do_network_conf
+ ewarn "Select start method:"
+ efetchall "MMC: 'Center'\n\t"
+ efetchall "WWW: 'Memo(m)','Center'"
+ efetchall "NFS: 'Address(c)','Center'"
+ efetchall "MMCpart: 'ToDo(t)','Center'"
+ read via
+ if [ "$via" = "" ]; then
+ efetch "partition ? for p1(vfat):'Center'\n\t\t for p2(ext2):'Memo','Center'"
+ read wpart
+ if [ "$wpart" = "" ]; then
+ export part=p1
+ VFSTYPE="vfat"
+ fi
+ if [ "$wpart" = "m" ]; then
+ export part=p2
+ VFSTYPE="ext2"
+ fi
+ unset wpart
+ do_mmc_mount
+ do_select_modlist
+ do_get_modules_mmc
+ fi
+ if [ "$via" = "m" ]; then
+ do_network_def
+ do_get_modules_www
+ fi
+ if [ "$via" = "c" ]; then
+ do_mount_nfs
+ do_chroot_nfs
+ fi
+ if [ "$via" = "t" ]; then
+ do_mmc_mount
+ do_chroot_oncard
+ fi
+ unset via
+}
+
+## configure boot process from BFUSettings parameters
+do_configure_bfu() {
+ #### configure network
+ if [ $BFUUseNet = "1" ]; then do_network_def; fi
+
+ #### type of partition
+ if [ "$BFUFS" = "0" ]; then VFSTYPE="vfat"; fi
+ if [ "$BFUFS" = "1" ]; then VFSTYPE="ext2"; fi
+ if [ "$BFUFS" = "2" ]; then VFSTYPE="ext3"; fi
+
+
+ #### source is modules on card(memory)
+ if [ "$BFUSource" = "0" ]; then
+ do_mmc_mount
+ do_select_modlist
+ do_get_modules_mmc
+ fi
+
+ #### source is modules from www
+ if [ "$BFUSource" = "1" ]; then
+ ewarn "Don't forget config usb0 on HOST..."
+ sleep 3
+ WWW="$BFUAddress"
+ if [ "$BFUUseNet" = "0" ]; then usenet="1"; do_network_def; fi ### replace BFUUseNet=0
+ do_get_modules_www
+ fi
+
+ #### source is real rootfs on nfs share
+ if [ "$BFUSource" = "2" ]; then
+ ewarn "Don't forget config usb0 on HOST..."
+ sleep 3
+ NFS="$BFUAddress"
+ if [ $BFUUseNet = "0" ]; then do_network_def; fi ### replace BFUUseNet=0
+ do_mount_nfs
+ do_chroot_nfs
+ fi
+
+ #### source is real rootfs on nfs share
+ if [ "$BFUSource" = "3" ]; then
+ do_mmc_mount
+ do_mmc_move ### xxxxx
+ do_chroot_oncard
+ fi
+}
+
+## get modules from www server, from modlist.txt, or modlist-gpe.txt
+do_get_modules_www() {
+ $DEBUGCMD
+ ewarn "Getting module list:"; efetch "$WWW/modlist.txt"
+ cd $MEMORY
+ wget "$WWW/modlist.txt" -P $MEMORY
+ if [ -e modlist.txt ]; then
+ MODLIST="modlist.txt"
+ else
+ efetch "try modlist-gpe.txt"
+ wget "$WWW/modlist-gpe.txt"
+ MODLIST="modlist-gpe.txt"
+ fi
+ export MOD_STR
+ do_die
+ MOD_STR=""
+ mkdir -p $COPY2RAM
+ for mod in `cat $MEMORY/$MODLIST` ; do
+ if [ -e $MMC_MNT$LINUX2RAM/$mod ]; then
+ efetch "$mod"
+ wget "$WWW/$mod" -P $COPY2RAM
+ MOD_STR="$mod $MOD_STR"
+ else
+ efetch "$mod"
+ wget "$WWW/$mod" -P $COPY2RAM
+ MOD_STR="$mod $MOD_STR"
+ fi
+ done
+ export MOD_STR
+ MODDIR="$COPY2RAM"
+ start_from_www="1"
+ $DEBUGCMD
+}
+
+## get modules from mmc card
+do_get_modules_mmc() {
+ $DEBUGCMD
+ ewarn "Getting modules list..."
+ cd $MEMORY
+ MOD_STR=""
+ ## don't try copy modlist from mmc, if found in memory
+ if [ ! -e $MEMORY/modlist-all.txt ]; then
+ efetch "$MMC_MNT$LINUX2RAM/$MODLIST"
+ cp "$MMC_MNT$LINUX2RAM/$MODLIST" .
+ do_die
+ fi
+
+ ## get MOD_STR from MODLIST
+ if [ "$copy2ram" = "1" ]; then efetch "modules will be copied to ram. wait..."; fi
+ for mod in `cat $MODLIST` ; do
+ if [ "$copy2ram" = "1" ]; then
+ efetch "$mod"
+ mkdir -p $COPY2RAM
+ cp $MMC_MNT$LINUX2RAM/$mod $COPY2RAM
+ MOD_STR="$mod $MOD_STR"
+ export MOD_STR
+ MODDIR="$COPY2RAM"
+ else
+ MOD_STR="$mod $MOD_STR"
+ export MOD_STR
+ MODDIR="$MMC_MNT$LINUX2RAM"
+ fi
+ done
+ export MOD_STR
+ start_from_mmc="1"
+ $DEBUGCMD
+}
+
+## mount mmc partition for boot, with or without run fsck
+do_mmc_mount() {
+ do_cpufreq_scale
+ ewarn "Initializing MMC..."
+ modprobe -s -q wbsd-palmt3
+ sleep 9
+
+ if [ "$BFUDevice" = "" ]; then
+ if [ "$part" = "" ]; then part="p1"; fi
+ MMC_PART="/dev/mmcblk0"$part
+ else
+ MMC_PART="$BFUDevice"
+ fi
+ export MMC_PART
+
+ if [ "$VFSTYPE" = "vfat" ]; then modprobe vfat; fi
+ if [ "$VFSTYPE" = "ext2" ]; then modprobe ext2; fi
+
+ if [ ! -e $MMC_MNT ]; then mkdir -p $MMC_MNT; fi
+
+ if [ "$fsckon" = "1" ]; then
+ echo
+ ewarn "MANUALLY run 'fsck' on $MMC_PART ?"
+ if [ "$VFSTYPE" = "vfat" ] ; then
+ if message_skipped "\t...dosfsck..." 9 "SKIP"; then efetch "autorepair,save unused,verify write"; dosfsck -fyvVw $MMC_PART; fi
+ else
+ if message_skipped "\t...e2fsck..." 9 "SKIP"; then e2fsck $MMC_PART; fi
+ fi
+ fi
+
+ efetch "mount $MMC_PART to $MMC_MNT"
+ efetch "(filesystem: $VFSTYPE, readmode: $rmode)"
+
+ ### only for vfat set umask
+ if [ "$VFSTYPE" = "vfat" ]; then
+ mount -t $VFSTYPE $MMC_PART $MMC_MNT -o $rmode,noatime,umask=0000
+ else
+ mount -t $VFSTYPE $MMC_PART $MMC_MNT -o $rmode,noatime
+ fi
+
+ if [ $? -ne 0 ]; then
+ eerr "Error while mounting: $MMC_PART\n\tNOTE: Try run Garux again, after reinsert card...\n"
+ showbfu="1"; do_bfu_check; sleep 7
+ ewarn "Remove mmc modules, run configure..."
+ rmmod wbsd-palmt3
+ do_configure
+ fi
+
+ do_cmdline_check_mmc
+ do_cpufreq_scale_mmc
+}
+
+## try reinitialize mmc, if mmc/sd don't mount [if say PowerDown don't work]
+do_mmc_reini() {
+ einfo "DEInitializing MMC..."
+ umount -l $MMC_PART $MMC_MNT
+ rmmod wbsd-palmt3
+ einfo "MAYBE: try change, add missed file\n\t or reinsert card ?\n\tafter this try press 'Center'"
+ read key
+ do_mmc_mount
+ unset key
+}
+
+## mount NFS share for boot
+do_mount_nfs() {
+ ewarn "Mounting NFS - $NFS"
+ ewarn "${C_REDY} WARNING: ${C_OFF}${C_WHIT}boot is ssSlLOoooWww"
+ mkdir -p $MEMORY/nfs
+
+ ## only for test
+ ### efetch "run portmap:"; portmap
+ ### efetch "run inetd: "; inetd
+ ### efetch "ifconfig" loopback; ifconfig lo 127.0.0.1 netmask 255.0.0.0 up
+
+ modprobe -v nfs
+ mount -t nfs $NFS $MEMORY/nfs
+ efetch "list $NFS:"; ls $MEMORY/nfs; efetch "wait for enter......"; read enter ###
+ $DEBUGCMD
+ if [ $? -ne 0 ]; then
+ eerr "Error while mounting:\n\t$NFS"
+ via=""
+ do_configure
+ fi
+}
+
+## create unionfs from modules, with writing support to changes dir in memory
+do_unionfs() {
+ ewarn "Creating unionfs"
+ mkdir -p $CHANGES
+ unionarg="dirs=$CHANGES=rw"
+ for mod in $MOD_STR ; do
+ unionarg="$unionarg:$IMAGES/$mod=ro"
+ done
+ mount -t unionfs -o $unionarg unionfs $UNION
+ do_die_msg "mount unionfs failed, mount args:\n$unionarg"
+}
+
+## create aufs from modules, with writing support to changes dir in memory
+do_aufs() {
+ ewarn "Creating unionfs (aufs)"
+ mkdir -p $CHANGES
+ unionarg="br:$CHANGES=rw"
+ for mod in $MOD_STR ; do
+ unionarg="$unionarg:$IMAGES/$mod=ro"
+ done
+ mount -t aufs -o $unionarg aufs $UNION
+ do_die_msg "mount aufs failed, mount args:\n$unionarg"
+}
+
+## insert squashfs modules into unionfs
+do_plug_mod() {
+ ewarn "Mounting modules"
+ cd $MEMORY
+ for mod in $MOD_STR ; do
+ if [ -e $MODDIR/$mod ]; then
+ efetch "$mod"
+ mkdir -p $IMAGES/$mod
+ mount -t squashfs -o ro,loop $MODDIR/$mod "$IMAGES/$mod"
+ else
+ ewarn "${C_REDY} WARNING: ${C_OFF}${C_WHIT} $mod not found\n\t ... put it in $LINUX2RAM\n\t ..or remove line from modlist-???.txt"
+ sleep 9
+ fi
+
+ done
+}
+
+## re-rooted to directory with new root
+do_chroot() {
+ cd $UNION
+ mkdir -p mnt/live
+ umount /sys
+ if [ ! -e $UNION/dev/console ]; then mknod $UNION/dev/console c 5 1; fi
+ if [ ! -e $UNION/dev/initctl ]; then mknod $UNION/dev/initctl p; fi
+ pivot_root . mnt/live
+ do_bin2flash_check
+ do_insmod_ext
+ ewarn "Running init..."
+ exec /usr/sbin/chroot . /sbin/init 5 <dev/console >dev/console 2>&1
+ do_die
+}
+
+do_chroot_nfs() {
+ cd $MEMORY/nfs
+ mkdir -p mnt/live
+ umount /sys
+ if [ ! -e $MEMORY/nfs/dev/console ]; then mknod $MEMORY/nfs/dev/console c 5 1; fi
+ if [ ! -e $MEMORY/nfs/dev/initctl ]; then mknod $MEMORY/nfs/dev/initctl p; fi
+ pivot_root . mnt/live
+ do_insmod_ext
+ ewarn "Running init..."
+ exec /usr/sbin/chroot . /sbin/init 5 <dev/console >dev/console 2>&1
+ do_die
+}
+
+do_chroot_oncard() {
+ cd $MMC_MNT
+ mkdir -p mnt/live
+ umount /sys
+ if [ ! -e dev/console ]; then mknod dev/console c 5 1; fi
+ if [ ! -e dev/initctl ]; then mknod dev/initctl p; fi
+ pivot_root . mnt/live
+ do_insmod_ext
+ ewarn "Running init..."
+ exec /usr/sbin/chroot . /sbin/init 5 <dev/console >dev/console 2>&1
+ do_die
+}
+
+######### MISC #########
+
+## initialise stowaway/docota keyboard
+do_stowaway() {
+ if [ "$usekbd" != "0" ]; then
+ ewarn "Initializing Stowaway compatible keyboard"
+ modprobe stowaway
+ do_serial_power 1
+ inputattach --stowaway /dev/ttyS3 &
+ fi
+}
+
+## copy files from unioncopy dir (in init) [ for now is used only for inputattach ]
+do_unioncopy(){
+ if [ -e /unioncopy ]; then
+### einfo "Copying some file from init to real root (/)"
+### cp -a /unioncopy/* $UNION 2>/dev/null
+ if [ "$usekbd" != "0" ]; then ### fixme - rewrite for separated copy !?
+ ewarn "Copying ...resume.d/inputtattach to real root (/)"
+ cp -a /unioncopy/* $UNION 2>/dev/null
+ fi
+ fi
+
+}
+
+## if found rootcopy (in source dir for modules), recursive copy all to /
+do_rootcopy() {
+ if [ -e $MMC_MNT$LINUX2RAM/rootcopy ]; then
+ ewarn "Copying 'rootcopy' to real root (/)"
+ cp -a $MMC_MNT$LINUX2RAM/rootcopy/* $UNION 2>/dev/null
+ fi
+ if [ "$start_from_www" = "1" ]; then
+ cd $COPY2RAM
+ einfo "Look for 'rootcopy.zip' on:"; efetch "$WWW"
+ wget "$WWW/rootcopy.zip" -P $COPY2RAM
+ if [ -e $COPY2RAM/rootcopy.zip ]; then
+ efetch "found, unpack to real root (/)..."
+ unzip -o -q $COPY2RAM/rootcopy.zip -d $UNION
+ else
+ efetch "not found...skiping"
+ fi
+ fi
+}
+
+## unpack live_changes.squashfs if found (created if reboot, or manualy run Live_Save icon in GPE)
+do_load_live_changes() {
+ if [ "$start_from_mmc" = "1" ]; then
+ if [ "$liveskip" != "1" ]; then
+ if [ -e $LIVE_CHANGES ]; then
+ if message_skipped "$WARN Loading live_changes... " 3 "${C_REDY}SKIP${C_OFF}"; then
+ efetch "unpacking ..."
+ unsquashfs -f -dest $CHANGES $LIVE_CHANGES >/dev/null
+ else
+ efetchall "skiping ..."
+ fi
+ fi
+ fi
+ fi
+}
+
+## move mmc mountpoint to /mnt/mmc after finish init
+do_mmc_move() {
+ if [ "$start_from_mmc" = "1" ]; then
+ ewarn "Move MMC mountpoint to /mnt/mmc"
+ mkdir -p $MMC_MNTNEW
+ ### xxx if [ $rmode="rw" ]; then mount $MMC_PART $MMC_MNT -o remount,$rmode; fi
+ mount --move $MMC_MNT $MMC_MNTNEW
+ rm -r -f $MMC_MNT
+ fi
+
+ ## mount also p1, if for boot is used p2
+ if [ "$MMC_PART" != "/dev/mmcblk0p1" ]; then
+ modprobe vfat
+ efetch "For boot not used p1, mounting p1(FAT) for data"
+ if [ "$start_from_mmc" = "1" ]; then
+ mkdir -p $MMC_MNTNEW'1'
+ mount /dev/mmcblk0p1 $MMC_MNTNEW'1' -o $rmode,noatime,umask=0000
+ else
+ mkdir -p $MMC_MNT/mnt/mmc1
+ mount /dev/mmcblk0p1 $MMC_MNT/mnt/mmc1 -o $rmode,noatime,umask=0000
+ fi
+ fi
+}
+
+## set cpufreq to fixed or auto frequency, using cpufreq governors
+do_cpufreq_scale() {
+ ewarn "Setting CPU speed..."
+ efetch "minimal frequency: "`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`" kHz"
+ efetch "maximal frequency: "`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`" kHz"
+ efetch "speed before is: "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed`" kHz"
+ if [ `cmdline_parameter cpufreq` ]; then
+ CPUFREQ="`cmdline_value cpufreq`"
+ efetch "read cpufreq from /proc/cmdline: $CPUFREQ'000' kHz"
+ fi
+ if [ "$CPUFREQ" = "" ]; then CPUFREQ="133"; efetch "set default value from init..."; fi
+ if [ "$CPUFREQ" != "auto" ]; then
+ echo $CPUFREQ'000' >/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
+ efetchall "after set is speed: "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed`" kHz"
+ else
+ GOVERNOR="conservative"; export GOVERNOR ; modprobe -q "cpufreq_$GOVERNOR"
+ echo "$GOVERNOR" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+ efetchall "cpufreq is set to auto ($GOVERNOR)"
+ fi
+}
+
+## change cpufreq from text file 'cmdline' in source dir for modules/real root (if found file & cpu=)
+do_cpufreq_scale_mmc() {
+ echo
+ if [ -e $CMD_MMC ]; then
+ if [ `cmdline_parameter cpufreq $CMD_MMC` ]; then
+ ewarn "ReSetting CPU speed, from:"; efetch " $CMD_MMC"
+ efetch "speed before is: "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed`" kHz"
+ CPUFREQ="`cmdline_value cpufreq $CMD_MMC`"
+ if [ "$CPUFREQ" != "auto" ]; then
+ echo $CPUFREQ'000' >/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
+ efetch "after set is speed: "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed`" kHz"
+ else
+ GOVERNOR="conservative"; export GOVERNOR ; modprobe -q "cpufreq_$GOVERNOR"
+ echo "$GOVERNOR" >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+ efetch "cpufreq is set to auto ($GOVERNOR)"
+ fi
+ fi
+ fi
+ echo
+}
+
+## show kernel cmdline
+do_cmdline_show() {
+ if [ "$SILENT" = "" ]; then
+ einfo "CMDLine"
+ echo `cat /proc/cmdline`
+ fi
+}
+
+## check kernel/garux cmdline parameters
+do_cmdline_check() {
+ if [ -e /proc/cmdline ]; then
+ if [ `cmdline_parameter nokbd` ]; then usekbd="0"; fi
+ if [ `cmdline_parameter debug` ]; then DEBUGCMD="debug"; fi
+ if [ `cmdline_parameter mmcrw` ]; then rmode="rw"; else rmode="ro"; fi
+ if [ `cmdline_parameter copy2ram` ]; then copy2ram="1"; fi
+ if [ `cmdline_parameter nfs` ]; then NFS="`cmdline_value nfs`"; else NFS="$NET_HOST_IP:/home/palmlinux/nfs"; fi
+ if [ `cmdline_parameter www` ]; then WWW="`cmdline_value www`"; else WWW="http://$NET_HOST_IP$LINUX2RAM"; fi
+ if [ `cmdline_parameter lcdbl` ]; then LCDBL="`cmdline_value lcdbl`"; fi
+ if [ `cmdline_parameter fsck` ]; then fsckon="1"; fi
+ if [ `cmdline_parameter ss` ]; then liveskip="1"; fi
+ fi
+}
+
+## check parameters from text file 'cmdline' in source dir for modules/real root
+do_cmdline_check_mmc() {
+ if [ -e $CMD_MMC ]; then
+ if [ `cmdline_parameter nokbd $CMD_MMC` ]; then usekbd="0"; fi
+ if [ `cmdline_parameter debug $CMD_MMC` ]; then DEBUGCMD="debug"; fi
+ if [ `cmdline_parameter mmcrw $CMD_MMC` ]; then rmode="rw"; fi
+ if [ `cmdline_parameter copy2ram $CMD_MMC` ]; then copy2ram="1"; fi
+ if [ `cmdline_parameter lcdbl $CMD_MMC` ]; then LCDBL="`cmdline_value lcdbl $CMD_MMC`"; do_lcdbl_set; fi
+ if [ `cmdline_parameter skipsaves $CMD_MMC` ]; then liveskip="1"; fi
+ fi
+}
+
+## import BFUSettings via BFULinuxHelper, and set value from it
+do_bfu_check() {
+ ewarn "Importing BFUSettings..."
+ ### replace showbfu, if run again
+ if [ "$showbfu" = "" ]; then if [ "`BFULinuxHelper | grep "BFUSilentBoot=1"`" = "" ]; then showbfu="1"; fi; fi
+ if [ "$showbfu" = "1" ]; then einfo "Show BFUSettings... "; fi
+ for bfu in `BFULinuxHelper` ; do
+ if [ "$showbfu" = "1" ]; then efetchall "$bfu" 5; fi
+ export $bfu
+ done
+
+ ## BFUSilentBoot
+ ## for BFUSilentBoot=1 MUST be set SILENT !
+ if [ "$BFUSilentBoot" = "1" ]; then
+ echo "0" > /proc/sys/kernel/printk
+ SILENT="1>/dev/null"
+ SILENT0=">/dev/null"
+ SILENT2="2>/dev/null"
+ # <dev/stdout >/dev/null <dev/console >/dev/null
+ fi
+ if [ "$BFUAddress" != "" ]; then LINUX2RAM="$BFUAddress"; fi
+ if [ "$BFUUseNet" = "0" ]; then usenet="0"; fi
+ if [ "$BFUKeyboard" = "0" ]; then usekbd="0"; fi
+ if [ "$BFUDebug" = "1" ]; then DEBUGCMD="debug"; fi
+ if [ "$BFUCardRO" = "0" ]; then rmode="rw"; else rmode="ro"; fi
+ if [ "$BFUCPUspeed" = "0" ]; then CPUFREQ="auto"; fi
+ if [ "$BFUCPUspeed" = "1" ]; then CPUFREQ="133"; fi
+ if [ "$BFUCPUspeed" = "2" ]; then CPUFREQ="266"; fi
+ if [ "$BFUCPUspeed" = "3" ]; then CPUFREQ="399"; fi
+ if [ "$BFUCopy2RAM" = "1" ]; then copy2ram="1"; fi
+ if [ "$BFUFSCK" = "1" ]; then fsckon="1"; fi
+ if [ "$BFULive" = "0" ]; then liveskip="1"; fi
+}
+
+## run shell for debuging init, test problebs etc.. need stowaway/dicota keyboard
+debug() {
+ ewarn ": Debugging started [CTRL+C for END]"
+ sh < /dev/console
+ echo
+}
+
+## workaround for compare md5
+md5_of() {
+
+ echo "`/mnt/live/bin/md5sum < $1`"
+}
+
+## workaround for compare md5
+cat_of() {
+
+ echo "`/mnt/live/bin/cat $1` -"
+}
+
+######## FROM SLAX(LIVE-SCRIPTS)
+egrep_o() {
+# egrep_o is a replacement for "egrep -o". It prints only the last
+# matching text. $1 = regular expression
+ cat | egrep "$1" | sed -r "s/.*($1).*/\\1/"
+}
+
+cmdline_parameter() {
+# look into cmdline and echo $1 back if $1 is set
+# $1 = value name, case sensitive, for example livecd_subdir
+# $2 = file to use instead /proc/cmdline, optional
+ CMDLINE=/proc/cmdline
+ if [ "$2" != "" ]; then CMDLINE="$2"; fi
+ cat "$CMDLINE" | egrep_o "(^|[[:space:]]+)$1(\$|=|[[:space:]]+)" | egrep_o "$1"
+}
+
+cmdline_value() {
+# look into cmdline and echo value of $1 option
+# $1 = value name, case sensitive, for example livecd_subdir
+# $2 = file to use instead /proc/cmdline, optional
+ CMDLINE=/proc/cmdline
+ if [ "$2" != "" ]; then CMDLINE="$2"; fi
+ cat "$CMDLINE" | egrep_o "(^|[[:space:]]+)$1=([^[:space:]]+)" | egrep_o "=.*" | cut -b 2- | tail -n 1
+}
+
+message_skipped() {
+# use: $1 - text, $2 - timeout, $3 - text for 'center'
+
+ i=$2; echo -ne "$1" "[${C_YEL} center=$3 ${C_WHIT}] ${C_RED}"$i"s${C_OFF}"
+ while [ $i -gt 0 ]; do
+ i=$(($i-1))
+ read -t 1 -s -n 1 CHAR
+ if [ $? = 0 -a "$CHAR" = "" ]; then echo; return 1; fi
+ echo -e -n "${C_RED}"$i"s${C_OFF}"
+ done
+ echo
+ return 0
+}
+
+######### AUTOFLASH start
+do_flash_start() {
+ mount -t proc none /proc 2>/dev/null
+ mount -t sysfs sysfs /sys 2>/dev/null
+ do_mtdutils_check
+ do_init_mtd
+ do_setup_mtd1
+ do_flash_prepare
+ do_setup_mtd0
+ do_flash_prepare
+ ewarn "${C_REDY}YOU SURE START WRITE INTO FLASH ???\n\t${C_YEL}('Address(c)', 'Center' for YES)"
+ read key
+ if [ "$key" = "c" ]; then
+ do_setup_mtd1
+ do_flash_write
+ do_setup_mtd0
+ do_flash_write
+ ewarn "Flashing is ended ${C_GRE}OK${C_OFF}"
+ fi
+ unset key
+ do_continue_boot
+}
+
+do_flash_restore() {
+ efetchall "restore from backup..."
+ mount -t proc none /proc 2>/dev/null
+ mount -t sysfs sysfs /sys 2>/dev/null
+ do_mtdutils_check
+ do_init_mtd
+ do_setup_mtd1_restore
+ do_flash_prepare
+ do_setup_mtd0_restore
+ do_flash_prepare
+ ewarn "${C_REDY}YOU SURE START WRITE INTO FLASH ???\n\t${C_YEL}('Address(c)', 'Center' for YES)${C_OFF}"
+ read key
+ if [ "$key" = "c" ]; then
+ do_setup_mtd1_restore
+ do_flash_write
+ do_setup_mtd0_restore
+ do_flash_write
+ ewarn "Flashing is ended ${C_GRE}OK${C_OFF}"
+ fi
+ unset key
+ do_continue_boot
+}
+
+do_init_mtd() {
+ efetchall "probing modules for flash memory"
+ $PREFIX/sbin/modprobe -s -q palmt3-flash
+ do_die_msg "modprobe palmt3-flash failed"
+ $PREFIX/sbin/modprobe -s -q mtdchar
+ if [ ! -e /dev/mtd0 ]; then mknod /dev/mtd0 c 90 0; fi
+ if [ ! -e /dev/mtd1 ]; then mknod /dev/mtd1 c 90 2; fi
+ do_die_msg "modprobe mtdchar failed"
+ efetchall "check flash partition..."
+ do_compare "$MTD_PROC_MD5" "`md5_of /proc/mtd`" "MD5: "
+}
+
+do_uninit_mtd() {
+ efetchall "remove modules for flash memory"
+ $PREFIX/sbin/modprobe -r -q mtdchar 2>/dev/null
+ $PREFIX/sbin/modprobe -r -q palmt3-flash 2>/dev/null
+ $PREFIX/sbin/modprobe -r -q cfi_cmdset_0001 2>/dev/null
+ $PREFIX/sbin/modprobe -r -q cfi_probe 2>/dev/null
+# rm /dev/mtd0
+# rm /dev/mtd1
+}
+
+do_flash_prepare() {
+ if [ "$MTD_NEW" != "skip" ]; then
+ efetchall "prepare for: ${C_YEL}$MTD_NEW${C_OFF} ..."
+
+## temporary(?) disabled - because MTD_DEV_MD5_AFTER is fixed, and MD5 for 0.1 and 0.2 is present in do_mtdX_setup
+# if [ ! -e "$BIN2FLASH/$MTD_NEW.md5" ]; then
+# efetch "${C_REDY}NOT FOUND: $MTD_NEW.md5"
+# efetch "${C_YEL}create it, ONLY with MD5 number."
+# efetch "${C_YEL}because flashing is DANGEROUS..."
+# efetch "${C_YEL}without this is ${C_REDW}STOPED${C_OFF}"
+# $PREFIX/bin/sleep 10
+# do_mmc_reini
+# do_flash_restart
+# fi
+
+ ## don't create backup if restore ;)
+ if [ "$backup" != "NO" ]; then do_flash_backup; fi
+
+ efetchall "copy ${C_YEL}$MTD_NEW${C_OFF} to ${C_YEL}ramdisk${C_OFF}..."
+ if [ -e $PREFIX/memory/$MTD_NEW ]; then $PREFIX/bin/rm $PREFIX/memory/$MTD_NEW; fi
+ $PREFIX/bin/cp $BIN2FLASH/$MTD_NEW $PREFIX/memory
+ do_compare "`md5_of $BIN2FLASH/$MTD_NEW`" "`md5_of /mnt/live/memory/$MTD_NEW`" "MD5: "
+ fi
+}
+
+do_flash_backup() {
+ if [ ! -e $BIN2FLASH/$MTD_BAK ]; then
+ efetchall "backup ${C_YEL}$MTD_DEV${C_OFF} to ${C_YEL}$MTD_BAK${C_OFF}"
+ dd if=$MTD_DEV of=$BIN2FLASH/$MTD_BAK 2>/dev/nul
+ do_compare "`md5_of $MTD_DEV`" "`md5_of $BIN2FLASH/$MTD_BAK`" "MD5: "
+ efetchall "create ${C_YEL}$MTD_BAK.md5${C_OFF}..."
+ echo "`md5_of $MTD_DEV`" >$BIN2FLASH/$MTD_BAK.md5
+ ## FIXME change $PREFIX/bin/cat to cat_of AFTER fix " -"
+ do_compare "`md5_of $MTD_DEV`" "`$PREFIX/bin/cat $BIN2FLASH/$MTD_BAK.md5`" "MD5: "
+ else
+ efetchall "backup of ${C_YEL}$MTD_DEV${C_WHIT} found, check it${C_OFF}"
+ do_compare "`$PREFIX/bin/cat $BIN2FLASH/$MTD_BAK.md5`" "`md5_of $BIN2FLASH/$MTD_BAK`" "MD5: " ## FIXME change $PREFIX/bin/cat to cat_of AFTER fix " -"
+ if [ "`md5_of $BIN2FLASH/$MTD_BAK`" = "`md5_of $MTD_DEV`" ]; then
+ efetchall "... is same as ${C_YEL}$MTD_DEV"
+ else
+ efetchall "${C_YEL}... already flashed. Switch to 'restore'..."
+ if message_skipped "\t..." 9 "NoSwitch"; then do_flash_restore; fi
+ fi
+ fi
+}
+
+do_flash_write() {
+ if [ "$MTD_NEW" != "skip" ]; then
+ efetchall "prepare ${C_YEL}$MTD_DEV${C_OFF}..."
+ $PREFIX/sbin/flash_eraseall $MTD_DEV
+ efetchall "${C_RED}writing${C_OFF} ${C_YEL}$MTD_NEW${C_OFF} ..."
+ $PREFIX/bin/dd if=/mnt/live/memory/$MTD_NEW of=$MTD_DEV bs=128k conv=sync
+ if [ "$MTD_DEV_MD5_AFTER" != "" ]; then
+ efetchall "check ${C_YEL}$MTD_DEV${C_OFF} result:"
+ do_compare "$MTD_DEV_MD5_AFTER" "`md5_of $MTD_DEV`" "MD5: "
+ efetchall "${C_YEL}$MTD_NEW ${C_RED}writen fine ${C_OFF}"; echo
+ else
+ efetchall "${C_YEL}RESULT NOT BE CHECKED${C_OFF}"
+ fi
+ fi
+}
+
+do_mtdutils_check() {
+ if [ ! -e $PREFIX/sbin/flash_eraseall ]; then
+ efetchall "${C_RED}flash _eraseall not found${C_OFF}"
+ echo
+ do_flash_restart
+ fi
+}
+
+do_setup_mtd1() {
+ MTD_NEW="u-boot.bin"
+ if [ -e $BIN2FLASH/$MTD_NEW ]; then
+ MTD_DEV="/dev/mtd1"
+ MTD_BAK="backup_mtd1.bin"
+ if [ "`md5_of $BIN2FLASH/$MTD_NEW`" = "45155b0514406643a89c2e8a90fbfa65 -" ]; then
+ efetchall "found ${C_YEL}u-boot for 0x20000${C_OFF}"
+ MTD_DEV_MD5_AFTER="d7daf9494db0c5703855fbd37cb8dea5 -"
+ else
+ efetchall "${C_YEL}unknown ${C_RED}$MTD_NEW${C_WHIT}, continue at YOUR RISK${C_OFF}"
+ efetchall "${C_RED}AFTER FLASH, RESULT NOT BE CHECKED${C_OFF}"
+ MTD_DEV_MD5_AFTER=""
+ fi
+ else
+ MTD_NEW="skip"
+ fi
+}
+
+do_setup_mtd0() {
+ MTD_NEW="smallrom.bin"
+ if [ -e $BIN2FLASH/$MTD_NEW ]; then
+ MTD_DEV="/dev/mtd0"
+ MTD_BAK="backup_mtd0.bin"
+
+ if [ "`md5_of $BIN2FLASH/$MTD_NEW`" = "13d5b80e6fa7e130afc026e3a298aa2d -" ]; then
+ efetchall "found ${C_YEL}updated smallrom image (patch 0.1)${C_OFF}"
+ MTD_DEV_MD5_AFTER="a6a3ddcf1603b1f5227cac525f01f180 -"
+ else
+ if [ "`md5_of $BIN2FLASH/$MTD_NEW`" = "536311dacb78c013bdab518fac8f2ee7 -" ]; then
+ efetchall "found ${C_YEL}updated smallrom image (patch 0.2)${C_OFF}"
+ MTD_DEV_MD5_AFTER="e3cb68ee435cb8cdd7291f2ad30d97c6 -"
+ else
+ efetchall "${C_YEL}unknown ${C_RED}$MTD_NEW${C_WHIT}, continue at YOUR RISK${C_OFF}"
+ efetchall "${C_RED}AFTER FLASH, RESULT NOT BE CHECKED${C_OFF}"
+ MTD_DEV_MD5_AFTER=""
+ fi
+ fi
+
+ else
+ MTD_NEW="skip"
+ fi
+}
+
+do_setup_mtd1_restore() {
+ backup="NO"
+ MTD_NEW="backup_mtd1.bin"
+ MTD_DEV="/dev/mtd1"
+ MTD_DEV_MD5_AFTER="`$PREFIX/bin/cat $BIN2FLASH/$MTD_NEW.md5`" ## FIXME change $PREFIX/bin/cat to cat_of AFTER fix " -"
+}
+
+do_setup_mtd0_restore() {
+ backup="NO"
+ MTD_NEW="backup_mtd0.bin"
+ MTD_DEV="/dev/mtd0"
+ MTD_DEV_MD5_AFTER="`$PREFIX/bin/cat $BIN2FLASH/$MTD_NEW.md5`" ## FIXME change $PREFIX/bin/cat to cat_of AFTER fix " -"
+}
+
+do_bin2flash_check() {
+
+ if [ "$BFUReflash" = "1" ]; then
+ if [ -e "$BIN2FLASH" ]; then
+ ewarn "Found bin2flash dir, run autoreflash ?"
+ if message_skipped "\t..." 9 "SKIP"; then
+ if [ "`ls $BIN2FLASH|grep backup_mtd`" != "" ]; then
+ efetchall "found ${C_YEL}backup files${C_WHIT}, use it for RESTORE?"
+ if ! message_skipped "\t..." 9 "restore"; then do_flash_restore; else do_flash_start;fi
+ fi
+ else
+ efetchall "skiped"
+ fi
+ else
+ ewarn "${C_REDY}/bin2flash not found..${C_OFF}"
+ sleep 5
+ fi
+ fi
+}
+
+do_compare() {
+# use: $1 - from, $2 - to, $3 - text before result
+ if [ "$1" = "$2" ]; then
+ efetchall "${C_OFF}$3$1 ${C_GRE}OK${C_OFF}"
+ else
+ efetchall "${C_OFF}$3$2 ${C_REDY}BAD${C_OFF}"
+ do_flash_restart
+ fi
+}
+
+do_flash_restart() {
+ echo -e "${C_REDY} PROBLEM FOUND ${C_OFF}"
+ do_uninit_mtd
+ efetchall "${C_YEL}'Address(c)', 'Center' for restart${C_OFF}"
+ efetchall "${C_YEL}'Center' for continue normal boot...${C_OFF}"
+ read key
+ if [ "$key" = "c" ]; then
+ do_bin2flash_check
+ else
+ do_continue_boot
+ fi
+ unset key
+}
+
+do_continue_boot() {
+ do_uninit_mtd
+ ewarn "For continue in normal boot press 'Center'${C_OFF}"
+ read enter
+ umount /sys
+ ## end part of do_chroot
+ ewarn "Running init..."
+ exec /usr/sbin/chroot . /sbin/init 5 <dev/console >dev/console 2>&1
+ do_die
+}
+######### AUTOFLASH end
Property changes on: linux4palm/BFUGarux/init/live-lib
___________________________________________________________________
Name: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|