logo
0
0
WeChat Login
docs: 添加用户苏木的 uboot README 文档

U-Boot

一、 获取 U-Boot

主线版 U-boot 对大部分比较新的处理器支持十分有限,这里选择使用 RK 版本的 U-Boot:next-dev, 而 RK 版本的 U-Boot 又分为两部分,一个是 U-boot 本身的代码仓库,也就是 u-boot 目录下的内容, 还有一部分是工具包仓库,存放 RK 不开源的二进制文件、脚本、打包工具,用于打包生成 loader、trust、uboot 固件,在 rkbin 目录下。

Tips:注意,rkbin 和 U-Boot 工程必须保持同级目录关系。

1. 源码仓库

仓库来源 GitHub 仓库 分支
Rockchip 官方 Caesar-github/u-boot next-dev
Caesar-github/rkbin master
野火 LubanCat/u-boot next-dev main
LubanCat/rkbin master main

2. 下载指定分支

2.1 从哪里确定版本?

用什么版本?我们可以先看野火的文档,里面下载 SDK 的命令为:

cd ~/LubanCat_SDK # 拉取 LubanCat_Linux_Generic_SDK repo init -u https://github.com/LubanCat/manifests.git -b linux -m lubancat_linux_generic.xml #如果运行以上命令失败,提示:fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle #则可以在以上命令中添加选项 --repo-url https://mirrors.tuna.tsinghua.edu.cn/git/git-repo .repo/repo/repo sync -c -j4

从这里可以知道,使用的清单库为 LubanCat/manifests ,使用的清单库文件为 manifests/lubancat_linux_generic.xml,它是一个软链接,指向了清单库中的 lubancat_linux/lubancat_linux_generic_release.xml 文件,而这个文件又指向了 lubancat_linux/lubancat_linux_generic_20260114.xml 文件,这个文件中 u-boot 和 rkbin 的部分如下:

<?xml version="1.0" encoding="UTF-8"?> <manifest> <!-- ... --> <project name="rkbin" revision="58a39b47f77a26a1e110fa1a1ce80bcfcb0b3505" dest-branch="main" clone-depth="1"/> <project name="u-boot" revision="8f53f800da2c25d0c6ba414fb45902a01675703a" dest-branch="main" clone-depth="1"/> <!-- ... --> </manifest>

Tips:截止到写这篇 md 文档,日期是 2026.3.27,此时野火官方仓库的清单库 LubanCat/manifestsmanifests/lubancat_linux_generic.xml 文件的提交记录为 41948d1

2.2 可以确定版本了

从上面的 lubancat_linux/lubancat_linux_generic_release.xml 文件,我们可以确定使用的 u-boot 和 rkbin 在野火仓库中的版本:

野火仓库 分支与提交记录 分支迁移的初次提交 分支来源
LubanCat/u-boot main at 8f53f80 after 8f53f80+1607 Caesar-github/u-boot ➡️ next-dev ➡️ e9cac7f
e9cac7f+0
LubanCat/rkbin main at 58a39b4 after 58a39b4+515 Caesar-github/rkbin ➡️ master ➡️ 5ed54e6
5ed54e6+0

Tips:如何在 Github 快速跳转到某次提交前的 n 次提交?

https://github.com/<仓库>/commits/<branch or commit-id>/?after=<commit-id>+<n> 例如: https://github.com/LubanCat/u-boot/commits/main/?after=8f53f800da2c25d0c6ba414fb45902a01675703a+500

2.3 在线源码

这里有一个网站,可以在线查看对应版本 u-boot 官方源码,从 u-boot/Makefile at 8f53f800da2c25d0c6ba414fb45902a01675703a · LubanCat/u-boot · GitHub 可知使用的 uboot 为 2017.09 版本,我们可以点这里查看对应 uboot 官方的源码:U-boot source code (v2017.09) - Bootlin Elixir Cross Referencer

2.4 下载命令

git clone --depth 1 https://github.com/LubanCat/u-boot.git cd u-boot git fetch --depth 1 origin 8f53f800da2c25d0c6ba414fb45902a01675703a git checkout 8f53f800da2c25d0c6ba414fb45902a01675703a