#! /bin/bash # # Sheeva 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 # setenv arcNumber 2097 ####### 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 KVer='2.6.34' function Md5Compare () { if [[ $(cat $2 | cut -d' ' -f1) \ != $(md5sum $1 | cut -d' ' -f1) ]]; then echo "Bad md5 detected on $1" exit 1 fi } function Download() { echo "Downloading files" local f='' for f in Modules.tar.gz Modules.tar.gz.md5 uImage uImage.md5 System.map; do if [[ ! -f sheeva-$KVer-$f ]]; then if [[ -z "$(which wget)" ]]; then echo "Use apt-get to install wget, then rerun this script" exit 1 fi local sites="http://www.plugapps.com/with-linux http://sheeva.with-linux.com/sheeva" local s='' for s in $sites; do if wget -c $s/$KVer/sheeva-$KVer-$f; then break fi done if [[ ! -f sheeva-$KVer-$f ]]; then echo "Unable to retrieve sheeva-$KVer-$f" exit 1 fi fi done Md5Compare sheeva-$KVer-Modules.tar.gz sheeva-$KVer-Modules.tar.gz.md5 Md5Compare sheeva-$KVer-uImage sheeva-$KVer-uImage.md5 } function CheckSize() { local uImageFile=sheeva-$KVer-uImage local mtd=$(grep uImage /proc/mtd | cut -d' ' -f1 | sed 's#:##') local mtdHexSize=$(grep uImage /proc/mtd | cut -d' ' -f2) local mtdSize='' let mtdSize=0x$mtdHexSize local uImageSize=$(stat -c%s "$uImageFile") if (( uImageSize > mtdSize )); then echo "uImage size $uImageSize exceeds $mtd size $mtdSize" echo "You must resize your mtds before this kernel will fit!" echo "The simplest way to do this is with the SheevaPlug installer" exit 1 fi } function ExtractModules() { echo "Extracting modules" tar x -C / --overwrite -zf sheeva-$KVer-Modules.tar.gz [[ -d /boot ]] || mkdir /boot cp sheeva-$KVer-System.map /boot/ depmod -eF /boot/sheeva-$KVer-System.map $KVer } function NandKernel() { echo "Flashing kernel to NAND" # MTDDEVICE should be either /dev/mtd0 or /dev/mtd1 # depending on which partition contains the kernel uImage local Mtd=$(grep uImage /proc/mtd | cut -d' ' -f1 | sed 's#:##') flash_eraseall -j /dev/$Mtd nandwrite -pm /dev/$Mtd sheeva-$KVer-uImage } function RootKernel() { echo "Writing kernel to /boot" [[ -d /boot ]] || mkdir /boot cp sheeva-$KVer-uImage /boot/ echo "****************************************************************" echo " update your bootcmd to load sheeva-$KVer-uImage" echo " or create a link from /boot/sheeva-$KVer-uImage to /boot/uImage" echo "****************************************************************" } function Usage() { echo "Use --nandkernel to write kernel to NAND" echo "Or --rootkernel to write kernel to /boot" } if [[ $# < 1 ]]; then Usage exit 1 fi if [[ "$1" == "--nandkernel" ]]; then Download CheckSize ExtractModules NandKernel elif [[ "$1" == "--rootkernel" ]]; then Download ExtractModules RootKernel else Usage exit 1 fi