Mainline Linux 和 U-Boot编译
By Toradex胡珊逢
Toradex 自从 Linux BSP v6 开始在使用 32位处理器的 Arm 模块如 iMX6、iMX6ULL、iMX7 上提供 mainline/upstream kernel ,部分 64位处理器模块如 Verdin iMX8M Mini/Plus 也提供实验性支持。文章将以季度发布版本 Linux BSP V6.3.0 为例介绍如何下载和编译 mainline/upstream Linux kernel 和 U-Boot。
Linux
下载 kernel 源码
内核源码可以从官网 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git 下载。但考虑到国内网络情况,推荐从国内的镜像站点下载,如 https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git。默认下载时会获取最新的 upstream 内核版本。可根据模块上运行 Linux 的版本 checkout 到对应版本源码。在模块上的 Linux 中运行 uname 命令,可以看到当前版本是 6.1.37。后面的 6.3.0 是 Toradex Linux BSP 季度发布版本。季度发布版本是经过充分的自动化和人工测试后发布的,可用于对应模块的生产环境。
----------------------------------
root@apalis-imx6:~# uname -a
Linux apalis-imx6 6.1.37-6.3.0+git.0f4ac6b4c5f0 #1 SMP Sat Jul 1 11:16:27 UTC 2023 armv7l armv7l armv7l GNU/Linux
----------------------------------
在电脑上使用下面命令并 checkout 到 v6.1.37。
----------------------------------
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git
$ git checkout v6.1.37
----------------------------------
下载和应用补丁
mainline/upstream kernel 通常还需要一些补丁。它们可以从 meta-toradex-bsp-common 中下载,后续其版本也需要对应到一样的季度版本。首先打开网址 https://git.toradex.com/cgit/toradex-manifest.git/tree/bsp/pinned-tdx.xml?h=6.3.0。结尾的 6.3.0 为对应的季度发布版本号。在页面中可以看到如下内容:
----------------------------------
<project name="meta-toradex-bsp-common.git" path="layers/meta-toradex-bsp-common" remote="tdx" revision="f7ff10a3b560dcf4e258115da679d1f864e09837" upstream="kirkstone-6.x.y"/>
----------------------------------
可以看到 meta-toradex-bsp-common.git 在季度发布版本 6.3.0 对应的 hash 是 f7ff10a3b560dcf4e258115da679d1f864e09837。通常建议使用最新发布的季度版本,获得问题修复和功能完善。因此,下载时请修改季度发布版本号和 hash 值。
进入上面下载的 Linux 源码目录后创建 patch 文件夹,并在其中下载 meta-toradex-bsp-common,checkout 对应用版本。
----------------------------------
$ cd linux-stable/
$ mkdir patch
$ cd patch
$ git clone https://git.toradex.com/cgit/meta-toradex-bsp-common.git
$ cd meta-toradex-bsp-common
$ git checkout f7ff10a3b560dcf4e258115da679d1f864e09837
----------------------------------
将 meta-toradex-bsp-common/recipes-kernel/linux/linux-toradex-mainline-git 的所有 patch 文件复制到 patch 目录下。
----------------------------------
$ cp meta-toradex-bsp-common/recipes-kernel/linux/linux-toradex-mainline-git/*.patch ./
----------------------------------
在 patch 目录下使用 git am 命令给 kernel 打补丁。注意必须要以固定的顺序打补丁。补丁顺序可以参看 meta-toradex-bsp-common/recipes-kernel/linux/linux-toradex-mainline_git.bb 文件。
----------------------------------
SRC_URI:append = " \
file://0001-thermal-imx-Update-critical-temp-threshold.patch \
file://0001-Revert-drm-panel-simple-drop-use-of-data-mapping-pro.patch \
file://0001-arm-dts-colibri-imx6-usb-dual-role-switching.patch \
file://0002-arm-dts-colibri-imx6-move-vbus-supply-to-module-leve.patch \
file://0003-arm-dts-colibri-imx6-specify-usbh_pen-gpio-being-act.patch \
file://0001-arm-dts-colibri-imx6ull-keep-peripherals-disabled.patch \
file://0002-arm-dts-colibri-imx6ull-enable-default-peripherals.patch \
file://0001-ARM-dts-colibri-imx6ull-Enable-dual-role-switching.patch \
file://0002-drivers-chipidea-disable-runtime-pm-for-imx6ul.patch \
file://0001-ARM-dts-apalis-imx6-Disable-usb-over-current.patch \
file://0002-ARM-dts-colibri-imx6-Disable-usb-over-current.patch \
file://0003-ARM-dts-colibri-imx6ull-Disable-usb-over-current.patch \
file://0004-ARM-dts-colibri-imx7-Disable-usb-over-current.patch \
file://0001-arm64-dts-imx8mm-verdin-Add-yavia-carrier-board.patch \
file://0002-arm64-dts-imx8mp-verdin-Add-yavia-carrier-board.patch \
file://0001-media-v4l2-async-fix-binding-async-subdevs-with-mult.patch \
file://0002-media-i2c-ov5640-Implement-get_mbus_config.patch \
file://0001-Revert-media-v4l2-async-Use-endpoints-in-__v4l2_asyn.patch \
"
----------------------------------
在 patch 文件夹里执行面命令,期间不应该出现任何错误和冲突。
----------------------------------
$ cd patch
$ git am 0001-thermal-imx-Update-critical-temp-threshold.patch \
0001-Revert-drm-panel-simple-drop-use-of-data-mapping-pro.patch \
0001-arm-dts-colibri-imx6-usb-dual-role-switching.patch \
0002-arm-dts-colibri-imx6-move-vbus-supply-to-module-leve.patch \
0003-arm-dts-colibri-imx6-specify-usbh_pen-gpio-being-act.patch \
0001-arm-dts-colibri-imx6ull-keep-peripherals-disabled.patch \
0002-arm-dts-colibri-imx6ull-enable-default-peripherals.patch \
0001-ARM-dts-colibri-imx6ull-Enable-dual-role-switching.patch \
0002-drivers-chipidea-disable-runtime-pm-for-imx6ul.patch \
0001-ARM-dts-apalis-imx6-Disable-usb-over-current.patch \
0002-ARM-dts-colibri-imx6-Disable-usb-over-current.patch \
0003-ARM-dts-colibri-imx6ull-Disable-usb-over-current.patch \
0004-ARM-dts-colibri-imx7-Disable-usb-over-current.patch \
0001-arm64-dts-imx8mm-verdin-Add-yavia-carrier-board.patch \
0002-arm64-dts-imx8mp-verdin-Add-yavia-carrier-board.patch \
0001-media-v4l2-async-fix-binding-async-subdevs-with-mult.patch \
0002-media-i2c-ov5640-Implement-get_mbus_config.patch \
0001-Revert-media-v4l2-async-Use-endpoints-in-__v4l2_asyn.patch
----------------------------------
kernel 配置
内核配置文件 .config 也可以从 Toradex Artifactory 下载,并使用对应的季度发布版本的编译文件。打开 Toradex Artifactory 网页,在左边的 Artifact Repository Browser 中点开 oe-release,选择 Linux BSP v6 对应的 kirkstone-6.x.y。依次打开 kirkstone-6.x.y/release/7/apalis-imx6/tdx-xwayland-upstream/tdx-reference-multimedia-image/oedeploy/。release 下面一般可以选择最大序列的,这对应最新的发布版本。右击 kernel-config 下载即可。
将 kernel-config 复制到刚才下载的内核源码目录,命名为 .config ,用其作为 Linux 的默认配置。如果需要修改,后面还可以使用 make menuconfig 命令。
----------------------------------
$ cd linux-stable/
$ mv kernel-config .config
$ make olddefconfig
----------------------------------
准备好源码、补丁和内核配置文件,接下来就可以编译了,具体方法参考这里。
U-Boot
下载 U-Boot 源码
首先从 https://source.denx.de/u-boot/u-boot.git 下载源码,并 checkout 到 v2022.07 版本,也是 Linux BSP v6 所使用的 U-Boot 版本。
----------------------------------
$ git clone https://source.denx.de/u-boot/u-boot.git
$ cd u-boot
$ git checkout v2022.07
----------------------------------
下载和应用补丁
Upstream/mainline U-Boot 同样也需要相关补丁,和上面一样由 meta-toradex-bsp-common 提供。按照前面的方法在 u-boot 目录中建立 patch 文件夹后,在其中下载和 checkout。U-Boot 补丁位于 meta-toradex-bsp-common/recipes-bsp/u-boot/u-boot-toradex 目录下。将里面的 patch 文件复制到 u-boot/patch 目录下。
----------------------------------
$ cd u-boot
$ mkdir patch
$ cd patch
$ git clone https://git.toradex.com/cgit/meta-toradex-bsp-common.git
$ cd meta-toradex-bsp-common
$ git checkout f7ff10a3b560dcf4e258115da679d1f864e09837
$ cp meta-toradex-bsp-common/recipes-bsp/u-boot/u-boot-toradex/*.patch ./
----------------------------------
注意必须要以固定的顺序打补丁。补丁顺序可以参看 U-Boot meta-toradex-bsp-common/recipes-bsp/u-boot/u-boot-toradex_2022.07.bb 文件。
----------------------------------
TDX_PATCHES = " \
file://0001-toradex-tdx-cfg-block-use-only-snprintf.patch \
file://0002-toradex-tdx-cfg-block-use-defines-for-string-length.patch \
file://0003-toradex-tdx-cfg-block-extend-assembly-version.patch \
file://0004-toradex-tdx-cfg-block-add-new-toradex-oui-range.patch \
file://0005-toradex-tdx-cfg-block-add-0068-i.mx-8m-mini-sku.patch \
file://0006-toradex-common-Remove-stale-comments-about-modules-a.patch \
file://0007-toradex-common-Use-ARRAY_SIZE-macro.patch \
file://0008-toradex-tdx-cfg-block-Cleanup-interactive-cfg-block-.patch \
file://0009-toradex-common-Remove-stale-function-declaration.patch \
file://0010-toradex-common-Remove-ifdef-usage-for-2nd-ethaddr.patch \
file://0011-toradex-tdx-cfg-block-Use-official-SKU-names.patch \
file://0012-toradex-common-Improve-product-serial-print-during-b.patch \
file://0013-configs-colibri-imx7-Enable-bootd-command.patch \
file://0001-ARM-imx8mp-verdin-imx8mp-Add-memory-size-detection.patch \
file://0001-apalis-colibri_imx6-imx6ull-_imx7-update-env-memory-.patch \
file://0001-configs-colibri-imx7-Fix-bad-block-table-in-flash-co.patch \
file://0001-colibri_imx6-fix-RALAT-and-WALAT-values.patch \
"
----------------------------------
在 patch 文件夹里执行面 git am 命令,期间不应该出现任何错误和冲突。
----------------------------------
$ git am 0001-toradex-tdx-cfg-block-use-only-snprintf.patch \
0002-toradex-tdx-cfg-block-use-defines-for-string-length.patch \
0003-toradex-tdx-cfg-block-extend-assembly-version.patch \
0004-toradex-tdx-cfg-block-add-new-toradex-oui-range.patch \
0005-toradex-tdx-cfg-block-add-0068-i.mx-8m-mini-sku.patch \
0006-toradex-common-Remove-stale-comments-about-modules-a.patch \
0007-toradex-common-Use-ARRAY_SIZE-macro.patch \
0008-toradex-tdx-cfg-block-Cleanup-interactive-cfg-block-.patch \
0009-toradex-common-Remove-stale-function-declaration.patch \
0010-toradex-common-Remove-ifdef-usage-for-2nd-ethaddr.patch \
0011-toradex-tdx-cfg-block-Use-official-SKU-names.patch \
0012-toradex-common-Improve-product-serial-print-during-b.patch \
0013-configs-colibri-imx7-Enable-bootd-command.patch \
0001-ARM-imx8mp-verdin-imx8mp-Add-memory-size-detection.patch \
0001-apalis-colibri_imx6-imx6ull-_imx7-update-env-memory-.patch \
0001-configs-colibri-imx7-Fix-bad-block-table-in-flash-co.patch \
0001-colibri_imx6-fix-RALAT-and-WALAT-values.patch
----------------------------------
U-Boot 配置
对于 32位处理器的模块,默认配置如下:
l colibri_imx6_defconfig
l colibri-imx6ull_defconfig
l colibri-imx6ull-emmc_defconfig
l colibri_imx7_defconfig
l colibri_imx7_emmc_defconfig
l apalis_imx6_defconfig
以 Apalis iMX6 为例。
----------------------------------
$ make mrproper
$ make apalis_imx6_defconfig
----------------------------------
最后编译 U-Boot。
----------------------------------
$ make -j$(nproc)
----------------------------------
相关文章:

Mainline Linux 和 U-Boot编译
By Toradex胡珊逢 Toradex 自从 Linux BSP v6 开始在使用 32位处理器的 Arm 模块如 iMX6、iMX6ULL、iMX7 上提供 mainline/upstream kernel ,部分 64位处理器模块如 Verdin iMX8M Mini/Plus 也提供实验性支持。文章将以季度发布版本 Linux BSP V6.3.0 为例介绍如何下…...

Mycat教程+面试+linux搭建
目录 一 MyCAT介绍 二 常见的面试题总结 三 linux下搭建Mycat 一 MyCAT介绍 1.1. 什么是MyCAT? 简单的说,MyCAT就是: 一个彻底开源的,面向企业应用开发的“大数据库集群” 支持事务、ACID、可以替代Mysql的加强版数据库 一个可…...
基于工作过程的高职计算机网络技术专业课程体系构建策略
行业人才需求分析高职教育是面向地方行业培养技能型、应用型人才,因此, 在课程体系的构建上要走社会调研、构建岗位群、构建专业模块及课程设置“四步 曲”。即通过社会行业需求调查研究,构建岗位群,设置相应的专业模块…...

(笔记四)利用opencv识别标记视频中的目标
预操作: 通过cv2将视频的某一帧图片转为HSV模式,并通过鼠标获取对应区域目标的HSV值,用于后续的目标识别阈值区间的选取 img cv.imread(r"D:\data\123.png") img cv.cvtColor(img, cv.COLOR_BGR2HSV) plt.figure(1), plt.imshow…...

一、计算机硬件选购
计算机硬件选购 一、设备选购1.1 I/O设备1.2 机箱1.3 主板1.3.1 主板芯片组的命名方式1.3.2 主板版型1.3.3 Z790-a(DDR5)主板参数 1.4 CPU1.5 硬盘1.6 显卡1.7 内存条1.8 散热器(水冷)1.9 电源、风扇、网线、插线板1.9.1 电源1.9.2 风扇1.9.3 网线1.9.4 …...

Dockerfile制作LAMP环境镜像
文章目录 使用Dockerfile制作LAMP环境镜像编写Dockerfile不修改默认页面修改默认页面 Start Script目录结构及文件登录私有仓库给镜像打标签上传镜像页面检查检测镜像可用性 使用Dockerfile制作LAMP环境镜像 编写Dockerfile 不修改默认页面 FROM centos:7 MAINTAINER "…...

暴力递归转动态规划(二)
上一篇已经简单的介绍了暴力递归如何转动态规划,如果在暴力递归的过程中发现子过程中有重复解的情况,则证明这个暴力递归可以转化成动态规划。 这篇帖子会继续暴力递归转化动态规划的练习,这道题有点难度。 题目 给定一个整型数组arr[]&…...
debian apt error: Package ‘xxx‘ has no installation candidate
新的debian虚拟机可能会出现这个问题。 修改apt的source.list,位于/etc/apt/source.list,添加两行: deb http://deb.debian.org/debian bullseye main deb-src http://deb.debian.org/debian bullseye main执行: sudo apt-get u…...

c#设计模式-结构型模式 之 外观模式
概述 外观模式(Facade Pattern)又名门面模式,隐藏系统的复杂性,并向客户端提供了一个客户端可以访问系统的接口。这种类型的设计模式属于结构型模式,它向现有的系统添加一个接口,来隐藏系统的复杂性。该模式…...

Focal Loss-解决样本标签分布不平衡问题
文章目录 背景交叉熵损失函数平衡交叉熵函数 Focal Loss损失函数Focal Loss vs Balanced Cross EntropyWhy does Focal Loss work? 针对VidHOI数据集Reference 背景 Focal Loss由何凯明提出,最初用于图像领域解决数据不平衡造成的模型性能问题。 交叉熵损失函数 …...

运算符(个人学习笔记黑马学习)
算数运算符 加减乘除 #include <iostream> using namespace std;int main() {int a1 10;int a2 20;cout << a1 a2 << endl;cout << a1 - a2 << endl;cout << a1 * a2 << endl;cout << a1 / a2 << endl;/*double a3 …...

开源与专有软件:比较与对比
🌷🍁 博主猫头虎 带您 Go to New World.✨🍁 🦄 博客首页——猫头虎的博客🎐 🐳《面试题大全专栏》 文章图文并茂🦕生动形象🦖简单易学!欢迎大家来踩踩~🌺 &a…...
openResty+lua+redis实现接口访问频率限制
openResty简介: OpenResty 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。 OpenResty 通过汇聚各种设…...

自动化测试(三):接口自动化pytest测试框架
文章目录 1. 接口自动化的实现2. 知识要点及实践2.1 requests.post传递的参数本质2.2 pytest单元测试框架2.2.1 pytest框架简介2.2.2 pytest装饰器2.2.3 断言、allure测试报告2.2.4 接口关联、封装改进YAML动态传参(热加载) 2.3 pytest接口封装ÿ…...
Python --datetime模块
目录 1, 获取datetime时间 2, datetime与timestamp转换 2-1, datetime转timestamp 2-2, timestamp转datetime 3, str格式与datetime转换 3-1, datetime转str格式 3-2, str格式转datetime…...

顺序表链表OJ题(3)——【数据结构】
W...Y的主页 😊 代码仓库分享 💕 前言: 今天是链表顺序表OJ练习题最后一次分享,每一次的分享题目的难度也再有所提高,但是我相信大家都是非常机智的,希望看到博主文章能学到东西的可以一键三连关注一下博主…...

【Azure】Virtual Hub vWAN
虚拟 WAN 文档 Azure 虚拟 WAN 是一个网络服务,其中整合了多种网络、安全和路由功能,提供单一操作界面。 我们主要讨论两种连接情况: 通过一个 vWAN 来连接不通的 vNET 和本地网络。以下是一个扩展的拓扑 结合 vhub,可以把两个中…...
React Navigation 使用导航
在 Web 浏览器中,您可以使用锚标记链接到不同的页面。当用户单击链接时,URL 会被推送到浏览器历史记录堆栈中。当用户按下后退按钮时,浏览器会从历史堆栈顶部弹出该项目,因此活动页面现在是以前访问过的页面。React Native 不像 W…...

双指针算法,基础算法实践,基本的算法的思想,双指针算法的实现
一,定义 双指针算法是一种常用于解决数组和链表问题的算法技巧。它的核心思想是使用两个指针在数据结构中按照一定的规则移动,从而达到快速搜索或处理数据的目的。这个技巧通常用于优化算法,降低时间复杂度,提高程序的执行效率。…...

idea http request无法识别环境变量
问题描述 创建了环境变量文件 http-client.env.json,然后在*.http 文件中引用环境变量,运行 HTTP 请求无法读取环境变量文件中定义的变量。 事故现场 IDEA 版本:2020.2 2021.2 解决步骤 2020.2 版本环境变量无法读取 2021.2 版本从 2020.…...
【根据当天日期输出明天的日期(需对闰年做判定)。】2022-5-15
缘由根据当天日期输出明天的日期(需对闰年做判定)。日期类型结构体如下: struct data{ int year; int month; int day;};-编程语言-CSDN问答 struct mdata{ int year; int month; int day; }mdata; int 天数(int year, int month) {switch (month){case 1: case 3:…...

Linux相关概念和易错知识点(42)(TCP的连接管理、可靠性、面临复杂网络的处理)
目录 1.TCP的连接管理机制(1)三次握手①握手过程②对握手过程的理解 (2)四次挥手(3)握手和挥手的触发(4)状态切换①挥手过程中状态的切换②握手过程中状态的切换 2.TCP的可靠性&…...

渗透实战PortSwigger靶场-XSS Lab 14:大多数标签和属性被阻止
<script>标签被拦截 我们需要把全部可用的 tag 和 event 进行暴力破解 XSS cheat sheet: https://portswigger.net/web-security/cross-site-scripting/cheat-sheet 通过爆破发现body可以用 再把全部 events 放进去爆破 这些 event 全部可用 <body onres…...

linux arm系统烧录
1、打开瑞芯微程序 2、按住linux arm 的 recover按键 插入电源 3、当瑞芯微检测到有设备 4、松开recover按键 5、选择升级固件 6、点击固件选择本地刷机的linux arm 镜像 7、点击升级 (忘了有没有这步了 估计有) 刷机程序 和 镜像 就不提供了。要刷的时…...

1.3 VSCode安装与环境配置
进入网址Visual Studio Code - Code Editing. Redefined下载.deb文件,然后打开终端,进入下载文件夹,键入命令 sudo dpkg -i code_1.100.3-1748872405_amd64.deb 在终端键入命令code即启动vscode 需要安装插件列表 1.Chinese简化 2.ros …...
第25节 Node.js 断言测试
Node.js的assert模块主要用于编写程序的单元测试时使用,通过断言可以提早发现和排查出错误。 稳定性: 5 - 锁定 这个模块可用于应用的单元测试,通过 require(assert) 可以使用这个模块。 assert.fail(actual, expected, message, operator) 使用参数…...

ABAP设计模式之---“简单设计原则(Simple Design)”
“Simple Design”(简单设计)是软件开发中的一个重要理念,倡导以最简单的方式实现软件功能,以确保代码清晰易懂、易维护,并在项目需求变化时能够快速适应。 其核心目标是避免复杂和过度设计,遵循“让事情保…...

HashMap中的put方法执行流程(流程图)
1 put操作整体流程 HashMap 的 put 操作是其最核心的功能之一。在 JDK 1.8 及以后版本中,其主要逻辑封装在 putVal 这个内部方法中。整个过程大致如下: 初始判断与哈希计算: 首先,putVal 方法会检查当前的 table(也就…...

20个超级好用的 CSS 动画库
分享 20 个最佳 CSS 动画库。 它们中的大多数将生成纯 CSS 代码,而不需要任何外部库。 1.Animate.css 一个开箱即用型的跨浏览器动画库,可供你在项目中使用。 2.Magic Animations CSS3 一组简单的动画,可以包含在你的网页或应用项目中。 3.An…...
腾讯云V3签名
想要接入腾讯云的Api,必然先按其文档计算出所要求的签名。 之前也调用过腾讯云的接口,但总是卡在签名这一步,最后放弃选择SDK,这次终于自己代码实现。 可能腾讯云翻新了接口文档,现在阅读起来,清晰了很多&…...