Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if [ $# != 2 ]
- then
- #echo
- #echo IMPORTANT!! IF THIS IS YOUR FIRST TIME COMPILING A KERNEL, DO NOT USE THIS SCRIPT.
- #echo look around, search and try doing it yourself!
- #echo
- echo Usage:
- echo -e \\\tmake_kernel \<compiler prefix\> \< url of tar archive of the linux kernel \>
- else
- which $1gcc &> /dev/null
- if [ $? != 0 ]
- then
- echo incorrect compiler prefix
- else
- echo $(tput setaf 6)Script for version 4.4.X$(tput sgr 0)
- echo -n $(tput setaf 6)downloading kernel$(tput sgr 0)\ \
- wget $2 -q -O /tmp/kern.tar.xz
- if [ $? != 0 ]
- then
- echo $(tput setaf 6)failed $(tput sgr 0)
- echo Incorrect link
- else
- NAME=`tar -tf /tmp/kern.tar.xz | head -n 1`
- echo
- echo -n $(tput setaf 6)extracting kernel\ \ $(tput sgr 0)
- cont=1
- if [ -d $NAME ]
- then
- echo -n $(tput setaf 6)Dir exists.Delete directory ? \(y\/n\)+enter\ $(tput sgr 0)
- read ans
- if [ "$ans" == "y" ]
- then
- rm -r $NAME
- if [ $? != 0 ]
- then
- echo $(tput setaf 6)failed$(tput sgr 0)
- cont=0
- fi
- else
- cont=0
- fi
- fi
- if [ $cont == 1 ]
- then
- tar xf /tmp/kern.tar.xz
- if [ $? != 0 ]
- then
- echo -n $(tput setaf 6)fail$(tput sgr 0)
- else
- echo
- #rm /tmp/kern.tar.xz
- echo -n $(tput setaf 6)getting patches from openwrt github repo\ \ $(tput sgr 0)
- CONT=1
- if [ -d openwrt-pxa-target ]
- then
- echo -n $(tput setaf 6)Repo exists.Delete directory ? \(y\/n\)+enter\ $(tput sgr 0)
- read ans
- if [ "$ans" == "y" ]
- then
- rm -r openwrt-pxa-target
- if [ $? != 0 ]
- then
- echo $(tput setaf 6)failed$(tput sgr 0)
- cont=0
- fi
- else
- cont=0
- fi
- fi
- if [ $CONT == 1 ]
- then
- git clone https://github.com/openwrt-zipit/openwrt-pxa-target &> /dev/null
- if [ $? != 0 ]
- then
- echo $(tput setaf 6)fail$(tput sgr 0)
- else
- echo
- echo $(tput setaf 6)Patching the kernel$(tput sgr 0)
- cd $NAME
- OK=1
- for f in ../openwrt-pxa-target/pxa/patches-4.4/*
- do
- if [ $OK == 1 ]
- then
- patch -p1 < "${f}"
- fi
- if [ $? != 0 ]
- then
- OK=0
- fi
- done
- if [ $OK == 1 ]
- then
- echo $(tput setaf 6)getting config for 4.4 from mozzwald\'s website$(tput sgr 0)
- curl https://mozzwald.com/zipit/kernel/config.4.4 > .config
- if [ $? != 0 ]
- then
- echo $(tput setaf 6)fail$(tput sgr 0)
- else
- echo $(tput setaf 6)compiling the kernel$(tput sgr 0)
- mkdir ../kernel
- cont=1
- if [ $? != 0 ]
- then
- if [ -d ../kenrel ]
- then
- echo -n $(tput setaf 6)Folder ../kernel exists\(Used for output\).Delete directory ? \(y\/n\)+enter\ $(tput sgr 0)
- read ans
- if [ "$ans" == "y" ]
- then
- rm -r ../kernel
- if [ $? != 0 ]
- then
- echo $(tput setaf 6)failed$(tput sgr 0)
- cont=0
- fi
- else
- cont=0
- fi
- else
- echo $(tput setaf 6)error$(tput sgr 0)
- cont=0
- fi
- fi
- if [ $cont == 1 ]
- then
- echo $(tput setaf 6)run make menuconfig before building kernel? \(y\/n\)$(tput sgr 0)
- read ans
- while [ $ans == "y" ]
- do
- make ARCH=arm CROSS_COMPILE=$1 INSTALL_MOD_PATH=../kernel/ menuconfig
- if [ $? != 0 ]
- then
- echo -n $(tput setaf 6)Something went wrong. Try again? \(y\/n\)$(tput sgr 0)
- read ans
- else
- ans="ok, we can move on"
- fi
- done
- make ARCH=arm CROSS_COMPILE=$1 INSTALL_MOD_PATH=../kernel/ zImage modules dtbs modules_install
- if [ $? != 0 ]
- then
- echo $(tput setaf 6)Error compiling kernel$(tput sgr 0)
- else
- cat arch/arm/boot/zImage arch/arm/boot/dts/zipit-z2.dtb >zImage-dtb
- mkimage -A Arm -O linux \
- -C none \
- -T kernel \
- -a 0xA0008000 -e 0xA0008000 \
- -n uImage -d zImage-dtb uImage
- mkdir ../kernel/boot
- cp uImage ../kernel/boot
- cd ..
- fi
- fi
- fi
- fi
- fi
- fi
- fi
- fi
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement