参考Rockchip Wiki

1. 准备交叉编译链

gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar


2. 编译源码

git clone https://github.com/rockchip-linux/kernel.git


3. 编译

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rockchip_linux_defconfig

$ PATH=../gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin:$PATH LD_LIBRARY_PATH=../gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/lib make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4

$ PATH=../gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin:$PATH LD_LIBRARY_PATH=../gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/lib make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rk3399-evb-ind-lpddr4-linux.img


4. 错误处理

/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status

交叉编译工具版本高造成的,可以降低版本也可以如下解决。

diff --git a/Makefile b/Makefile
index 9ca1a4e00239..a53f7f1edcc9 100644
--- a/Makefile
+++ b/Makefile
@@ -323,6 +323,8 @@ HOSTCXX      = g++
 HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
 HOSTCXXFLAGS = -O2
 
+HOSTCFLAGS += -fcommon
+
 # Decide whether to build built-in, modular, or both.
 # Normally, just do built-in.