在imx6q上移植ubuntu16.04系统

在i.MX6q上移植UBUNTU 16.04系统步骤:

1.下载根文件系统

cd ~/UbuntuDev/

mkdir rootfs

cd rootfs

wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04-core-armhf.tar.gz

在imx6q上移植ubuntu16.04系统_第1张图片

    下载完后,解压到ubuntu目录:

mkdir ubuntu

sudo tar -xpf ubuntu-base-16.04-core-armhf.tar.gz -C ubuntu

http://dev.t-firefly.com/data/attachment/forum/201609/29/142515wkxz08mxqpcsz8xm.png

    解压后,可以ls看看,这就是最小化的ubuntu根文件系统,可以直接用来生成镜像,但里面基本是要啥没啥。如何可以预置一些程序呢,如vim,openssh-server,git什么的工具。办法是有的:在PC里模拟运行这个根文件系统,运行后安装配置一些需要预置的程序,再把此根文件系统打包成固件。

2.安装qemu-user-static工具

sudo apt-get install qemu-user-static

拷贝qemu-arm-static到刚刚解压出来的目录

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

3.网络配置

$ sudo cp /etc/resolv.conf ./etc/resolv.conf

打开文件直接在下面添加

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

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

 

4.为了制作成功的根文件系统能够联网,可以直接拷贝本机的dns配置文件到根文件系统的相应位置,

$ sudo cp /etc/resolv.conf ./etc/resolv.conf

 

5. 为了简化操作过程,这里使用一个切换根文件系统的脚本,点击下载:https://pan.baidu.com/s/1pLo36jD?errno=0&errmsg=Auth%20Login%20Sucess&&bduss=&ssnerror=0&traceid=。下载后,拷贝到~/UbuntuDev/rootfs目录,并增加可执行权限。用脚本挂载切换到指定的根文件系统,命令为:

挂载过程的bash脚本内容:

cd ~/UbuntuDev/rootfs

chmod +x ch-mount.sh

./ch-mount.sh -m ubuntu/

Shell脚本内容如下:

    #!/bin/bash

    echo "MOUNTING"

    sudo mount -t proc /proc /home/phy/image/debian-rootfs/proc

    sudo mount -t sysfs /sys /home/phy/image/debian-rootfs/sys

    sudo mount -o bind /dev /home/phy/image/debian-rootfs/dev

    sudo mount -o bind /dev/pts /home/phy/image/debian-rootfs/dev/pts       

    sudo chroot /home/phy/image/debian-rootfs/

 

卸载过程的bash脚本内容:

 

    #!/bin/bash

    echo "UNMOUNTING"

    sudo umount /home/phy/image/debian-rootfs/proc

    sudo umount /home/phy/image/debian-rootfs/sys

    sudo umount /home/phy/image/debian-rootfs/dev/pts

sudo umount /home/phy/image/debian-rootfs/dev

在imx6q上移植ubuntu16.04系统_第2张图片

可以看到执行后,终端显示的用户名发生了变化,用ls可以看到文件系统也有变化,此终端里的根文件系统已经切换到binary目录里的根文件系统。可以在终端里做安装程序等操作了,就像进入了一个新系统,所以我也叫作是模拟运行根文件系统。

 

 

6.安装软件

 

首先更新源

apt update

 

更新完成,安装必要软件,这个根据需求安装就可以了。

 

    apt install sudo

    apt install language-pack-en-base

    apt install ssh

    apt install net-tools

    apt install ethtool

    apt install ifupdown

    apt install iputils-ping

    apt install rsyslog

    apt install htop

apt install vi 

7.用户配置

设置root密码

passwd root

创建用户

adduser phy(用户名)

 

设置主机名称和本机IP

 

    echo "i.MX6" > /etc/hostname

    echo "127.0.0.1 localhost" >> /etc/hosts

    echo "127.0.1.1 i.MX6" >> /etc/hosts

8.配置串口和网络dhcp

首先配置串口,下载到板子上以后发现串口无法输出到超级终端,找了很多方案,终于试出来了,需要做一个链接才行。

ln -s /lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected]

由于我用的是i.mx6q的平台,需要添加一个名为[email protected]的链接,连接到[email protected]服务。i.mx的平台是ttymxc0,其他平台的名字就不清楚了。如果确定不了名字,一个比较笨的方法就是先把制作好的根文件系统下载到开发板上,超级终端上查看打印出来的log,会在 waiting for device dev-ttymxc0.device 时出现 [Time out] ,Dependency failed for Serial Getty on ttymxc0. 由此就可以知道了。

配置DHCP,也可以等下载到开发板之后在配置,但启动时会很慢。

·  echo auto eth0 > /etc/network/interfaces.d/eth0
·  echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0
·  /etc/init.d/networking restart

退出根文件系统:

exit

http://dev.t-firefly.com/data/attachment/forum/201609/29/142519p5r3b65armhrab5b.png

用脚本载缷载退出根文件系统:

./ch-mount.sh -u ubuntu/

http://dev.t-firefly.com/data/attachment/forum/201609/29/142519h36frmfofr4oihfv.png

8.制作镜像

进入到根文件系统目录

cd ubuntu目录
执行./build.sh将该文件压缩成 rootfs.tar.bz2

将压缩成的文件拷贝到烧写目录进行烧写

在imx6q上移植ubuntu16.04系统_第3张图片

重启,成功进入ubunt系统

参考文献:https://blog.csdn.net/sinat_37141443/article/details/80882219

http://dev.t-firefly.com/thread-10963-1-1.html

多谢两位前辈的参考文档,现结合自己的开发平台总结如上。

你可能感兴趣的:(系统移植)