ยง2023-10-28
This document is only intended to support ODROID SBC from Hardkernel, supported boards are limited as listed below.
ODROID-N2
ODROID-N2Plus
ODROID-C4
ODROID-HC4
Package requirements
In order to build Linux kernel, you need to install developement packages required.
$ sudo apt install git build-essential bc flex bison libssl-dev libncurses-dev
Download the Source code
$ git clone --depth 1 https://github.com/tobetter/linux \
-b `uname -r | awk -F'.' '{print "odroid-" $1 "." $2 ".y"}'`
$ cd linux
$ git branch
Compile your custom kernel
Unline the generic desktop, your Ubuntu/Debian uses a package flash-kernel that helps to install the Linux kernel packages and the device tree file for a target device. You have to tweak a couple of things once in order to let the package flash-kernel install your custom kernel properly.
Compile
:warning: Use these commands once before preceeding.
$ cp /boot/config-$(uname -r) .config
$ sed -i "s/.*CONFIG_LOCALVERSION_AUTO.*/CONFIG_LOCALVERSION_AUTO=y/g" .config
$ echo "-odroid-arm64" > .scmversion
Then, start to compile the Linux kernel source.
$ make oldconfig
$ make -j8
Install
:warning: Use these commands once before preceeding.
$ sudo sed -i "s/^force=.*$/force=\"yes\"/g" /usr/share/flash-kernel/functions
$ sudo ln -s $PWD/arch/arm64/boot/dts /usr/lib/linux-image-$(cat include/config/kernel.release)
Then, you can install the Linux kernel image and its drivers. The boot script, the device tree file and initramfs will be updated while installing by the flash-kernel. Please note that your Linux kernel version must ends with -odroid-arm64, so ensure the last log with make modules_install.
$ sudo make modules_install
$ sudo make install
- mv
alexlai@n2JamGen:~/build$ sudo arch-chroot /mnt/gentoo/ /bin/bash
n2JamGen / # source /etc/profile
(chroot) n2JamGen / # cd /usr/src/
(chroot) n2JamGen /usr/src # ls
linux linux-odroid-5.15.y linux-odroidg12-4.9.y
(chroot) n2JamGen /usr/src # eselect kernel list
Available kernel symlink targets:
[1] linux-odroidg12-4.9.y
[2] linux-odroid-5.15.y *
(chroot) n2JamGen /usr/src # ls -l
total 8
lrwxrwxrwx 1 root root 19 Oct 28 19:17 linux -> linux-odroid-5.15.y
drwxrwxr-x 27 1026 1026 4096 Oct 28 20:22 linux-odroid-5.15.y
drwxr-xr-x 26 root root 4096 Oct 28 17:22 linux-odroidg12-4.9.y
- genkernel
(chroot) n2JamGen /usr/src # emerge sys-kernel/genkernel
----
- [odroid-N2 Kernel](https://wiki.odroid.com/odroid-n2/software/building_kernel)
1) git clone
(chroot) n2JamGen / # emerge dev-vcs/git (chroot) n2JamGen / # cd /usr/src (chroot) n2JamGen /usr/src # git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidg12-4.9.y (chroot) n2JamGen /usr/src # mv linux/ linux-odroidg12-4.9.y (chroot) n2JamGen /usr/src # eselect kernel list Available kernel symlink targets: [1] linux-odroidg12-4.9.y (chroot) n2JamGen /usr/src # eselect kernel set 1 (chroot) n2JamGen /usr/src # ls -l total 4 lrwxrwxrwx 1 root root 21 Oct 28 17:16 linux -> linux-odroidg12-4.9.y drwxr-xr-x 25 root root 4096 Oct 28 17:14 linux-odroidg12-4.9.y (chroot) n2JamGen /usr/src/linux-odroidg12-4.9.y # make odroidg12_defconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf
configuration written to .config
(chroot) n2JamGen /usr/src/linux-odroidg12-4.9.y # time make -j 6 <-- has to sepecify, it did not take from make.conf ---> failed to compile