#! /bin/bash # # Dreamplug kernel install # This README can be used to flash the new kernel # Watch out for erase/flash errors # If errors are encountered you should redo the flash # # This is a mainline Linux Kernel and you must set # the mainlineLinux and arcNumber env variables in U-Boot # and change the bootargs for a successful boot. # # setenv mainlineLinux yes # Do one of the following three # setenv arcNumber 2097 # for standard sheevaplugs # setenv arcNumber 2678 # for e-sata sheevaplugs # setenv arcNumber 2659 # for guruplugs and dreamplugs ####### change bootargs, replace nand_mtd with orion_nand and add rootfstype=jffs2 # setenv bootargs rootfstype=jffs2 console=ttyS0,115200 mtdparts=orion_nand:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw ip=192.168.1.9:192.168.1.4:192.168.1.4:255.255.255.0:DB88FXX81:eth0:none # saveenv ####### change vm security settings # Due to changes in vm security a change must be made in /etc/sysctl.d/10-process-security.conf. # vm.mmap_min_addr should be set to 32768 (This change is safe for any kernel version). # If this is not done it is likely that you will not be able to login remotely. # Although you should still be able to login as root on the main console. set -e set -u ProgName="$0" KVer='' ERROR=0 WGET='/usr/bin/wget' CURL='/usr/bin/curl' DEPMOD='/sbin/depmod' for f in $WGET $CURL $DEPMOD; do if [[ ! -x $f ]]; then echo "missing $f" ERROR=1 fi done if (( ERROR )); then exit 1 fi function Md5Compare () { if [[ $(cat $2 | cut -d' ' -f1) \ != $(md5sum $1 | cut -d' ' -f1) ]]; then echo "Bad md5 detected on $1" exit 1 fi } function GetDownloadPath() { local site=$1 local v1=$(echo $KVer | cut -d'.' -f1) local v2=$(echo $KVer | cut -d'.' -f2) local v3=$(echo $KVer | cut -d'.' -f3) local v4=$(echo $KVer | cut -d'.' -f4) local path="$v1/$v1.$v2" if (( $v1 == 2 )); then if [[ -z $v3 ]]; then path="$path/$v1.$v2" else path="$path/$v1.$v2.$v3" if [[ -z $v4 ]]; then path="$path/$v1.$v2.$v3" else path="$path/$v1.$v2.$v3.$v4" fi fi else if [[ -z $v3 ]]; then path="$path/$v1.$v2" else path="$path/$v1.$v2.$v3" fi fi for (( i = 5; i >= 1; i-- )); do testpath=$site/$path/release/$i if $CURL -sf $testpath; then path=$path/release/$i break fi done echo $path } function Download() { echo "Downloading files" local site1="http://www.xilka.com/kernel" local path=$(GetDownloadPath $site1) local f='' p='' for f in Modules.tar.gz Modules.tar.gz.md5 uImage uImage.md5 System.map; do p='sheeva' [[ $f != uImage* ]] || p='dream' if [[ ! -f $p-$KVer-$f ]]; then local s='' for s in $site1; do if $WGET -c $s/$path/$p-$KVer-$f && [[ -f $p-$KVer-$f ]]; then break fi done if [[ ! -f $p-$KVer-$f ]]; then echo "Unable to retrieve $p-$KVer-$f" exit 1 fi fi done Md5Compare sheeva-$KVer-Modules.tar.gz sheeva-$KVer-Modules.tar.gz.md5 Md5Compare dream-$KVer-uImage dream-$KVer-uImage.md5 } function ExtractModules() { local v1=$(echo $KVer | cut -d'.' -f1) local v2=$(echo $KVer | cut -d'.' -f2) local v3=$(echo $KVer | cut -d'.' -f3) local depmodVer=$KVer [[ ! -z $v3 ]] || depmodVer="$v1.$v2.0" local extractDir='/' [[ ! -L '/lib' ]] || extractDir=$(dirname $(readlink '/lib')) [[ -d $extractDir ]] || extractDir="/$extractDir" echo "Extracting modules" tar x -C $extractDir --overwrite -zf sheeva-$KVer-Modules.tar.gz [[ -d /boot ]] || mkdir /boot cp sheeva-$KVer-System.map /boot/ $DEPMOD -eF /boot/sheeva-$KVer-System.map $depmodVer } function RootKernel() { echo "Writing kernel to /boot" [[ -d /boot ]] || mkdir /boot cp dream-$KVer-uImage /boot/ echo "****************************************************************" echo " update your bootcmd to load dream-$KVer-uImage" echo " or create a link from /boot/dream-$KVer-uImage to /boot/uImage" echo "****************************************************************" } function Usage() { echo "Use $ProgName VERSION to write kernel to /boot" echo echo " where VERSION is something like 3.4.6" } if (( $# < 1 )); then Usage exit 1 fi KVer="$1" Download ExtractModules RootKernel