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

Difference between revisions of "Rock5/guide/build-kernel-on-5b"

< Rock5‎ | guide
Line 14: Line 14:
 
=== Install essential pacakges ===
 
=== Install essential pacakges ===
  
  sudo apt-get update
+
  $ 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
+
  $ 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 ===
 
=== Get the source code ===
Line 21: Line 21:
 
Clone the source code
 
Clone the source code
  
  mkdir ~/rk3588-sdk && cd ~/rk3588-sdk
+
  $ mkdir ~/rk3588-sdk && cd ~/rk3588-sdk
  git clone -b linux-5.10-gen-rkr3.4 https://github.com/radxa/kernel.git
+
  $ 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 master https://github.com/radxa/rkbin.git
  git clone -b debian https://github.com/radxa/build.git
+
  $ git clone -b debian https://github.com/radxa/build.git
  
 
And you will get  
 
And you will get  
  
  build  kernel  rkbin
+
  build  kernel  rkbin
 +
 
 
Directories usage introductions:
 
Directories usage introductions:
  
Line 34: Line 35:
 
** Some script files and configuration files for building u-boot, kernel and rootfs.
 
** Some script files and configuration files for building u-boot, kernel and rootfs.
 
* kernel:  
 
* kernel:  
** kernel source code.
+
** Kernel source code.
 
* rkbin:  
 
* rkbin:  
 
** Prebuilt Rockchip binaries, include first stage loader and ATF(Arm Trustzone Firmware).
 
** Prebuilt Rockchip binaries, include first stage loader and ATF(Arm Trustzone Firmware).
Line 40: Line 41:
 
=== Build kernel ===
 
=== Build kernel ===
  
Need to checkout branch to '''linux-5.10-gen-rkr3.4'''.
+
By default, the kernel branch is '''linux-5.10-gen-rkr3.4'''.
  
 
Build kernel with default '''rockchip_linux_defconfig'''.
 
Build kernel with default '''rockchip_linux_defconfig'''.
  
  cd ~/rk3588-sdk
+
  $ cd ~/rk3588-sdk
  ./build/mk-kernel.sh rk3588-rock-5b    #For ROCK 5B
+
  $ ./build/mk-kernel.sh rk3588-rock-5b    # For ROCK 5B
  
 
==== Change kernel config ====
 
==== Change kernel config ====
Line 51: Line 52:
 
Optionally, if you want to change the default kernel config
 
Optionally, if you want to change the default kernel config
  
  cd ~/rk3588-sdk
+
  $ cd ~/rk3588-sdk
  cd kernel
+
  $ cd kernel
  make rockchip_linux_defconfig
+
  $ make rockchip_linux_defconfig
  make menuconfig
+
  $ make menuconfig
  make savedefconfig
+
  $ make savedefconfig
  cp defconfig arch/arm64/configs/rockchip_linux_defconfig
+
  $ cp defconfig arch/arm64/configs/rockchip_linux_defconfig
  
==== build kernel ====
+
==== Build kernel with new defconfig ====
  
  cd ~/rk3588-sdk
+
  $ cd ~/rk3588-sdk
  ./build/mk-kernel.sh rk3588-rock-5b    #For ROCK 5B
+
  $ ./build/mk-kernel.sh rk3588-rock-5b    # For ROCK 5B
  
 
You will get the kernel image and dtb file
 
You will get the kernel image and dtb file
  
  ls out/kernel/
+
  $ ls out/kernel/
 
  Image  rk3588-rock-5b.dtb
 
  Image  rk3588-rock-5b.dtb
  
Line 72: Line 73:
 
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.  
 
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
+
  $ ./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.
 
The generated packages will be copied to out/packages directory.
  
  ls out/packages/
+
  $ ls out/packages/
  linux-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-rockchip_arm64.changes
+
  linux-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.changes
  linux-image-5.10.66-10-rockchip-ge5013df5e066-dbg_5.10.66-10-rockchip_arm64.deb
+
  linux-headers-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.deb
  linux-headers-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-rockchip_arm64.deb
+
  linux-image-5.10.110-99-rockchip-g9fd61a9a9912-dbg_5.10.110-99-rockchip_arm64.deb
  linux-libc-dev_5.10.66-10-rockchip_arm64.deb
+
  linux-image-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.deb
  linux-image-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-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.
 
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
+
  $ 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
  
After a while, you will find that some files are generated in the /boot directory.then you may modify the default boot kernel.
+
And you will find that some files are generated in the /boot directory.
$ 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
+
Check configuration file <code>/boot/extlinux/extlinux.conf</code>.
  $ uname -r
+
 
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
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 ===
 
=== FAQs ===
  
 +
1.When build kernel packages, there is one error "internal compiler error: Segmentation fault", like this:
 +
 +
<pre>
 +
  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
 +
</pre>
 +
 +
We can just ignore it. Please add the following patch in repository build. And build kernel again via command <code>./build/pack-kernel.sh -d rockchip_linux_defconfig -r 99</code>
 +
 +
<pre>
 +
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
 +
</pre>
  
 
=== Troubleshooting ===
 
=== Troubleshooting ===
  
 
Check [[rock5/FAQs |ROCK 5 FAQs]] first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/rock5.
 
Check [[rock5/FAQs |ROCK 5 FAQs]] first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/rock5.

Revision as of 10:56, 29 January 2023

    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 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.