天天看點

firefly3399專題1-uboot2022.10的移植一、下載下傳uboot源碼二、源碼編譯三、燒錄到開發闆四、總結

硬體資訊: friefly3399一塊,2GB記憶體/16Gemmc。

軟體資訊: ubuntu18.04虛拟機,内部有firefly的SDK包。

參考資料:[ROC-RK3399-PC Pro] 手把手教你移植主線U-Boot(基于v2022.04-rc5版本)_Neutionwei的部落格-CSDN部落格

目标移植uboot2022.10到firefly3399開發闆

firefly3399專題1-uboot2022.10的移植一、下載下傳uboot源碼二、源碼編譯三、燒錄到開發闆四、總結

一、下載下傳uboot源碼

1.1  git 下載下傳,需要安裝git工具!!

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

1.2 出現問題:

[email protected]:~/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.查找一下,發現有該編譯器

[email protected]:~/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

firefly3399專題1-uboot2022.10的移植一、下載下傳uboot源碼二、源碼編譯三、燒錄到開發闆四、總結

3.3 開發闆連接配接usb的type c接口,重新啟動進入loader模式,重新開機的時候按住recovery按鍵(或者在uboot階段使用 reboot loader指令,或者linux系統中使用reboot loader指令都是可以進入到loader模式的。)

3.4 準備下載下傳

firefly3399專題1-uboot2022.10的移植一、下載下傳uboot源碼二、源碼編譯三、燒錄到開發闆四、總結

 3.5 執行,開發闆重新開機,成功

firefly3399專題1-uboot2022.10的移植一、下載下傳uboot源碼二、源碼編譯三、燒錄到開發闆四、總結

四、總結

4.1 以上步驟隻是記錄我移植的過程,中間的原理沒有關注,隻能是說移植的步驟基本完成,但是實際每個人每個虛拟機遇到的問題應該會有差異,建議百度解決。

4.2 基本還算是比較順利,花時2小時左右吧.

4.3 有什麼問題也歡迎私信我讨論,但是我本人技術也很渣啦,不一定能幫大家解決。

繼續閱讀