文章目录
- 一、开发环境
- 二、准备工作
-
- 1、需要的软件
- 2、ubuntu core版本
- 三、配置 ubuntu
-
- 1、配置准备
- 2、安装 qemu 模拟器
- 3、iMX6Q Ubuntu14.04系统 配置 网络
- 4、iMX6Q Ubuntu14.04系统 配置 下载软件镜像源
- 5、模拟登陆 iMX6Q Ubuntu14.04 系统
-
- ①、创建模拟登陆脚本
- ②、模拟登陆 iMX6Q Ubuntu14.04 系统
- 6、iMX6Q Ubuntu14.04 系统 安装软件
-
- ①、更新源
- ②、下载软件
- 7、iMX6Q Ubuntu14.04 系统 用户配置
-
- ①、设置root密码
- ②、设置主机名称
- ③、设置本机IP
- 8、iMX6Q Ubuntu14.04 系统 配置 调试串口
- 9、iMX6Q Ubuntu14.04 系统 配置 网络dhcp
- 10、iMX6Q Ubuntu14.04 系统 完成配置
- 四、制作 iMX6Q Ubuntu14.04 文件系统
-
- 1、进入rootfs目录
- 2、制作文件系统
一、开发环境
开发环境:Ubuntu14.04
开发平台:iMX6Q
内核版本:4.14.98
二、准备工作
1、需要的软件
ubuntu core 官方下载传送门
Ubuntu一个以桌面应用为主的开源GNU/Linux操作系统,ubuntu core是最小Ubuntu核心
Ubuntu官方提供了不同版本的ubuntu core,可以根据需要下载、移植。
选择版本下载的时候下载后缀是 core-armhf
选择版本下载的时候下载后缀是 core-armhf
选择版本下载的时候下载后缀是 core-armhf
2、ubuntu core版本
在这里我选择了Ubuntu14.04.6
ubuntu-base-14.04.6-base-armhf.tar.gz
三、配置 ubuntu
1、配置准备
新建文件夹存放 ubuntu core
mkdir ~/rootfs
拷贝 ubuntu core
cp /media/sf_share/6q/ubuntu/ubuntu-base-14.04.6-base-armhf.tar.gz ~/
解压 ubuntu core 到 rootfs
sudo tar xvf ubuntu-base-14.04.6-base-armhf.tar.gz -C rootfs/
进入rootfs查看文件
2、安装 qemu 模拟器
qemu 模拟器:
可扩展,可自定义新的指令集
开源,可移植,仿真速度快
在支持硬件虚拟化的x86构架上可以使用KVM加速配合内核ksm大页面备份内存,速度稳定远超过VMware ESX
增加了模拟速度,某些程序甚至可以实时运行
可以在其他平台上运行Linux的程序
可以储存及还原运行状态(如运行中的程序)
可以虚拟网络卡
qemu模拟器主要作用是:在主机的Ubuntu上 模拟登陆 要移植的 Ubuntu。
在模拟器上,运行的ubuntu系统,可以使用各种 Ubuntu命令来安装需要的软件。
sudo apt-get install qemu-user-static
拷贝 qemu-arm-static 到 ubuntu core 的 usr/bin/
sudo cp /usr/bin/qemu-arm-static ~/rootfs/usr/bin/
3、iMX6Q Ubuntu14.04系统 配置 网络
为了制作成功的根文件系统能够联网,可以直接拷贝本机的dns配置文件到根文件系统的相应位置
拷贝主机的 resolv.conf 到 ubuntu core的 etc 目录
sudo cp /etc/resolv.conf ~/rootfs/etc/
这一步不做的话会上不了网!!!
这一步不做的话会上不了网!!!
这一步不做的话会上不了网!!!
4、iMX6Q Ubuntu14.04系统 配置 下载软件镜像源
配置我们制作的 iMX6Q Ubuntu14.04系统 下载软件镜像源。
在这里我修改为清华软件镜像源,也可以直接使用默认的。
sudo vim ~/rootfs/etc/apt/sources.list
这是原本的默认配置
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted## Major bug fix updates produced after the final release of the
## distribution.
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty universe
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://ports.ubuntu.com/ubuntu-ports/ trusty multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates multiverse## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-backports main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-backports main restricted universe multiverse## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu trusty partner
# deb-src http://archive.canonical.com/ubuntu trusty partnerdeb http://ports.ubuntu.com/ubuntu-ports/ trusty-security main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-security universe
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-security universe
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-security multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-security multiverse
只要将ubuntu改成ubuntu-ports即可。阿里软件镜像源、中科大软件镜像源、以及其他软件镜像源都可以这样改。
选择其中一个就可以了,在这里我选了中科大软件镜像源
1、Ubuntu14.04系统 ARM 中科大软件镜像源
# icedustpan
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports trusty-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ trusty-updates main multiverse restricted universe
2、Ubuntu14.04系统 ARM 清华软件镜像源
# icedustpan
deb http://mirrors.mit.edu/ubuntu-ports/ trusty main restricted universe multiverse
deb http://mirrors.mit.edu/ubuntu-ports/ trusty-updates main restricted universe multiverse
deb http://mirrors.mit.edu/ubuntu-ports/ trusty-security main restricted universe multiverse
deb http://mirrors.mit.edu/ubuntu-ports/ trusty-backports main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu-ports/ trusty main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu-ports/ trusty-updates main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu-ports/ trusty-security main restricted universe multiverse
deb http://mirror.csclub.uwaterloo.ca/ubuntu-ports/ trusty-backports main restricted universe multiverse
5、模拟登陆 iMX6Q Ubuntu14.04 系统
在这里使用模拟器登录 iMX6Q Ubuntu14.04 系统
①、创建模拟登陆脚本
在 rootfs 上一级目录 创建模拟登陆脚本
我的 iMX6Q Ubuntu14.04 系统文件 是放在 ~/rootfs/
所以我的 rootfs 上一级目录 就是主目录 ~
vim ~/ch-mount.sh
脚本内容
#!/bin/bashfunction mnt() {
echo "MOUNTING"sudo mount -t proc /proc ${
2}procsudo mount -t sysfs /sys ${
2}syssudo mount -o bind /dev ${
2}devsudo chroot ${
2}
}function umnt() {
echo "UNMOUNTING"sudo umount ${
2}procsudo umount ${
2}syssudo umount ${
2}dev}if [ "$1" == "-m" ] && [ -n "$2" ] ;
thenmnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
thenumnt $1 $2
elseecho ""echo "Either 1'st, 2'nd or both parameters were missing"echo ""echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"echo ""echo "For example: ch-mount -m /media/sdcard/"echo ""echo 1st parameter : ${
1}echo 2nd parameter : ${
2}
fi
增加可执行权限
chmod +x ch-mount.sh
②、模拟登陆 iMX6Q Ubuntu14.04 系统
1、rootfs 这个是我存放 iMX6Q Ubuntu14.04 系统文件 的目录
2、-m 创建home目录 (不加这个要手动添加目录,不然开机时,会出现No directory,Logging in with HOME=/ )
3、rootfs 改成自己存放 Ubuntu系统文件的目录
./ch-mount.sh -m rootfs/
成功模拟登陆 iMX6Q Ubuntu14.04 系统
6、iMX6Q Ubuntu14.04 系统 安装软件
①、更新源
apt-get update
②、下载软件
这里根据自己的需求去下载就好了
这是我下载的软件:
apt-get install sudo sudo命令
apt-get install vim vim编辑器
apt-get install net-tools ifconfig,netstat,route,arp等
apt-get install dhcpcd5 dhcp服务
apt-get install iputils-ping ping和ping6
apt-get install wireless-tools iwconfig等,显示、修改无线设置
apt-get install htop htop工具,交互式进程查看器
apt-get install rsyslog 系统log服务
apt-get install network-manager Network Manager服务和框架,高级网络管理
apt-get install ifupdown ifup,ifdown等工具
apt-get install ethtool ethtool命令,显示、修改以太网设置
一键安装全部命令:
apt-get install sudo vim net-tools dhcpcd5 iputils-ping wireless-tools htop rsyslog network-manager ifupdown ethtool
7、iMX6Q Ubuntu14.04 系统 用户配置
①、设置root密码
passwd root
②、设置主机名称
echo "i.MX6Q" > /etc/hostname
③、设置本机IP
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.1.1 i.MX6Q" >> /etc/hosts
8、iMX6Q Ubuntu14.04 系统 配置 调试串口
我用的是iMX6Q,iMX平台默认调试串口是ttymxc0
需要在 etc/init 下面创建一个 ttymxc0.conf 文件
sudo vim ~/rootfs/etc/init/ttymxc0.conf
ttymxc0.conf 里面填写以下代码
# ttymxc0 - getty
# icedustpan
# This service maintains a getty on ttymxc0 from the point the system is
# started until it is shut down again.start on stopped rc RUNLEVEL=[2345] and (not-container orcontainer CONTAINER=lxc orcontainer CONTAINER=lxc-libvirt)stop on runlevel [!2345]respawn
exec /sbin/getty -8 115200 ttymxc0
然后需要在etc/rc.local
sudo vim ~/rootfs/etc/rc.local
加上
start ttymxc0
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.start ttymxc0
exit 0
9、iMX6Q Ubuntu14.04 系统 配置 网络dhcp
配置DHCP,可以烧录到开发板之后在配置,但启动时会慢一点。
echo auto eth0 > /etc/network/interfaces.d/eth0
echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0
使能配置DHCP
/etc/init.d/networking restart
10、iMX6Q Ubuntu14.04 系统 完成配置
现在我们退出模拟登录的iMX6Q Ubuntu14.04 系统
退出退出chroot
exit
用脚本载缷载退出 模拟登录 文件系统
./ch-mount.sh -u rootfs/
现在已经退出模拟登录的iMX6Q Ubuntu14.04 系统
四、制作 iMX6Q Ubuntu14.04 文件系统
1、进入rootfs目录
cd ~/rootfs/
2、制作文件系统
因为iMX平台的文件系统是默认.bz2格式的
所以压缩生成.bz2格式的文件系统
sudo tar jcvf imx6q-ubuntu14.04.tar.bz2 *
接下来把这个文件系统烧录进去就行了
使用uuu工具烧录系统