Skip to content

Instantly share code, notes, and snippets.

@neagix
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neagix/8ae313e5325d562acf32 to your computer and use it in GitHub Desktop.
Save neagix/8ae313e5325d562acf32 to your computer and use it in GitHub Desktop.
Script used to compile kernels for U2
#!/bin/bash
## generate kernel image & modules + u-boot script
## @author neagix
#
set -e
if [ ! $# -eq 1 ]; then
echo "Please specify kernel directory" 1>&2
exit 1
fi
## enter such kernel directory
cd $1
## careful: do not set PFIX to empty string!
PFIX=generated
mkdir -p $PFIX
## remove old generated stuff
rm -rfv $PFIX/*
function make_boot() {
local RAM="2047M" # should be mem=1023M for ODROID-X
(
echo "setenv initrd_high \"0xffffffff\""
echo "setenv fdt_high \"0xffffffff\""
echo "setenv bootcmd \"fatload mmc 0:1 0x40008000 zImage; bootm 0x40008000\""
echo "setenv bootargs \"console=tty1 console=ttySAC1,115200n8 root=/dev/mmcblk0p2 rootwait ro mem=$RAM\""
echo "boot"
) > $PFIX/boot.txt || return 1
sudo mkimage -A arm -T script -C none -n "ODROID-WHEEZY" -d $PFIX/boot.txt $PFIX/boot.scr
}
## start compiling kernel
make -j5 zImage
## after kernel compilation, copy .config
cp -v .config $PFIX/config-`cat include/config/kernel.release`
## copy result of compilation
cp -v arch/arm/boot/zImage $PFIX/zImage-`cat include/config/kernel.release`
## generate modules
make modules -j5
sudo make modules_install
make_boot
sudo cp -v $PFIX/boot.txt $PFIX/boot.scr /boot/
## all backup copies
sudo cp -vi /boot/zImage /boot/zImage-`uname -r`
sudo cp -vi .config /boot/config-`uname -r`
#
# now replace kernel
#
sudo cp -v $PFIX/zImage /boot/zImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment