当先锋百科网

首页 1 2 3 4 5 6 7

硬件信息: friefly3399一块,2GB内存/16Gemmc。

 

软件信息: ubuntu18.04虚拟机,内部有firefly的SDK包。

参考资料:[ROC-RK3399-PC Pro] 手把手教你移植主线U-Boot(基于v2022.04-rc5版本)_Neutionwei的博客-CSDN博客

目标移植uboot2022.10到firefly3399开发板

 

 

一、下载uboot源码

1.1  git 下载,需要安装git工具!!

git clone [email protected]:u-boot/u-boot.git

1.2 出现问题:

zhi@ubuntu:~/3399/system/2022-11-27$ git clone [email protected]:u-boot/u-boot.git
Cloning into 'u-boot'...
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

1.3 解决问题,主要是github账号授权的问题。解决的步骤(参考百度):

1.ssh-keygen -t rsa -C [email protected]  (注意修改,是自己的github账号的邮箱地址)

2.ssh -v [email protected]

3.ssh-agent -s

4.ssh-add ~/.ssh/id_rsa  (出错(Could not open a connection to your authentication agent.)继续第5步,没错则跳过5,6)

5.eval `ssh-agent -s`

6.ssh-add ~/.ssh/id_rsa

7.cat ~/.ssh/id_rsa.pub  打印出来的数据,贴到github中的账号中去。

8.打开自己的github的账号,在settings下,SSH and GPG keys下new SSH key,title随便取一个名字,然后将id_rsa.pub里的内容复制到Key中,完成后Add SSH Key。

9. 验证:ssh -T [email protected]  提示successfully 即表示成功

1.4 继续下载

git clone [email protected]:u-boot/u-boot.git

1.5 查看版本信息

cd uboot/

git tag   使用空格打印出更多

1.6 切换分支,我这里选项2022.10.rc5

git checkout -b v2022.10-rc5 v2022.10-rc5

二、源码编译

2.1 需要准备交叉编译环境。

我自己的环境有一个编译器,是firefly中自带的。

1.查找一下,发现有该编译器

zhi@ubuntu:~/3399/system/rk3399_linux_release_v2.5.1_20210301$ find -name aarch64-linux-gnu* 

2.没有的话,可以自行下载

git clone https://gitlab.com/firefly-linux/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu

3.设置环境变量PATH,根据自己的目录更改吧

export PATH=/home/zhi/3399/system/rk3399_linux_release_v2.5.1_20210301/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin:$PATH

4. 查看命令是否正常

 aarch64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/home/zhi/3399/system/rk3399_linux_release_v2.5.1_20210301/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/6.3.1/lto-wrapper
Target: aarch64-linux-gnu
Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/snapshots/gcc.git~linaro-6.3-2017.05/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu
Thread model: posix
gcc version 6.3.1 20170404 (Linaro GCC 6.3-2017.05) 

2.2 查看配置信息,选择firefly-rk3399_defconfig

cd configs

ls | grep 3399

evb-rk3399_defconfig
ficus-rk3399_defconfig
firefly-rk3399_defconfig
khadas-edge-captain-rk3399_defconfig
khadas-edge-rk3399_defconfig
khadas-edge-v-rk3399_defconfig
leez-rk3399_defconfig
nanopc-t4-rk3399_defconfig
nanopi-m4-2gb-rk3399_defconfig
nanopi-m4b-rk3399_defconfig
nanopi-m4-rk3399_defconfig
nanopi-neo4-rk3399_defconfig
nanopi-r4s-rk3399_defconfig
orangepi-rk3399_defconfig
pinebook-pro-rk3399_defconfig
puma-rk3399_defconfig
rock960-rk3399_defconfig
rock-pi-4c-rk3399_defconfig
rock-pi-4-rk3399_defconfig
rock-pi-n10-rk3399pro_defconfig
rockpro64-rk3399_defconfig
roc-pc-mezzanine-rk3399_defconfig
roc-pc-rk3399_defconfig

2.3 使用该配置文件

cd ../

make firefly-rk3399_defconfig

2.4 开始编译

make CROSS_COMPILE=aarch64-linux-gnu-

2.5 出错1.

unable to execute 'swig': No such file or directory
error: command 'swig' failed with exit status 1

2.6 解决错误1

sudo apt install swig

2.7 错误2

scripts/dtc/pylibfdt/libfdt_wrap.c:149:11: fatal error: Python.h: No such file or directory
 # include <Python.h>
           ^~~~~~~~~~

2.8 解决错误2

sudo apt-get install python3-distutils -y

sudo apt install python3-dev -y

2.9 继续编译,编译完成

make CROSS_COMPILE=aarch64-linux-gnu-

./"arch/arm/mach-rockchip/make_fit_atf.py" \
arch/arm/dts/rk3399-firefly.dtb > u-boot.its
WARNING: BL31 file bl31.elf NOT found, resulting binary is non-functional
WARNING: Please read Building section in doc/README.rockchip
  MKIMAGE u-boot.itb
===================== WARNING ======================
This board uses CONFIG_SPL_FIT_GENERATOR. Please migrate
to binman instead, to avoid the proliferation of
arch-specific scripts with no tests.
====================================================
  CFGCHK  u-boot.cfg
  OFCHK   .config
  BINMAN  all

2.10  继续下载bl31.elf

编译完成后打印了一个警告,意思是说没找到 bl31.elf文件

cd ../   (到uboot外面去)

git clone [email protected]:ARM-software/arm-trusted-firmware.git

2.11 编译atf

cd arm-trusted-firmware
make realclean
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399
 

2.12 出现错误

make[1]: arm-none-eabi-gcc: Command not found

2.13 解决错误

没有命令了,安装就好

sudo apt-get install gcc-arm-none-eabi

2.14 继续,就成功了

make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399

2.15 回到uboot目录,重新编译uboot

cd ../u-boot/
export BL31=/home/zhi/3399/system/2022-11-27/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf
make CROSS_COMPILE=aarch64-linux-gnu-

没有警告了!!!!

./"arch/arm/mach-rockchip/make_fit_atf.py" \
arch/arm/dts/rk3399-firefly.dtb > u-boot.its
  MKIMAGE u-boot.itb
  BINMAN  all

三、烧录到开发板

3.1 烧录有很多方法,比如tf卡,我这里直接使用usb的工具吧。

需要用到两个文件,我把它们拷贝到windows共享目录中

cp idbloader.img /mnt/hgfs/vm_share/rk3399/

cp u-boot.itb /mnt/hgfs/vm_share/rk3399/

3.2 准备下载,打开AndroidTool_Release_v2.71

3.3 开发板连接usb的type c接口,重新启动进入loader模式,重启的时候按住recovery按键(或者在uboot阶段使用 reboot loader命令,或者linux系统中使用reboot loader命令都是可以进入到loader模式的。)

3.4 准备下载

 3.5 执行,开发板重启,成功

 

四、总结

4.1 以上步骤只是记录我移植的过程,中间的原理没有关注,只能是说移植的步骤基本完成,但是实际每个人每个虚拟机遇到的问题应该会有差异,建议百度解决。

4.2 基本还算是比较顺利,花时2小时左右吧.

4.3 有什么问题也欢迎私信我讨论,但是我本人技术也很渣啦,不一定能帮大家解决。