Q. How to obtain kernel header for Debian OS for Tinker Board

A:

We recommend using the kernel header of an OS that has been confirmed to work with API-TOOL(LNX).

However, the Debian OS kernel header for Tinker Board is not open to the public.
For this reason, you need to build the kernel in a suitable environment and create the kernel header.

Target

Environment

Single board computer (SBC)

Tinker Board 2S

OS

Debian 11 V3.0.11 (Kernel 5.10.160 (aarch64))

Kernel source (from GitHub)

rockchip-linux-kernel-linux5.10-rk3399-debian11.zip

The steps and commands may vary depending on the Debian OS version.
Therefore, an example procedure for creating kernel header in the above environment is provided below.

In addition, the example procedure below downloads each file via the Internet.
Before following the steps below, please prepare an environment that allows you to connect to the Internet using Debian OS on the target Tinker Board 2S.

① Downloading kernel source

The kernel source of Debian OS for Tinker Board is stored on the software development platform GitHub.
Download the kernel source of [TinkerBoard-Linux/rockchip-linux-kernel] from GitHub.


1. In a web browser, browse to [TinkerBoard-Linux/rockchip-linux-kernel] on GitHub.

[TinkerBoard-Linux/rockchip-linux-kernel on GitHub]
  https://github.com/TinkerBoard-Linux/rockchip-linux-kernel


2. From the [TinkerBoard-Linux/rockchip-linux-kernel] screen, select [Code] and a pull-down menu will appear.
    You can download the kernel file by selecting [Download ZIP] from the pull-down menu.

    For Debian 11 Ver.3.0.11, the download file name is [rockchip-linux-kernel-linux5.10-rk3399-debian11.zip].

    Please note that due to GitHub revisions, the displayed screen may differ from the screenshot.

 

②Copying and unpacking kernel source

1. Run the following command to copy the downloaded kernel source to the current directory.

    If you have already downloaded the kernel source to the directory where you want to build it, you do not need to run this command.
    Please proceed to the next step.

    The [xxx/] part specifies the directory where you downloaded the kernel source.

# cp xxx/rockchip-linux-kernel-linux5.10-rk3399-debian11.zip ./

2. Run the following command to extract the kernel source.

# unzip rockchip-linux-kernel-linux5.10-rk3399-debian11.zip

3. Run the following command to move to the directory where you extracted the kernel source.

# cd rockchip-linux-kernel-linux5.10-rk3399-debian11

 

③Creating kernel configuration file

Kernel configuration file (.config) is not included in the unzipped kernel sources.
Please create a new kernel configuration file (.config) suitable for the system you are building in the directory where you extracted the kernel source.

Note that if the running Debian is Debian 11 V3.0.11 (Kernel 5.10.160 (aarch64)), it is the same version as the downloaded kernel source.
We will show you how to copy the configuration file (.config) of a running kernel to the current directory and change the file description as necessary.

Typically, the configuration file for a running kernel is stored in /proc/config.gz.
In this case, execute the following command to copy the running kernel configuration file to the current directory where the kernel source was extracted.

# zcat /proc/config.gz > .config

(Reference 1) To check the version of Debian you are running, run the following command.

# cat /etc/issue

(Reference 2) To check the kernel version of Debian you are running, run the following command.

# uname --all

 

④Updating package list

To correct known defects, we recommend updating the package list before building the kernel.

If the package list is already in the correct state, there is no need to run this command.
Please proceed to the next step.

Debian OS administrator (root) privileges are required to update the package list.
If you do not have root privileges, please log in again with root privileges.

 To update the package list, run the following command:

# apt update

 

⑤Installing tools

Run the following command to install the tools required for kernel build.

If each tool is already installed, there is no need to run this command.
Please proceed to the next step.

Debian OS administrator (root) privileges are required to install each tool.
If you do not have root privileges, please log in again with root privileges.

      # apt install git-core gitk git-gui gcc-arm-linux-gnueabihf device-tree-compiler gcc-aarch64-linux-gnu mtools parted
      # apt install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison zstd rsync

 

⑥Building the kernel and kernel modules

Debian OS administrator (root) privileges are required to build the kernel and kernel modules.
If you do not have root privileges, please log in again with root privileges.

1. To check the current directory, run the following command.
  If the current directory is not the directory where you extracted the kernel source, move to the appropriate directory.

      # pwd

2. To build the downloaded kernel source based on the kernel configuration file (.config), run the following command.
  The kernel build will take some time, please do not stop the process until the build is complete.

      # make deb-pkg -j8

(Reference 1) While building the kernel, you will be prompted to select the items required for the build.
    We recommend that you enter "n" for all.

(Reference 2) The following error may occur during compilation.

      dpkg-source: error: cannot represent change to logo.bmp: binary file contents changed
      dpkg-source: error: cannot represent change to logo_kernel.bmp: binary file contents changed

      To avoid this error, run the command below and build again.

  # rm logo.bmp logo_kernel.bmp

 

⑦Checking generation of kernel headers

1. When the kernel build completes successfully, the kernel header (linux-headers-5.10.160_5.10.160-1_arm64.deb) will be generated in the parent directory.
  To move from the current directory to the parent directory, run the following command:

      # cd ..

2. To verify that the kernel headers are present, run the command below:

      # ls linux-headers-5.10.160_5.10.160-1_arm64.deb

 

⑧Installing kernel headers

1. To register the generated kernel header with Debian's package management system, run the following command:

# sudo dpkg -i ../linux-headers-5.10.160_5.10.160-1_arm64.deb

2. To install the generated kernel headers, run the following command:

# sudo apt-get install linux-headers-$(uname -r)

 

⑨How to check the kernel header version of [dep file] again

1. Unpack the dep file.

2. There is a kernel version folder inside the lib/module directory of the unpacked files.