如何编译uboot?
一.如何修改uboot的配置?
- 先通过
./make.sh rk3566生成一个 .config 基础配置文件 - 然后通过
make menuconfig来修改配置 - 配置完成后,通过
make savedefconfig来保存配置,保存的文件名为defconfig - 然后将
defconfig拷贝到configs目录下,并重命名为my_defconfig - 修改完毕后,通过
./make.sh my就可以编译出my_defconfig的uboot了
二.如何从源代码编译uboot?
参考: U-Boot 编译
1. 安装编译环境
运行环境: Ubuntu 20.04 在docker中运行
docker run -it ubuntu:20.04 /bin/bash编译环境安装:
bash
sudo apt-get update
sudo apt-get install bc bison build-essential coccinelle \
device-tree-compiler dfu-util efitools flex gdisk graphviz imagemagick \
libgnutls28-dev libguestfs-tools libncurses-dev \
libpython3-dev libsdl2-dev libssl-dev lz4 lzma lzma-alone openssl \
pkg-config python3 python3-asteval python3-coverage python3-filelock \
python3-pkg-resources python3-pycryptodome python3-pyelftools \
python3-pytest python3-pytest-xdist python3-sphinxcontrib.apidoc \
python3-sphinx-rtd-theme python3-subunit python3-testtools \
python3-venv swig uuid-dev
sudo apt-get install gcc gcc-aarch64-linux-gnu2. 编译uboot
- 下载uboot的源码 下载地址: https://github.com/u-boot/u-boot.git
bash
git clone https://github.com/u-boot/u-boot.git
cd u-boot在这个目录下, 可以看到 configs 目录, 这个目录下存放着uboot的配置文件, 我们需要修改的配置文件就在这个目录下. 搜索 rk3566 可以看到有``
root@tspi:/home/lckfb/configs# ll | grep 3566
-rw-rw-r-- 1 1000 1000 2001 Oct 29 14:39 lckfb-tspi-rk3566_defconfig可以看到有一个 lckfb-tspi-rk3566_defconfig 配置文件, 这个文件就是我们需要修改的配置文件.说明对于泰山派的rk3566,已经直接可以受官方支持了.
- 编译uboot
bash
cd u-boot
make lckfb-tspi-rk3566_defconfig
make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc)- 编译后,会发现出现了错误:
c
Image 'simple-bin' is missing external blobs and is non-functional: rockchip-tpl atf-bl31
/binman/simple-bin/mkimage/rockchip-tpl (rockchip-tpl):
An external TPL is required to initialize DRAM. Get the external TPL
binary and build with ROCKCHIP_TPL=/path/to/ddr.bin. One possible source
for the external TPL binary is https://github.com/rockchip-linux/rkbin.
/binman/simple-bin/fit/images/@atf-SEQ/atf-bl31 (atf-bl31):
See the documentation for your board. You may need to build ARM Trusted
Firmware and build with BL31=/path/to/bl31.bin
Image 'simple-bin' has faked external blobs and is non-functional: rockchip-tpl
Image 'simple-bin' is missing optional external blobs but is still functional: tee-os
/binman/simple-bin/fit/images/@tee-SEQ/tee-os (tee-os):
See the documentation for your board. You may need to build Open Portable
Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.bin这个错误是因为缺少 rockchip-tpl, atf-bl31, tee-os 这三个文件, 这三个文件是uboot启动时需要的文件, 我们需要从 rkbin 中获取. rkbin 是 rockchip 提供的固件包,里面包含了 rockchip-tpl, atf-bl31, tee-os 这三个文件.
- 下载
rkbin的源码 从错误信息中可以看到, 需要从rkbin中获取rockchip-tpl,atf-bl31,tee-os这三个文件. 下载地址: https://github.com/rockchip-linux/rkbin.git
bash
git clone https://github.com/rockchip-linux/rkbin.git
cd rkbin在这个目录下的 bin 目录下, 可以看到 rk35 目录, 这个目录下存放着 rk3566 的固件包.
在开始编译之前,需要配置一下:
bash
export ROCKCHIP_TPL=/home/lckfb/rkbin/bin/rk35/rk3566_ddr_1056MHz_v1.23.bin
export BL31=/home/lckfb/rkbin/bin/rk35/rk3568_bl31_v1.45.elf- 对于 tee-os, 我们需要从 在
make menuconfig中选择CONFIG_TEE=n来禁用tee-os的编译. 去掉这个选项, 就可以编译成功.
Location:
-> Boot options
-> Boot images
[] Flattened Image Tree (FIT)- 再次编译:
bash
make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc)编译成功后, 可以看到
u-boot.bin文件, 这个文件就是我们需要的uboot文件.烧录uboot:
