Difference between revisions of "Rock5/guide/build-kernel-on-5b"
(→Get the source code) |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
== 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. | Below is the instructions of how to build kernel for ROCK 5 on rock5 board. | ||
Line 11: | Line 10: | ||
Available boards: | Available boards: | ||
+ | * ROCK 5A | ||
* ROCK 5B | * 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 | Clone the source code | ||
− | mkdir ~/rk3588-sdk && cd ~/rk3588-sdk | + | $ mkdir ~/rk3588-sdk && cd ~/rk3588-sdk |
− | git clone -b | + | $ 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 37: | Line 36: | ||
** 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. |
* 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). | ||
− | === | + | === Build kernel === |
− | + | 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 ==== | |
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 |
− | cd | + | |
− | ./build/mk-kernel.sh rk3588-rock-5b #For ROCK 5B | + | ==== 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 | 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 | ||
− | ==== Build kernel | + | ==== 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. | 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 | + | $ ./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. | + | linux-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.changes |
− | linux- | + | linux-headers-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.deb |
− | linux- | + | linux-image-5.10.110-99-rockchip-g9fd61a9a9912-dbg_5.10.110-99-rockchip_arm64.deb |
− | linux- | + | linux-image-5.10.110-99-rockchip-g9fd61a9a9912_5.10.110-99-rockchip_arm64.deb |
− | linux- | + | 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. | ||
− | + | $ 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 <code>/boot/extlinux/extlinux.conf</code>. | ||
+ | |||
+ | <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 === | ||
− | + | 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 === | |
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. |
Latest revision as of 10:56, 29 January 2023
ROCK 5 > Guide > Build Kernel on ROCK 5B
Contents
Build Kernel on ROCK 5B
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.