We're no longer updating This wiki!!

Kernel

This page introduce how you can download and compile the Linux kernel for ODROID-C2.

Cross Compile - HOST-PC/Ubuntu

Installing required packages

You will need install required packages before you start to build Linux kernel on your Ubuntu desktop.

$ sudo apt-get update
$ sudo apt-get install git lzop build-essential gcc libncurses5-dev libc6-i386 lib32stdc++6 zlib1g:i386

Toolchain (4.9.2)

Click one of the site to download toolchain to build Linux kernel.

Once the download is done, extract the tarball to /opt/toolchains/.

$ sudo mkdir -p /opt/toolchains
$ sudo tar Jxvf gcc-linaro-aarch64-linux-gnu-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=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
export PATH=/opt/toolchains/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/:$PATH

You can apply the change if you login again or import to apply this change, login again or evaluate $HOME/.bashrc with source command.

$ source ~/.bashrc

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.

$ aarch64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/opt/toolchains/aarch64-linux-4.9/bin/../libexec/gcc/aarch64-linux-gnu/4.9.2/lto-wrapper
Target: aarch64-linux-gnu
Configured with: /cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/.build/src/gcc-linaro-4.9-2014.09/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=aarch64-linux-gnu --prefix=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/install --with-sysroot=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/install/aarch64-linux-gnu/libc --enable-languages=c,c++,fortran --disable-multilib --enable-multiarch --with-arch=armv8-a --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 --disable-libmudflap --enable-libgomp --disable-libssp --with-gmp=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/.build/aarch64-linux-gnu/build/static --with-mpfr=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/.build/aarch64-linux-gnu/build/static --with-mpc=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/.build/aarch64-linux-gnu/build/static --with-isl=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/.build/aarch64-linux-gnu/build/static --with-cloog=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/.build/aarch64-linux-gnu/build/static --with-libelf=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/.build/aarch64-linux-gnu/build/static --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-plugin --with-local-prefix=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-linux-gnu-linux/install/aarch64-linux-gnu/libc --enable-c99 --enable-long-long
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 Linux kernel source tree from Hardkernel's Github, please note that we distribute the Linux kernel in different branches for Android and other Linux distributions.

Android

Lollipop
$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y-android
$ cd linux
Marshamollow
$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y-android
$ cd linux

Linux

$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y
$ cd linux

Compile

Note

  • If you want to download & build only Android Linux kernel source code without another Android BSP, you face the error message as below:
    • drivers/amlogic/wifi/Kconfig:26: can't open file “../hardware/wifi/realtek/drivers/8192cu/rtl8xxx_CU/Kconfig”
  • Please delete the last line as below in 'drivers/amlogic/wifi/Kconfig' file if you will build only Android Linux kernel.
    • source “../hardware/wifi/realtek/drivers/8192cu/rtl8xxx_CU/Kconfig”

You must do kernel configuration for ODROID-C2, then start to build. Adding -j option on make command will help you to finish compiling faster.

$ make odroidc2_defconfig
$ make <-j4> Image dtbs modules

You have done to compile the Linux kernel (Image), the device tree file (.dtb) and kernel modules (.ko).

Custom Kernel Build

If you have some kernel drivers wish to include for your custom build, you can select the drivers easily in Linux kernel tree. make menuconfig will show you text based menus help you to select kernel drivers.

$ make menuconfig

Once you done selecting the drivers, exit from the menu screen. Then you can start kernel build with make again.

$ make <-j4> Image modules

When you exit from kernel menu screen, you will have .config in the current directory what have changes for your custom build. You can back up this as a file, my_kernel.config for example, or can make a patch if you manage your own git.

$ cp .config arch/arm64/configs/odroidc2_defconfig
$ git add arch/arm64/configs/odroidc2_defconfig
$ git commit -s -m "Change the kernel config file for ODROID-C2"
$ git push

Installation

There are different instructions to install Linux kernel image and device tree for Android and Linux. Since Android loads both from a boot partition, we have to use fastboot to install into the dedicated partition. Please refer the partition table from here. In contrast, Linux boots by the instructions described in boot.ini the 1st FAT partition.

Android

This is the instruction to install kernel image, Image, to the boot card.

$ fastboot flash boot <path/of/your/Image>

This is to install a device tree file, meson64_odroidc2.dtb.

$ fastboot flash dtb <path/of/your/meson64_odroidc2.dtb>

Linux

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 Image and DT(meson64_odroidc2.dtb) to the FAT partition(1st partition) in the Boot-Device.

$ mkdir -p mount
$ sudo mount /dev/sdc1 ./mount
$ sudo cp arch/arm64/boot/Image arch/arm64/boot/dts/meson64_odroidc2.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=arm64 INSTALL_MOD_PATH=./mount && sync && sudo umount ./mount
$ rm -rf mount

Native Compile - ODROID-C2/Ubuntu

Note

  • 8GB eMMC/SD card have not enough space to build kernel source. In order to do native compile, the 5GB of storage space is required at least.

Installing required packages

You will need install required packages before you start to build Linux kernel on your Ubuntu ODROID-C2.

odroid@odroid64:~$ sudo apt-get update
odroid@odroid64:~$ sudo apt-get install git

Toolchain (4.9.2)

The kernel for ODROID-C2 does not support gcc 5.x version yet. So, you must change to the gcc 4.9 version in order to build ODROID-C2 kernel.

odroid@odroid64:~$ sudo apt-get install gcc-4.9
odroid@odroid64:~$ sudo rm /usr/bin/gcc
odroid@odroid64:~$ sudo ln -s /usr/bin/gcc-4.9 /usr/bin/gcc
odroid@odroid64:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/4.9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.9.3-12ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.9/u
Thread model: posix
gcc version 4.9.3 (Ubuntu/Linaro 4.9.3-12ubuntu1) 

Checkout

odroid@odroid64:~$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y
odroid@odroid64:~$ cd linux

Compile & Installation

odroid@odroid64:~/linux$ make odroidc2_defconfig
odroid@odroid64:~/linux$ make -j4
odroid@odroid64:~/linux$ sudo make modules_install
odroid@odroid64:~/linux$ sudo cp -f arch/arm64/boot/Image arch/arm64/boot/dts/meson64_odroidc2.dtb /media/boot/
odroid@odroid64:~/linux$ sudo sync
odroid@odroid64:~/linux$ sudo reboot
en/c2_building_kernel.txt · Last modified: 2017/02/06 18:25 by codewalker
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0