OrangeZero2 内核编译/移植 和 驱动编译
为什么要选它?(买不起树莓派 : /(ㄒoㄒ)/~~)
当然是学习下内核编译 , 内核移植,驱动的编译啦。
1. 准备工作
- 工具
- Ubuntu18.04 (分辨率调大一点不然会出错 ,我设置的分辨率为 : 1360 * 768 )
- 更新下软件源 sudo apt-get update (配置完软件源后更新)
- 一些工具 sudo apt install bison flex libncurses-dev make libssl-dev u-boot-tools
- 对应源码
sdk 源码:(我当时 github下的编译会报错,就去找的其他版本)
链接:https://pan.baidu.com/s/1Va3HnrBZJwYJ2XFU5SftZQ?pwd=fgg1
提取码:fgg1- 查看板子内核信息 :uname -a 得到信息如下
Linux orangepizero2 4.9.170-sun50iw9 #14 SMP PREEMPT Mon Mar 28 14:53:15 CST 2022 aarch64 aarch64 aarch64 GNU/Linux (4.9.170 版本)
- 设置软件源为清华源
需要替换的/etc/apt/sources.list 文件的内容为:
test@test:~$ sudo mv /etc/apt/sources.list cat /etc/apt/sources.list.bak
test@test:~$ sudo vim /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe
multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe
multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe
multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted
universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted
universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted
universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe
multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted
universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted
universe multiverse
2. 编译 Liunx 内核
需要科学上网,不然会出错
-
运行 build.sh 脚本,记得加 sudo 权限 : sudo ./build.sh ( 会帮我们下载编译工具和源码 )
-
选择 Kernel package,然后回车
-
接着选择开发板的型号
-
然后选择分支(我的板子是 4.9 的)
-
配置内核 (按需配置,我这直接退出)
-
生成目录如下
编译好的内核文件在 kernel 下
部分文件释义
a. build.sh: 编译启动脚本
b. external: 包含编译镜像需要用的配置文件、特定功能的脚本以及部分程序的源码,编译镜像过程中缓存的 rootfs 压缩包也存放在 external 中
c. kernel: 存放 linux 内核的源码,里面名为 orange-pi-4.9-sun50iw9 的文件夹存 放 的 就 是 H616 系 列 开 发 板 legacy 分 支 的 内 核 源 码 , 里 面 名 为orange-pi-5.13-sunxi64 的文件夹存放的就是 H616 开发板 current 分支的内核源码(如果只编译了 legacy 分支的 linux 镜像,那么则只能看到 legacy 分支的内核源码;如果只编译了 current 分支的 linux 镜像那么则只能看到current 分支的内核源码),内核源码的文件夹的名字请不要手动修改,如果修改了,编译系统运行时会重新下载内核源码
d. LICENSE: GPL 2 许可证文件
e. README.md: orangepi-build 说明文件
f. output: 存放编译生成的 u-boot、linux 等 deb 包、编译日志以及编译生成的镜像等文件
g. scripts: 编译 linux 镜像的通用脚本
h. toolchains: 存放交叉编译工具链
i. u-boot: 存放 u-boot 的源码,里面名为 v2018.05-sun50iw9 的文件夹存放的就是 H616 系列开发板 legacy 分支的 u-boot 源码,里面名为 v2021.07-sunxi的文件夹存放的就是 H616 开发板 current 分支的 u-boot 源码(如果只编译了current 分支的 linux 镜像,那么则只能看到 current 分支的 u-boot源码),u-boot 源码的文件夹的名字请不要手动修改,如果修改了,编译系统运行时会重新下载 u-boot 源码
j. userpatches: 存放编译脚本需要用到的配置文件
3. 内核移植
- 上传 dep 包,使用第三个
- 将编译好的deb 文件上传 至开发板