====== Linux (v4.2 - experimental) ======
This page introduce how you can download and compile the Linux kernel for **ODROID-XU4**, especially for mainline kernel. You need to use the **gcc version 4.9** to build the Linux Kernel.
===== Toolchain (4.9.2)=====
Click one of the site to download toolchain to build Linux kernel.
* [[http://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz|Download #1]]
* [[http://dn.odroid.com/toolchains/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz|Download #2]]
Once the download is done, extract the tarball to **/opt/toolchains/**.
$ sudo mkdir -p /opt/toolchains
$ sudo tar xvf gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz -C /opt/toolchains/
In order to add the toolchain path to PATH, paste below lines to **$HOME/.bashrc**.
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=/opt/toolchains/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/:$PATH
You can check if the toolchain installed above works properly while checking the version of toolchain. If you can find **gcc version 4.9.2 20140904 (prerelease)** at the end of the line, the toolchain is well installed.
$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/toolchains/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/opt/toolchains/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/../libexec/gcc/arm-linux-gnueabihf/4.9.2/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/gcc-linaro-4.9-2014.09/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install --with-sysroot=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran --disable-multilib --enable-multiarch --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=hard --with-pkgversion='crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-mpfr=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-mpc=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-isl=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-cloog=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-libelf=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-plugin --enable-gold --with-local-prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/arm-linux-gnueabihf/libc --enable-c99 --enable-long-long --with-mode=thumb --disable-multilib --with-float=hard
Thread model: posix
gcc version 4.9.2 20140904 (prerelease) (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09)
===== Checkout =====
You can checkout **Kernel** source tree from **[[https://github.com/tobetter/linux/commits/odroidxu4-v4.2|tobetter's Github]]**.
Please note that we distribute the Linux kernel in different branches for Android and other Linux distributions.
$ git clone --depth 1 https://github.com/tobetter/linux -b odroidxu4-v4.2
$ cd linux
===== Compile =====
Before compiling, you must configure for **ODROID-XU4** with following command.
$ make odroidxu4_defconfig
$ make
Then you can start to build Linux kernel image, **zImage**. This will create **arch/arm/boot/zImage**. You can also add **-j** option for fast compile.
===== Installation =====
** This explanation assume that your USB memory CARD reader is assigned at /dev/sdc. Be careful!**
1. Plug the Boot-Device(eMMC or SD) into the USB memory CARD reader and Connect the USB memory CARD reader to your HOST PC(Linux OS).
2. Copy the zImage and DT(exynos5422-odroidxu4.dtb) to the FAT partition(1st partition) in the Boot-Device.
$ mkdir -p mount
$ sudo mount /dev/sdc1 mount/
$ sudo cp arch/arm/boot/zImage mount/
$ sudo cp arch/arm/boot/dts/exynos5422-odroidxu4.dtb mount/
$ sync
$ sudo umount mount/
3. Copy the driver modules to the EXT4 partition(2nd partition) in the Boot-Device.
$ sudo mount /dev/sdc2 mount/
$ sudo make modules_install ARCH=arm INSTALL_MOD_PATH=mount/
$ sync
$ sudo umount mount/