Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Rock5/guide/build-kernel-on-5b

< Rock5‎ | guide
Revision as of 06:10, 4 January 2023 by Stephen (Talk | contribs)

    ROCK 5 >  Guide >  Build Kernel on ROCK 5B

Build Kernel on ROCK 5B

Below is the instructions of how to build kernel for ROCK 5 on rock5 board.

Available boards:

  • ROCK 5B

Install essential pacakges

sudo apt-get update
sudo apt-get install -y git  device-tree-compiler libncurses5 libncurses5-dev build-essential libssl-dev mtools bc python dosfstools bison flex rsync u-boot-tools

Get the source code

Clone the source code

mkdir ~/rk3588-sdk && cd ~/rk3588-sdk
git clone -b stable-5.10-rock5 https://github.com/radxa/kernel.git
git clone -b master https://github.com/radxa/rkbin.git
git clone -b debian https://github.com/radxa/build.git

And you will get

build  kernel  rkbin  

Directories usage introductions:

  • build:
    • Some script files and configuration files for building u-boot, kernel and rootfs.
  • kernel:
    • kernel source code.
  • rkbin:
    • Prebuilt Rockchip binaries, include first stage loader and ATF(Arm Trustzone Firmware).

Build kernel

Need to checkout branch to stable-5.10-rock5.

Build kernel with default rockchip_linux_defconfig.

cd ~/rk3588-sdk
./build/mk-kernel.sh rk3588-rock-5b    #For ROCK 5B

Change kernel config

Optionally, if you want to change the default kernel config

cd ~/rk3588-sdk
cd kernel
make rockchip_linux_defconfig
make menuconfig
make savedefconfig
cp defconfig arch/arm64/configs/rockchip_linux_defconfig

build kernel

cd ~/rk3588-sdk
./build/mk-kernel.sh rk3588-rock-5b    #For ROCK 5B

You will get the kernel image and dtb file

ls out/kernel/
Image  rk3588-rock-5b.dtb

Build kernel package

The kernel package build can pack the kernel, device tree, modules and firmware into Debian packages, which makes it easier to install on the ROCK 5.

./build/pack-kernel.sh -d rockchip_linux_defconfig -r 10 # rockchip_linux_defconfig: kernel defconfig; 1: release number

The generated packages will be copied to out/packages directory.

ls out/packages/
linux-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-rockchip_arm64.changes
linux-image-5.10.66-10-rockchip-ge5013df5e066-dbg_5.10.66-10-rockchip_arm64.deb
linux-headers-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-rockchip_arm64.deb
linux-libc-dev_5.10.66-10-rockchip_arm64.deb
linux-image-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-rockchip_arm64.deb

When you want to install specified kernel packages to your OS, try the following steps.

# dpkg -i linux-image-5.10.66-10-rockchip-ge5013df5e066-dbg_5.10.66-10-rockchip_arm64.deb

After a while, you will find that some files are generated in the /boot directory.then you may modify the default boot kernel.

$ vim /boot/extlinux/extlinux.conf
...
default l0
menu title U-Boot menu
prompt 0
timeout 10
...

change to:

...
default l1
menu title U-Boot menu
prompt 0
timeout 10
...

Now,you can reboot your board.After entering the system, enter the following command to check whether the version is the same as the version you built

$ uname -r

FAQs

1.There is one new kernel branch, https://github.com/radxa/kernel/tree/linux-5.10-gen-rkr3.4. How to download and build it?

cd ~/rk3588-sdk/kernel
make distclean
git remote add -t linux-5.10-gen-rkr3.4 github-radxa https://github.com/radxa/kernel.git
git fetch github-radxa
git checkout -b linux-5.10-gen-rkr3.4 remotes/github-radxa/linux-5.10-gen-rkr3.4

Now we switch the branch to linux-5.10-gen-rkr3.4. Then build kernel with rockchip_linux_defconfig.

Troubleshooting

Check ROCK 5 FAQs first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/rock5.