Step-by-step Cross-compiling a Kernel

From odroid US
Revision as of 20:11, 2 February 2013 by Osterluk (Talk | contribs) (Created page with "THIS IS IN PROGRESS: PLEASE DO NOT EDIT wget https://launchpadlibrarian.net/129963014/gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux.tar.xz xz -d gcc-linaro-arm-...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

THIS IS IN PROGRESS: PLEASE DO NOT EDIT


wget https://launchpadlibrarian.net/129963014/gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux.tar.xz xz -d gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux.tar.xz tar -xvf gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux.tar

sudo mkdir -p /usr/local/arm >/dev/null ln -s gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux /usr/local/arm/toolchain

Setup the c-compiler cache

cd /usr/local/arm/toolchain
mkdir bin-ccache
ln -s $(which ccache) arm-linux-gnueabihf-gcc
ln -s $(which ccache) arm-linux-gnueabihf-g++
ln -s $(which ccache) arm-linux-gnueabihf-cpp
ln -s $(which ccache) arm-linux-gnueabihf-c++

export PATH=/usr/local/arm/toolchain/bin-ccache:/usr/local/arm/toolchain/bin:$PATH


Get the kernel snapshot, and unzip it

wget --no-check-certificate https://github.com/hardkernel/linux/archive/odroid-3.0.y.zip
unzip odroid-3.0.y.zip


Move into the kernel source directory and set up

cd linux-odroid-3.0.y/
export CROSS_COMPILE=arm-linux-gnueabihf-
export ARCH=arm

Select the configuration you want, and build it

make odroidu2_ubuntu_defconfig 
make -j8 zImage

Make a directory for the kernel modules and let the kernel make system strip and copy them out.

mkdir ../rfs
export INSTALL_MOD_PATH=$PWD/../rfs
make modules_install
cd ../rfs
# remove symlinks that point to files we do not need in root file system
find . -name source | xargs rm
find . -name build | xargs rm
# Compress
sudo tar -cvzf ../modules.tgz .
cd ../

Copy our new kernel and modules to the target. This method copies over the network. The thing to remember is that the kernel goes on the boot partition and the kernel modules go on the rootfs partition

scp modules.tgz root@odroidu2:/
scp linux-odroid-3.0.y/arch/arm/boot/zImage  root@odroidu2:/boot

Now go to the odroid Linux console and expand the kernel modules and reboot

tar -xvzf modules.tgz 
rm modules.tgz
sync
reboot

Check the kernel version, with uname -a

Linux odroidu2-1 3.0.61 #1 SMP Sat Feb 2 15:28:35 PST 2013 armv7l GNU/Linux