RockPI 4A Linux内核*载下**与编译

本文介绍RockPI 4A单板Debian系统Linux内核的*载下**和编译方法,为后续介绍RockPI 4A单板Linux内核调试进行抛砖引玉。

一、代码*载下**

Rockpi 4A Debian版本SDK代码*载下**方法:

git clone --recursive https://github.com/radxa/rockchip-bsp.git
cd rockchip-bsp/

代码*载下**完成后,显示如下:

root@ubuntu:/home/run/code/rockchip-bsp# ls
build  docker  kernel  out  README.md  rkbin  rootfs  u-boot

kernel 目录下保存Linux内核代码。

build 目录下保存配置和编译脚本。

如果RockPI 4A代码*载下**失败,提示如下:

root@ubuntu:/home/run/code# git clone --recursive https://github.com/radxa/rockchip-bsp.git
Cloning into 'rockchip-bsp'...
fatal: unable to access 'https://github.com/radxa/rockchip-bsp.git/': gnutls_handshake() failed: Error in the pull function.

解决方法:将*载下**链接中 https 替换成 git

root@ubuntu:/home/run/code# git clone --recursive git://github.com/radxa/rockchip-bsp.git  
Cloning into 'rockchip-bsp'...
remote: Enumerating objects: 114, done.
remote: Counting objects: 100% (114/114), done.
remote: Compressing objects: 100% (81/81), done.
Receiving objects:  35% (165/471), 28.01 KiB | 3.00 KiB/s  

二、内核编译

使用代码里的编译脚本,编译脚本名称: mk-kernel.sh ,位置如下:

root@ubuntu:/home/run/code/rockchip-bsp# ls build/
board_configs.sh  extlinux       kernel-package.mk  mk-kernel.sh  out          pack-kernel.sh  partitions.sh  rockpis-partitions.sh
debian            flash_tool.sh  mk-image.sh        mk-uboot.sh   pack_deb.sh  pack-uboot.sh   README.md      uboot-package.mk

注:在脚本 mk-kernel.sh 中有一段代码: source $LOCALPATH/build/board_configs.sh $BOARD ,使用脚本编译时,必须在 build 文件夹同一级目录。

RockPI 4A Linux内核编译方法如下(使用...省略部分编译输出):

root@ubuntu:/home/run/code/rockchip-bsp# ./build/mk-kernel.sh rockpi4a
 Building kernel for rockpi4a board!
4.4.154
  CHK     include/config/kernel.release
 ...
 Generate Boot image start
mkfs.fat 4.1 (2017-01-24)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
 Generate Boot image : /home/run/code/rockchip-bsp/out/boot.img success!
 Kernel build success!

其中: rockpi4a 对应RockPI 4A单板,如果使用其它单板,需要设置不同内容。单板类型可参考 build/board_configs.sh 脚本中 case ${BOARD} in 的选项。例:

case ${BOARD} in
        "tb-rk3399prod")
                DEFCONFIG=rockchip_linux_defconfig
                UBOOT_DEFCONFIG=rk3399pro_defconfig
                DTB=rk3399pro-toybrick-prod-linux.dtb
                export ARCH=arm64
                export CROSS_COMPILE=aarch64-linux-gnu-
                CHIP="rk3399pro"
                ;;
        "ficus2-rk3399pro")
                DEFCONFIG=rockchip_linux_defconfig
                UBOOT_DEFCONFIG=rk3399pro-ficus2_defconfig
                DTB=rk3399pro-ficus2-linux.dtb
                export ARCH=arm64
                export CROSS_COMPILE=aarch64-linux-gnu-
                CHIP="rk3399pro"
                ;;
        "rockpin10")

编译出来的映像路径:

root@ubuntu:/home/run/code/rockchip-bsp/out# tree
.
├── boot.img
└── kernel
    ├── Image
    └── rk3399-rock-pi-4a.dtb

1 directory, 3 files