RK3588s-OrangePi 官方编译脚本获取及代码组织架构分析(三--其一)
一.编译环境和工具平台搭建
二.Linux 系统构建基础知识储备
三.OrangePi 官方编译脚本获取及代码组织架构分析
3-1. OrangePi官方脚本包获取(build.sh获取)
- 在获取build.sh编译脚本包之前务必参考专栏第一篇文章实现如下:
1). 修改apt镜像源
2). 安装好git工具且网络能够正常Ping通github网站 - 运行下列命令实现自动化编译脚本包的获取
- 成功示意
xiezr@xiezr-virtual-machine:~/rk3588_example$ git clone https://github.com/orangepi-xunlong/orangepi-build.git -b next
正克隆到 'orangepi-build'...
remote: Enumerating objects: 6469, done.
remote: Counting objects: 100% (1848/1848), done.
remote: Compressing objects: 100% (549/549), done.
remote: Total 6469 (delta 1355), reused 1647 (delta 1236), pack-reused 4621
接收对象中: 100% (6469/6469), 211.41 MiB | 7.73 MiB/s, 完成.
处理 delta 中: 100% (3013/3013), 完成.
正在更新文件: 100% (2166/2166), 完成.
如果下载不成功,将原来下载编译脚本的目录重新删除,然后重新mkdir,并chmod 777权限或科学上网
- 失败示意
xiezr@xiezr-virtual-machine:~/orangepi$ git clone https://github.com/orangepi-xunlong/orangepi-build.git -b next
正克隆到 'orangepi-build'...
remote: Enumerating objects: 6297, done.
remote: Counting objects: 100% (1676/1676), done.
remote: Compressing objects: 100% (468/468), done.
error: RPC 失败。curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
error: 预期仍然需要 5898 个字节的正文
fetch-pack: unexpected disconnect while reading sideband packet
fatal: 过早的文件结束符(EOF)
fatal: fetch-pack:无效的 index-pack 输出
3-2. OrangePi官方脚本包文件层级分析
- git clone orangepi-build 文件夹后大家不要急于运行build.sh脚本,先分析编译前文件层级
xiezr@xiezr-virtual-machine:~/rk3588_example/orangepi-build$ ls
build.sh external LICENSE README.md scripts
#############文件层级注释###################
# build.sh: 启动自动化编译的总脚本,即用户层的一个总开关,该脚本会调用./scripts/ 目录下的脚本和 \
./external下/的配置文件和特定脚本
# external: 该目录下比较杂,编译镜像需要用的配置文件、特定的脚本以及部分程序的源码等,不展开讲。
# LICENSE: GNU开源许可说明。
# README.md: 说明文档,主要是编译脚本支持的板子说明以及orangepi官网链接。
# scripts: 编译脚本文件夹,是站在build.sh背后支撑自动编译体系的脚本小弟们。接下来重点展开。
- ./scripts/*.sh重点脚本文件说明
感谢大佬的参考帖子:非常直观的脚本索引图
https://blog.youkuaiyun.com/zfenggo/article/details/111713307?spm=1001.2014.3001.5506
xiezr@xiezr-virtual-machine:~/rk3588_example/orangepi-build/scripts$ ls
build-all-ng.sh debootstrap.sh fel-load.sh makeboarddeb.sh
chroot-buildpackages.sh desktop.sh general.sh pack-uboot.sh
compilation.sh distributions.sh image-helpers.sh
configuration.sh extensions.sh main.sh
#############重点脚本注释###################
# build-all-ng.sh: build发生失败情况下执行此脚本对一些资源或变量进行销毁。
# main.sh: 编译是出现的配置UI界面逻辑分支切换就是由该脚本进行定义的,并实现从UI获取编译各配置参数
# compilation: 编译uboot.kernel等时候就是调用这个脚本里的接口函数。
# general.sh: 可以看作一个通用库,里面定义一系列通用脚本函数,如清空,异常退出,关键信息高亮打印,git仓库检查...
# extensions.sh: 跟编译拓展管理相关,具体作用待深挖。
# configuration.sh: 编译配置相关脚本文件,在main.sh中被调用展开
# pack-uboot.sh: 打包uboot脚本
# desktop.sh: 制作桌面环境相关脚本
# debootstrap.sh: 制作rootfs相关
# fel-load.sh: USB FEL加载RAM方式相关脚本
# chroot-buildpackages.sh: ######chroot相关
# makeboarddeb.sh: ######
# distributions.sh ######发行相关
# image-helpers.sh: 定义一些辅助函数,比如挂载和解挂载,SD上运行等行数。
3-3. build.sh编译失败–github自行获取u-boot,kernel源码安装包实现离线编译
- 运行sudo ./build.sh时会从github上获取u-boot源码,但是常常存在失败的清况,笔者选择从github上直接干源码压缩包离线编译会快很多,如果有科学上网更加事半功倍
1).笔者时orangepi 5 的板子,所以用的是下图中的u-boot版本
2).kernel版本有两个可以选择
- 运行sudo ./build.sh后会新创建几个文件夹
xiezr@xiezr-virtual-machine:~/rk3588s/orangepi-build$ ls
build.sh kernel output scripts u-boot
external LICENSE README.md toolchains userpatches
#############新增文件夹分析################
# userpatches: 存放编译脚本需要用到的配置文件,就是跟据external文件夹下的通用配置文件生成的
# toolchains: 交叉编译工具链,首次编译./build.sh会下载
# uboot: uboot源码存放路径,源码文件夹命名要求“v2017.09-rk3588”,否则脚本会git重更新下载
# kernel: kernel源码存放路径,源码文件夹命名要求“orange-pi-5.10-rk35xx”或"orange-pi-6.1-rk35xx",否则脚本会git重更新下载
# output: 编译结果输出目录
###注意:如果不想git检测,编辑userpatches/config-default.conf文件,将IGNORE_UPDATES="yes"即可。