Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:c2_building_kernel [2016/02/11 17:49] brian.kim [Android] |
en:c2_building_kernel [2017/02/06 18:25] (current) codewalker [Checkout] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Installing required packages ====== | + | ====== 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. | You will need install required packages before you start to build Linux kernel on your Ubuntu desktop. | ||
<code> | <code> | ||
$ sudo apt-get update | $ sudo apt-get update | ||
- | $ sudo apt-get install git lzop build-essential gcc libncurses5-dev | + | $ sudo apt-get install git lzop build-essential gcc libncurses5-dev libc6-i386 lib32stdc++6 zlib1g:i386 |
</code> | </code> | ||
- | ====== Kernel ====== | + | |
- | This page introduce how you can download and compile the Linux kernel for **ODROID-C2**. | + | ==== Toolchain (4.9.2) ==== |
- | ===== Toolchain (4.9.2)===== | + | |
Click one of the site to download toolchain to build Linux kernel. | Click one of the site to download toolchain to build Linux kernel. | ||
- | * [[https://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.9-2014.09_linux.tar.xz|Download #1]] | + | * [[http://releases.linaro.org/archive/14.09/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz|Download #1]] |
+ | * [[http://dn.odroid.com/toolchains/gcc-linaro-aarch64-none-elf-4.9-2014.09_linux.tar.xz|Download #2]] | ||
Once the download is done, extract the tarball to **/opt/toolchains/**. | Once the download is done, extract the tarball to **/opt/toolchains/**. | ||
<code> | <code> | ||
$ sudo mkdir -p /opt/toolchains | $ sudo mkdir -p /opt/toolchains | ||
- | $ sudo tar xvf gcc-linaro-aarch64-none-elf-4.9-2014.09_linux.tar.xz -C /opt/toolchains/ | + | $ sudo tar Jxvf gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux.tar.xz -C /opt/toolchains/ |
</code> | </code> | ||
In order to add the toolchain path to PATH, paste below lines to **$HOME/.bashrc**. | In order to add the toolchain path to PATH, paste below lines to **$HOME/.bashrc**. | ||
<code> | <code> | ||
export ARCH=arm64 | export ARCH=arm64 | ||
- | export CROSS_COMPILE=aarch64-none-elf- | + | export CROSS_COMPILE=aarch64-linux-gnu- |
- | export PATH=/opt/toolchains/gcc-linaro-aarch64-none-elf-4.9-2014.09_linux/bin/:$PATH | + | export PATH=/opt/toolchains/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin/:$PATH |
</code> | </code> | ||
You can apply the change if you login again or import | You can apply the change if you login again or import | ||
Line 28: | Line 31: | ||
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. | 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. | ||
<code> | <code> | ||
- | $ aarch64-none-elf-gcc -v | + | $ aarch64-linux-gnu-gcc -v |
Using built-in specs. | Using built-in specs. | ||
- | COLLECT_GCC=aarch64-none-elf-gcc | + | COLLECT_GCC=aarch64-linux-gnu-gcc |
- | COLLECT_LTO_WRAPPER=/opt/toolchains/gcc-linaro-aarch64-none-elf-4.9-2014.09_linux/bin/../libexec/gcc/aarch64-none-elf/4.9.2/lto-wrapper | + | COLLECT_LTO_WRAPPER=/opt/toolchains/aarch64-linux-4.9/bin/../libexec/gcc/aarch64-linux-gnu/4.9.2/lto-wrapper |
- | Target: aarch64-none-elf | + | Target: aarch64-linux-gnu |
- | Configured with: /cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/src/gcc-linaro-4.9-2014.09/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=aarch64-none-elf --prefix=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/install --with-local-prefix=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/install/aarch64-none-elf --without-headers --with-newlib --enable-threads=no --disable-shared --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 --with-arch=armv8-a --disable-__cxa_atexit --with-gmp=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-mpfr=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-mpc=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-isl=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-cloog=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-libelf=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --enable-lto --enable-linker-build-id --disable-libmudflap --disable-libgomp --disable-libssp --disable-libstdcxx-pch --enable-multiarch --disable-multilib --enable-languages=c,c++,fortran | + | 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: single | + | 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) | gcc version 4.9.2 20140904 (prerelease) (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) | ||
</code> | </code> | ||
- | ===== Checkout ===== | + | |
+ | ==== Checkout ==== | ||
You can checkout Linux kernel source tree from **[[https://github.com/hardkernel/linux/tree/odroidc2-3.14.y-android|Hardkernel's Github]]**, please note that we distribute the Linux kernel in different branches for Android and other Linux distributions. | You can checkout Linux kernel source tree from **[[https://github.com/hardkernel/linux/tree/odroidc2-3.14.y-android|Hardkernel's Github]]**, please note that we distribute the Linux kernel in different branches for Android and other Linux distributions. | ||
- | ==== Android ==== | + | |
+ | === Android === | ||
+ | == Lollipop == | ||
<code> | <code> | ||
$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y-android | $ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y-android | ||
$ cd linux | $ cd linux | ||
</code> | </code> | ||
+ | == Marshamollow == | ||
+ | <code> | ||
+ | $ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y-android | ||
+ | $ cd linux | ||
+ | </code> | ||
+ | |||
- | ==== Linux ==== | + | === Linux === |
<code> | <code> | ||
$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y | $ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y | ||
$ cd linux | $ cd linux | ||
</code> | </code> | ||
- | ===== Compile ===== | + | ==== Compile ==== |
<WRAP center round important 100%> | <WRAP center round important 100%> | ||
Line 60: | Line 72: | ||
</WRAP> | </WRAP> | ||
- | |||
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. | 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. | ||
Line 68: | Line 79: | ||
</code> | </code> | ||
You have done to compile the Linux kernel (Image), the device tree file (.dtb) and kernel modules (.ko). | You have done to compile the Linux kernel (Image), the device tree file (.dtb) and kernel modules (.ko). | ||
- | ===== Custom Kernel Build ===== | + | |
+ | ==== 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. | 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. | ||
<code> | <code> | ||
Line 84: | Line 96: | ||
$ git push | $ git push | ||
</code> | </code> | ||
- | ===== Installation ===== | + | |
+ | ==== 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 [[http://odroid.com/dokuwiki/doku.php?id=en:c2_partition_table|here]]. In contrast, Linux boots by the instructions described in **boot.ini** the 1st FAT partition. | 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 [[http://odroid.com/dokuwiki/doku.php?id=en:c2_partition_table|here]]. In contrast, Linux boots by the instructions described in **boot.ini** the 1st FAT partition. | ||
- | ==== Android ==== | + | |
+ | === Android === | ||
This is the instruction to install kernel image, **Image**, to the boot card. | This is the instruction to install kernel image, **Image**, to the boot card. | ||
<code> | <code> | ||
Line 96: | Line 110: | ||
</code> | </code> | ||
- | ==== Linux (Cross build) ==== | + | === Linux === |
<WRAP center round important 100%> | <WRAP center round important 100%> | ||
** This explanation assume that your USB memory CARD reader is assigned at /dev/sdc. Be careful!** | ** This explanation assume that your USB memory CARD reader is assigned at /dev/sdc. Be careful!** | ||
Line 117: | Line 130: | ||
$ rm -rf mount | $ rm -rf mount | ||
</code> | </code> | ||
+ | |||
+ | ===== Native Compile - ODROID-C2/Ubuntu ===== | ||
+ | <WRAP center round important 100%> | ||
+ | **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. | ||
+ | </WRAP> | ||
+ | ==== Installing required packages ==== | ||
+ | You will need install required packages before you start to build Linux kernel on your Ubuntu ODROID-C2. | ||
+ | <code> | ||
+ | odroid@odroid64:~$ sudo apt-get update | ||
+ | odroid@odroid64:~$ sudo apt-get install git | ||
+ | </code> | ||
+ | |||
+ | ==== 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. | ||
+ | <code> | ||
+ | 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) | ||
+ | </code> | ||
+ | |||
+ | ==== Checkout ==== | ||
+ | <code> | ||
+ | odroid@odroid64:~$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y | ||
+ | odroid@odroid64:~$ cd linux | ||
+ | </code> | ||
+ | |||
+ | ==== Compile & Installation ==== | ||
+ | <code> | ||
+ | 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 | ||
+ | </code> |