Embedded & MCUHow ToIoT OS & RTOSMicrocontrollersRaspberry PiTutorials/DIY

Build Kernel on ROCK 5B

Radxa Single Board Computer

Radxa SBCs are full computers with a microprocessor, memory, input/output (I/O), and other components built on a single circuit board. Radxa SBCs are small and potent devices that can be used for a variety of DIY projects, smart home control, and game machines. Radxa SBCs are completely open, and it is up to you how to use them. Radxa SBCs are the ideal all-in-one solution for any application requiring a full computer, offering the flexibility to modify software and connect a variety of peripherals.

Radxa ROCK 5 SBC

Radxa’s ROCK5 is the single board computer’s (SBC) of fifth generation. Linux, Android, BSD, and other operating systems can all run on it.

Rockchip RK3588(s) SoC powers the ROCK5 and features an Oct core ARM processor (4x Cortex-A76 + 4x Cortex-A55), up to 32GB 64bit LPDDR4X ram, up to 8K@60 HDMI, MIPI DSI, MIPI CSI, 3.5mm jack with mic, USB Port, GbE LAN, PCIe 3.0 x4, PCIe 2.0, 40-pin colour expansion header, RTC. Furthermore, ROCK5 supports USB PD power in display alternative mode.

ROCK 5 Model B

ROCK5 is a series of Rockchip RK3588(s) based SBC(Single Board Computer) by Radxa. It can run Linux, Android, BSD and other distributions.

ROCK5 comes in two models, Model A and Model B. Both models offer 4GB, 8GB and 16GB options. For detailed difference between Model A and Model B.

ROCK5 features a Octa core ARM processor(4x Cortex-A76 + 4x Cortex-A55), 64bit 3200Mb/s LPDDR4, up to 8K@60 HDMI, MIPI DSI, MIPI CSI, 3.5mm jack with mic, USB Port, 2.5 GbE LAN, PCIe 3.0, PCIe 2.0, 40-pin color expansion header, RTC. Also, ROCK5 supports USB PD and QC powering.

 

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

Available boards:

  • ROCK 5A
  • 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 make

Get the source code

Clone the source code

$ mkdir ~/rk3588-sdk && cd ~/rk3588-sdk
$ git clone -b linux-5.10-gen-rkr3.4 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

By default, the kernel branch is linux-5.10-gen-rkr3.4.

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 with new defconfig

$ 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 99 # [-d rockchip_linux_defconfig: kernel defconfig] [99: release number]

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

$ ls out/packages/
linux-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.changes
linux-headers-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.deb
linux-image-5.10.110-99-rockchip-g9fd61a9a9912-dbg_5.10.110-99-rockchip_arm64.deb
linux-image-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.deb
linux-libc-dev_5.10.110-99-rockchip_arm64.deb

Install kernel packages

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

$ sudo dpkg -i out/packages/linux-headers-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.deb
$ sudo dpkg -i out/packages/linux-image-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.deb

And you will find that some files are generated in the /boot directory.

Check configuration file /boot/extlinux/extlinux.conf.

timeout 10
menu title select kernel

# Set default kernel version
default kernel-5.10.110-99-rockchip-g9fd61a9a9912

label kernel-5.10.110-99-rockchip-g9fd61a9a9912
    kernel /vmlinuz-5.10.110-99-rockchip-g9fd61a9a9912
    initrd /initrd.img-5.10.110-99-rockchip-g9fd61a9a9912
    devicetreedir /dtbs/5.10.110-99-rockchip-g9fd61a9a9912
    append   root=UUID=a6820e76-421d-4275-bdae-0ad612df361b earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 loglevel=7 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 irqchip.gicv3_pseudo_nmi=0 switolb=1 coherent_pool=2M

label kernel-5.10.110-34-rockchip-gca15bbe36e6c
    kernel /vmlinuz-5.10.110-34-rockchip-gca15bbe36e6c
    initrd /initrd.img-5.10.110-34-rockchip-gca15bbe36e6c
    devicetreedir /dtbs/5.10.110-34-rockchip-gca15bbe36e6c
    append   root=UUID=a6820e76-421d-4275-bdae-0ad612df361b earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 loglevel=7 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 irqchip.gicv3_pseudo_nmi=0 switolb=1 coherent_pool=2M

Reboot the device and check the running kernel version.

$ uname -a
Linux rock-5b 5.10.110-99-rockchip-g9fd61a9a9912 #rockchip SMP Sun Jan 29 17:51:26 UTC 2023 aarch64 GNU/Linux

FAQs

1.When build kernel packages, there is one error “internal compiler error: Segmentation fault”, like this:

  CC [M]  drivers/net/wireless/rockchip_wlan/rtl8852bu/phl/test/verify/phl_test_verify.o
during GIMPLE pass: local-fnsummary
drivers/net/wireless/rockchip_wlan/rtl8852be/phl/test/mp/phl_test_mp_reg.c: In function 'phl_mp_reg_read_macreg':
drivers/net/wireless/rockchip_wlan/rtl8852be/phl/test/mp/phl_test_mp_reg.c:320:1: internal compiler error: Segmentation fault
  320 | }
      | ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.
make[9]: *** [scripts/Makefile.build:274: drivers/net/wireless/rockchip_wlan/rtl8852be/phl/test/mp/phl_test_mp_reg.o] Error 1
make[9]: *** Waiting for unfinished jobs....
  CC [M]  drivers/net/wireless/rockchip_wlan/rtl8852bu/phl/test/verify/dbcc/phl_test_dbcc.o

We can just ignore it. Please add the following patch in repository build. And build kernel again via command ./build/pack-kernel.sh -d rockchip_linux_defconfig -r 99

diff --git a/pack-kernel.sh b/pack-kernel.sh
index 5aa2e89ca..2ec116808 100755
--- a/pack-kernel.sh
+++ b/pack-kernel.sh
@@ -34,7 +34,7 @@ if [ "X$(uname -m)" == "Xaarch64" ]; then
 fi
 
 echo -e "\e[31m Start to pack kernel. \e[0m"
-cd ${KERNEL_DIR} && make distclean && make -f $ROCKCHIP_BSP_DIR/build/kernel-package.mk kernel-package
+cd ${KERNEL_DIR} && make -f $ROCKCHIP_BSP_DIR/build/kernel-package.mk kernel-package
 
 mv $ROCKCHIP_BSP_DIR/linux-*${RELEASE_NUMBER}-rockchip*.deb $PACKAGES_DIR
 mv $ROCKCHIP_BSP_DIR/linux-*${RELEASE_NUMBER}-rockchip*.changes $PACKAGES_DIR

Troubleshooting

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

You may also like : How to turn a Raspberry pi into a Router 

You may also like : 60/40 Vs 63/37 Solder – What are their Similarities and Differences

You may also like : Types of Transformers and Their Applications

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. Tech enthusiast and IT professional with a B.Tech in IT, PG Diploma in IoT from CDAC, and 6 years of industry experience. Founder of HVM Smart Solutions, blending technology for real-world solutions. As a passionate technical author, I simplify complex concepts for diverse audiences. Let's connect and explore the tech world together! If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning! Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *