打印
[ARM入门]

手把手教你在Ubuntu定制文件系统

[复制链接]
1096|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
布罗利|  楼主 | 2022-12-15 20:16 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 布罗利 于 2022-12-15 20:18 编辑

为了给客户的测试和开发提供便利,飞凌嵌入式的开发板产品一般都支持多种操作系统,以基于全志T507H处理器设计研发的OKT507-C开发板为例,它支持三种操作系统,分别是:Linux、Android 和 Forlinx Desktop(Ubuntu),这里提到的Forlinx Desktop系统是飞凌嵌入式在Ubuntu base的基础上构建的桌面操作系统,完全兼容Ubuntu18.04,相对传统的Linux系统而言易用性更高。








Forlinx Desktop(Ubuntu)系统基于Ubuntu官方为嵌入式设备制作的操作系统-Lubuntu,该操作系统具备apt-get、ldd等常用的命令,若需要安装软件则直接apt-get在线安装即可,不需进行交叉编译移植等繁琐操作。但是每次重新烧写镜像之后,之前安装的软件就得重新安装,比较繁琐,如果需要批量操作则每块开发板都需要去apt-get安装,这样会大幅增加工作量,很不便于批量化生产。




能不能把软件一起打包到镜像呢?这样每次烧写完就不用再去apt-get在线安装了。答案当然是肯定的,这就涉及到文件系统的定制了,那么接下来,小编就为大家介绍在Forlinx Desktop(Ubuntu)系统上定制文件系统的操作过程。




1. 解压文件系统

首先,找到OKT507-desktop-release源码的文件系统所在的目录,然后将文件系统压缩包解压,路径如下:

OKT507-desktop-release/ubuntu









解压后,可看到文件系统目录OKT507-linux-ubuntu,进入到此目录后可看到如下文件夹:




[backcolor=rgba(18, 18, 18, 0.5)]​





2. 安装QEMU

这里简单介绍下QEMU,它是一个小巧的模拟器,可以模拟很多硬件如ARM、x86、AMD64/Intel64等。QEMU用途广泛,比如Xen、Android模拟器等都是基于QEMU的。下面我们开始在虚拟机进行安装QEMU,如下:

① 更新下载源:

sudo apt-get update

②执行命令安装:

sudo apt-get install qemu-aarch64-static

sudo apt-get install qemu-user-static




3. 修改配置

① 将QEMU的qemu-arm-static拷贝到文件系统目录OKT507-linux-ubuntu,如下:

sudo cp /usr/bin/qemu-arm-static usr/bin/









② 拷贝PC主机端的DNS配置,因为待会我们安装程序时要用网络:

sudo cp -b /etc/resolv.conf  etc/resolv.conf








③ 修改下载源:

sudo vim etc/apt/sources.list



添加

deb http://ports.ubuntu.com/ubuntu-ports/ xenial main universedeb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main universe









4. 挂载文件系统

因为我们这里是通过脚本的方式挂载和卸载文件系统,所以需要编写一个脚本挂载和卸载文件系统。

① 新建一个脚本文件命名为ch-mount.sh,附代码如下:
  • <ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li>
    </li></ul><div class="blockcode"><blockquote><div class="Editable-unstyled" data-block="true" data-editor="2409i" data-offset-key="9rnb9-0-0" style="margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, " helvetica="" neue",="" "pingfang="" sc",="" "microsoft="" yahei",="" "source="" han="" sans="" "noto="" cjk="" "wenquanyi="" micro="" hei",="" sans-serif;="" letter-spacing:="" normal;="" text-align:="" start;="" white-space:="" pre-wrap;"=""><div data-offset-key="9rnb9-0-0" class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" style="max-width: 100%;"><span data-offset-key="9rnb9-0-1"><pre class="code-snippet__js" data-lang="bash" style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; outline: 0px; max-width: 1000%; overflow-x: auto; white-space: normal; flex: 1 1 0%; color: rgb(51, 51, 51); letter-spacing: 0.544px; text-align: justify; box-sizing: border-box !important;"><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__meta" style="outline: 0px; max-width: 1000%; color: rgb(175, 175, 175); box-sizing: border-box !important;">#!/bin/bash</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__keyword" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">function</span> <span class="code-snippet__function" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__title" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">mnt</span></span>() {</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"MOUNTING"</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">sudo mount -t proc /proc <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${2}</span>proc</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">sudo mount -t sysfs /sys <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${2}</span>sys</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">sudo mount -o <span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">bind</span> /dev <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${2}</span>dev</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">sudo chroot <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${2}</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">}</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__keyword" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">function</span> <span class="code-snippet__function" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__title" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">umnt</span></span>() {</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"UNMOUNTING"</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">sudo umount <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${2}</span>proc</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">sudo umount <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${2}</span>sys</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">sudo umount <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${2}</span>dev</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">}</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__keyword" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">if</span> [ <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"<span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">$1</span>"</span> == <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"-m"</span> ] && [ -n <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"<span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">$2</span>"</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">] ;</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">
    </span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__keyword" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">then</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">mnt <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">$1</span> <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">$2</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__keyword" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">elif</span> [ <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"<span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">$1</span>"</span> == <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"-u"</span> ] && [ -n <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"<span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">$2</span>"</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">];</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__keyword" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">then</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">umnt <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">$1</span> <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">$2</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__keyword" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">else</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">""</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"Either 1'st, 2'nd or both parameters were missing"</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">""</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"1'st parameter can be one of these: -m(mount) OR</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">-u(umount)"</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"2'nd parameter is the full path of rootfs</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;">directory(with trailing '/')"</span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">""</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">"For example: ch-mount -m /media/sdcard/"</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> <span class="code-snippet__string" style="outline: 0px; max-width: 1000%; color: rgb(221, 17, 68); box-sizing: border-box !important;">""</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> 1st parameter : <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${1}</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__built_in" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">echo</span> 2nd parameter : <span class="code-snippet__variable" style="outline: 0px; max-width: 1000%; color: rgb(14, 156, 229); box-sizing: border-box !important;">${2}</span></span></code><code style="outline: 0px; max-width: 1000%; text-align: left; white-space: pre; display: flex; position: relative; font-family: Consolas, " liberation="" mono",="" menlo,="" courier,="" monospace;="" box-sizing:="" border-box="" !important;"=""><span class="code-snippet_outer" style="outline: 0px; max-width: 1000%; box-sizing: border-box !important;"><span class="code-snippet__keyword" style="outline: 0px; max-width: 1000%; color: rgb(202, 125, 55); box-sizing: border-box !important;">fi</span></span></code></pre></span></div></div><div class="Editable-unstyled" data-block="true" data-editor="2409i" data-offset-key="9vg43-0-0" style="margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, " helvetica="" neue",="" "pingfang="" sc",="" "microsoft="" yahei",="" "source="" han="" sans="" "noto="" cjk="" "wenquanyi="" micro="" hei",="" sans-serif;="" letter-spacing:="" normal;="" text-align:="" start;="" white-space:="" pre-wrap;"=""><div data-offset-key="9vg43-0-0" class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" style="max-width: 100%;"><span data-offset-key="9vg43-0-0">
    </span></div></div><div class="Editable-unstyled" data-block="true" data-editor="2409i" data-offset-key="njen-0-0" style="margin-bottom: 1.4em; color: rgb(18, 18, 18); font-family: -apple-system, BlinkMacSystemFont, " helvetica="" neue",="" "pingfang="" sc",="" "microsoft="" yahei",="" "source="" han="" sans="" "noto="" cjk="" "wenquanyi="" micro="" hei",="" sans-serif;="" letter-spacing:="" normal;="" text-align:="" start;="" white-space:="" pre-wrap;"=""><div data-offset-key="njen-0-0" class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" style="max-width: 100%;"><span data-offset-key="njen-0-0" style="font-weight: bold;">② 设置这个shell脚本可执行权限</span><span data-offset-key="njen-0-1">,如下:</span></div></div><blockquote class="Editable-styled" data-block="true" data-editor="2409i" data-offset-key="1ofj1-0-0" style="margin-top: 1.4em; margin-bottom: 1.4em; border-left: 3px solid rgb(211, 211, 211); color: rgb(100, 100, 100); padding-left: 1em; font-family: -apple-system, BlinkMacSystemFont, " helvetica="" neue",="" "pingfang="" sc",="" "microsoft="" yahei",="" "source="" han="" sans="" "noto="" cjk="" "wenquanyi="" micro="" hei",="" sans-serif;="" letter-spacing:="" normal;="" text-align:="" start;="" white-space:="" pre-wrap;"=""><div data-offset-key="1ofj1-0-0" class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" style="max-width: 100%;"><span data-offset-key="1ofj1-0-0">sudo chmod 777 ch-mount.sh</span></div>


执行ch-mount.sh脚本 指定参数-m,挂载成功如下:

sudo ./ch-mount.sh -m ./




[



5. 安装软件

前面我们挂载了文件系统,已将文件系统挂载到了QEMU模拟器,接下来就可以安装我们所需要的软件了。

① 更新下载源:

apt update

注意:更新下载源可能会报错,这里需要注意一下,因为tmp文件夹权限不够,chmod为其赋予权限。

如下:

chmod 777 /tmp
② 安装软件:

至此,便可以安装所需软件了,在这里用apt-get安装自己所需软件,根据所需安装。我们这里来安装一个minicom串口测试工具。如下:







③ 安装完成后,exit退出QEMU。

④ 执行ch-mount.sh脚本卸载文件系统,指定参数-u,卸载成功后打印如下:








注意:我们exit退出后,只是退出了QEMU模拟器,并没有卸载文件系统,一定要执行脚本卸载文件系统。




6. 打包文件系统

① 完成前面的步骤后,用tar命令将当前文件夹下所有文件压缩,命名为OKT507-linux-ubuntu.tar.gz。如下:

sudo tar -cvzf OKT507-linux-ubuntu.tar.gz ./*



② 压缩完成后,为文件系统压缩包OKT507-linux-ubuntu.tar.gz赋予权限,如下:

sudo chmod a+w OKT507-linux-ubuntu.tar.gz







③ 将刚打包好的压缩包替换到上一级目录下的旧的文件系统压缩包。




[backcolor=rgba(18, 18, 18, 0.5)]​





④ 重新编译打包后生成新的镜像烧录开发板。









7. 测试方法

烧录到板子后,在终端启动minicom,验证下是否安装上。如下:







从上图红框可以看出,通过终端命令启动了minicom,说明我们在QEMU中安装成功了,至此Ubuntu文件系统定制就做完了。




通过这种方法可以个性化的定制属于自己文件系统,安装自己所需软件,也可以根据自己需求将出厂不需要的软件用相同的方式卸载掉,这样既能减少工作量,又利于批量化生产。


使用特权

评论回复

相关帖子

沙发
呐咯密密| | 2022-12-27 22:14 | 只看该作者
思路清晰,过程明了详细,写的真不错

使用特权

评论回复
板凳
yangjiaxu| | 2022-12-30 21:20 | 只看该作者
感觉现在的单片机都慢慢的往嵌入式,操作系统方面前进了,而且MCU和MPU都快分不清界限了

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

170

主题

172

帖子

0

粉丝