香橙派内核编译/移植 和 驱动编译

OrangeZero2 内核编译/移植 和 驱动编译

为什么要选它?(买不起树莓派 : /(ㄒoㄒ)/~~)
当然是学习下内核编译 , 内核移植,驱动的编译啦。

在这里插入图片描述

1. 准备工作

  1. 工具
  1. Ubuntu18.04 (分辨率调大一点不然会出错 ,我设置的分辨率为 : 1360 * 768 )
  2. 更新下软件源 sudo apt-get update (配置完软件源后更新)
  3. 一些工具 sudo apt install bison flex libncurses-dev make libssl-dev u-boot-tools
  4. 对应源码
    sdk 源码:(我当时 github下的编译会报错,就去找的其他版本)
    链接:https://pan.baidu.com/s/1Va3HnrBZJwYJ2XFU5SftZQ?pwd=fgg1
    提取码:fgg1
  5. 查看板子内核信息 :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 版本)
  1. 设置软件源为清华源
    需要替换的/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 内核

需要科学上网,不然会出错

  1. 运行 build.sh 脚本,记得加 sudo 权限 : sudo ./build.sh ( 会帮我们下载编译工具和源码 )

  2. 选择 Kernel package,然后回车
    在这里插入图片描述

  3. 接着选择开发板的型号
    在这里插入图片描述

  4. 然后选择分支(我的板子是 4.9 的)
    在这里插入图片描述

  5. 配置内核 (按需配置,我这直接退出)

    在这里插入图片描述

  6. 生成目录如下
    在这里插入图片描述
    编译好的内核文件在 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. 内核移植

  1. 上传 dep 包,使用第三个在这里插入图片描述
  2. 将编译好的deb 文件上传 至开发板
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老痞啥都不会

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值