Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save TinkerTeam/6286550ce70d34f6b3d483cd803da786 to your computer and use it in GitHub Desktop.
Save TinkerTeam/6286550ce70d34f6b3d483cd803da786 to your computer and use it in GitHub Desktop.
How to Compile Debian Kernel for Tinker Board

How to Compile Kernel for Tinker Board

- Build environment

Installing the build tools

sudo apt-get install git-core gitk git-gui gcc-arm-linux-gnueabihf device-tree-compiler gcc-aarch64-linux-gnu mtools parted libssl-dev

- Build Kernel

1. Compile the kernel

make ARCH=arm miniarm-rk3288_defconfig -j16
make zImage ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16
make modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16
make ARCH=arm rk3288-miniarm.dtb CROSS_COMPILE=arm-linux-gnueabihf- -j16

Note: As of 2018-01-05, if may be necessary to edit the Makefile to add -Wno-misleading-indentation to the CFLAGS_MODULE if you are using GCC 6 and up. Ref: https://github.com/TinkerBoard/debian_kernel/commit/9be94537ea733f70f42bdaa55aff68d0d1b06d70

2. Install WIFI module to root file system

  1. Insert sd card to linux pc and then mount partition2 (root file system) Example:
sudo mkdir –p /media/users/sdx2
sudo mount /dev/sdx2 /media/users/sdx2
  1. Open terminal to kernel folder and enter the following com mands
sudo make ARCH=arm INSTALL_MOD_PATH=/media/users/sdx2 modules_install
sudo umount /media/users/sdx2

3. Replace the kernel image

  1. Insert sd card to linux pc and then mount partition1 (root file system) Example:
sudo mkdir –p /media/users/sdx1
sudo mount /dev/sdx1 /media/users/sdx1
  1. Open terminal to kernel folder and copy zImage and rk3288- miniarm.dtb to partition1(boot partition)
cp arch/arm/boot/zImage /media/users/sdx1
cp arch/arm/boot/dts/rk3288-miniarm.dtb /media/users/sdx1
sudo umount /media/users/sdx1
@dvergeylen
Copy link

Typo: CROSS_COMPILE should be arm-linux-gnueabihf- instead of arm-linux-gnueabi- 😉

@dvergeylen
Copy link

Just to clarify a bit: the three last instructions are actually:

cp arch/arm/boot/zImage /media/users/sdx1
cp arch/arm/boot/dts/rk3288-miniarm.dtb /media/users/sdx1
sudo umount /media/users/sdx1

(zImage and rk3288-miniarm.dtb aren't at the kernel root folder)

@TinkerTeam
Copy link
Author

TinkerTeam commented Oct 1, 2018

Hi @dvergeylen
Thank you!! The typo has been fixed.

@IngvarOlsson
Copy link

To me, being new to tinkerboard, it is not clear on where and how I get the source code. Perhaps that could be added before step 1?

@jd1378
Copy link

jd1378 commented Dec 15, 2020

I assume I have to get source from https://github.com/TinkerBoard/debian_kernel,
But it seems I can't simply compile the source, I get a lot of errors.
I downloaded the latest tag from the repo and done the instructions exactly, but the zImage is not generated
@TinkerTeam please can you update the gist if it needs any update ?

Edit: For those who may be looking here later, this comment helped me compile the kernel

@dvergeylen
Copy link

dvergeylen commented Dec 16, 2020

Edit: For those who may be looking here later, this comment helped me compile the kernel

Glad I could help a bit! 😇
I also get a lot of errors when compiling TinkerBoard Debian kernel.
The TinkerBoard (and TinkerBoard S) is actually supported mainline in the kernel (see here and here) so you don't have to compile the one provided by Asus, getting one from kernel.org will make it! 😎

# Clone from kernel.org, Github's torvalds/linux only mirrors the
# master branch, not the LTS ones (see https://github.com/torvalds/linux/branches).
git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
cd linux
git branch --list --remotes
git branch --show-current
git checkout linux-5.4.y # 5.4 is LTS until Dec, 2025 (see: https://www.kernel.org/category/releases.html)
                         # 5.10 should be the next LTS release, but isn't listed in the above list yet at this time of writing

# Fetch Tinkerboard kernel config
curl -L https://raw.githubusercontent.com/TinkerBoard/debian_kernel/develop/arch/arm/configs/miniarm-rk3288_defconfig -o arch/arm/configs/miniarm-rk3288_defconfig

# Configure the kernel with the downloaded configuration
# (you shouldn't get errors except a warning about duplicated lines)
make ARCH=arm miniarm-rk3288_defconfig -j8
make ARCH=arm menuconfig # Optional, to add more configuration yourself

# Compile kernel and its modules
make zImage ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8
make modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8

# Tinker's dts is in mainline kernel, under the name rk3288-tinker.dts
# (see: arm/boot/dts/rk3288-tinker.dts)
# so compile it as well to a dtb file (binary)
make ARCH=arm rk3288-tinker.dtb CROSS_COMPILE=arm-linux-gnueabihf- -j8

# Install modules to the SDCard's '/' partition
sudo make ARCH=arm INSTALL_MOD_PATH=/media/sdX/ modules_install

# Copy freshly compiled kernel to the SDcard's '/boot' partition
cp arch/arm/boot/zImage /media/sdY/zImage
cp arch/arm/boot/dts/rk3288-tinker.dtb /media/sdY/rk3288-miniarm.dtb

Edit: I will update my comment to reflect the instructions above.

@jd1378
Copy link

jd1378 commented Dec 16, 2020

Even with your previous comment I was able to do it successfully with combination of this gist, but you saved me days, because otherwise I would be still trying to compile the mentioned repo instead of kernel.org one, thanks a lot! 👍
Also thanks for taking time to update your comment ! nice to have all in one place (it only misses the required build-tools I guess)

@6a5h4
Copy link

6a5h4 commented Apr 27, 2021

I need a working kernel for Tinkerboard S with TinkerOSv2.1.16 and driver included or as module for BONDING. I decided to compile my own.
I did everything you've written here and compiled some compressed kernels (4.4.267, 4.9 and 5.4.114 with BONDING) but no one can boot. Everyone failed because the eMMC isn't detected i think, so it failed with error "VFS: Unable to mount on unknown-block(0,0)". The original kernel 4.4.132+ mounts the eMMC (mmcblk1-known as number 179) and its partitions as "/boot" (mmcblk1p1-179,1) and root "/" (mmcblk1p2-179,2).
Which driver i need to activate/integrate or which setting is missing?


Update 30.04.2021 : Solution found last evening!! this is howto recompile the kernel with new settings

(in the kernel setup configuration select only what you really need!! - otherwise the compilation will abort due some errors!) :

# into ~ (home directory) i created the directory "kernel" and jumped into it...
mkdir kernel
cd kernel

# Downloading the sources of Tinker-OS v2.1.16...
wget https://github.com/TinkerBoard/debian_kernel/archive/refs/tags/tinker_board-debian-2.1.16.tar.gz

# unpack the package... and jump into...
tar -xaf ~/kernel/tinker_board-debian-2.1.16.tar.gz
cd debian_kernel-tinker_board-debian-2.1.16 tb-os-2116

# create default .config and then start modifying the new kernel (edits the .config). Selecting network options and bonding driver support.
# then save the .config file. (i had to unselect the wlan 2Tx00 driver packages for successfull compiling the new kernel with bonding driver)
make ARCH=arm miniarm-rk3288_defconfig -j4
make ARCH=arm menuconfig

# compiles the new (compressed zImage) kernel (on tinkerboard S eMMC it takes about 30 minutes!!), the modules and installs the modules. 
# then rename the original kernel and copy the fresh-compiled kernel to the  /boot directory (mmcblk1p1). 
# CAUTION! If the booting fails because the compiled kernel is not working fine, you need to connect the tinkerboard to another 
# computer and mount the mmcblk1p1 (/boot) partition (on windows this is the only one automounted partition) and rename 
# zImage_original to zImage (overwriting the not-working kernel) and then reboot and recompile again.
make zImage ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
make modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
sudo make ARCH=arm INSTALL_MOD_PATH=/ modules_install
mv /boot/zImage /boot/zImage_original
cp /arch/arm/boot/zImage /boot/zImage

# reboots the machine and you see the new kernel booting and entering rootfs on the emmc (kernel 4.4.132 from TinkerOS v2.1.16).
sudo reboot now

# on success the output show you now the new ethernet interface bond0. 
ip link show bond0

now i can make my bonding configuration...

@giseleznev
Copy link

Hi, is there any instructions for tinker board 2 kernel compiling? analog of rk3288-tinker.dts, rk3399-tinker.dts is missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment