Ubuntu-Base 18 文件系统 在iMX8平台上的移植
开发板是如下的型号
OKMX8MPX-C V2.0
OKMX8PQ-C开发板
FETMX8MPX-C V1.0
在 飞凌 提供的 ubuntu虚拟机里面搭建环境:
步骤如下:
mkdir /home/forlinx/work/ubuntu-core
cd /home/forlinx/work/ubuntu-core/
进入如下网址:
http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/
下载 如下 文件 :
ubuntu-base-18.04.5-base-arm64.tar.gz
mkdir /home/forlinx/work/ubuntu-core/ubuntu-base
cd /home/forlinx/work/ubuntu-core/
tar xvf ubuntu-base-18.04.5-base-arm64.tar.gz -C ubuntu-base/
sudo apt install qemu-user-static -y
执行 :
cd /home/forlinx/work/ubuntu-core/ubuntu-base
sudo cp /usr/bin/qemu-arm-static usr/bin/
sudo cp /usr/bin/qemu-aarch64-static usr/bin/
这样是为了防止出现如下错误:
chroot: failed to run command ‘/bin/bash’: No such file or directory
接着创建文件:
cd /home/forlinx/work/ubuntu-core
vi ch-mount.sh
#!/bin/bash
function mnt() {
echo "MOUNTING"
sudo mount -t proc /proc ${2}proc
sudo mount -t sysfs /sys ${2}sys
sudo mount -o bind /dev ${2}dev
sudo mount -o bind /dev/pts ${2}dev/pts
sudo chroot ${2}
}
function umnt() {
echo "UNMOUNTING"
sudo umount ${2}proc
sudo umount ${2}sys
sudo umount ${2}dev/pts
sudo umount ${2}dev
}
if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
umnt $1 $2
else
echo ""
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 777 ch-mount.sh
准备工作:
因为Ubuntu-Base默认的apt安装源是官网源,速度比较慢,我们将其换为国内源,我习惯中科大源(mirrors.ustc.edu.cn),所以执行sed命令更换,注意路径
cd /home/forlinx/work/ubuntu-core/ubuntu-base
sed -i ‘s|ports.ubuntu.com|mirrors.ustc.edu.cn|g’ ./etc/apt/sources.list
此时的文件系统里面还没有设置dns服务器,直接进去会无法解析域名,所以将开发机的DNS配置文件复制进去
cp /etc/resolv.conf ./etc/resolv.conf
然后执行:
cd /home/forlinx/work/ubuntu-core
./ch-mount.sh -m ubuntu-base/
./ch-mount.sh -m ubuntu-base/
echo "larry-imx8mm" > /etc/hostname
echo "127.0.0.1 localhost" > /etc/hosts
echo "127.0.0.1 larry-imx8mm" >> /etc/hosts
chmod 777 /tmp
apt update
apt install language-pack-en-base sudo ssh net-tools network-manager iputils-ping rsyslog bash-completion htop resolvconf dialog vim nano v4l-utils alsa-utils git gcc less resolvconf autoconf autopoint libtool bison flex gtk-doc-tools glib-2.0 libglib2.0-dev libpango1.0-dev libatk1.0-dev kmod pciutils -y
passwd root
exit
./ch-mount.sh -u ubuntu-base/
如果在apt update的时候出现Couldn’t create temporary file(无法创建临时文件)的错误,将/tmp路径权限设为777之后重试即可
chmod 777 /tmp
如果不执行 apt install …那些指令
会出现如下错误:
/bin/sh: 0: can’t access tty; job control turned off
随后输入exit指令退出Ubuntu-Base文件系统,再使用ch-mount.sh脚本卸载proc、sys、dev、dev/pts文件系统即可。
到这里Ubuntu-Base文件系统的移植就算是完成了,将配置好的文件系统、内核和BootLoader一起烧录进开发板即可。
Ubuntu 18.04 永久修改DNS的方法
修改 :
sudo vim /etc/systemd/resolved.conf
[Resolve]
DNS=192.168.99.1
DNS=8.8.8.8
执行完之后 ,nfs服务器 ():
sudo vi /etc/exports
/nfs_rootfs 192.168.99.*(rw,sync,no_root_squash,no_subtree_check)
/home/forlinx/nfs_rootfs 192.168.99.*(rw,sync,no_root_squash,no_subtree_check)
/home/forlinx/work/ubuntu-core/ubuntu-base 192.168.99.*(rw,sync,no_root_squash,no_subtree_check)
sudo exportfs -rv
sudo /etc/init.d/rpcbind restart
sudo /etc/init.d/nfs-kernel-server restart
uboot 环境变量
(ctrl+shift +insert 插入 ubuntu putty)
setenv ipaddr 192.168.99.53
setenv serverip 192.168.99.50
setenv image Image
setenv fdt_file OK8MP-C.dtb
setenv netargs setenv bootargs console=ttymxc1,115200 root=/dev/nfs rw ip=192.168.99.53:192.168.99.50:192.168.99.1:255.255.255.0::eth0:off nfsroot=192.168.99.50:/home/forlinx/work/ubuntu-core/ubuntu-base,v3,tcp
setenv netboot 'run netargs; tftpboot ${loadaddr} ${image}; tftpboot ${fdt_addr} ${fdt_file}; booti ${loadaddr} - ${fdt_addr}'
saveenv
run netboot
通过uboot 命令行 , run netboot是 通过 nfs启动
默认启动还是从mmc启动。
进入系统之后,
可以执行的命令为:
ping www.baidu.com
apt search python3.8
ping www.baidu.com
可以用
参考文档:
Ubuntu-Base在iMX8MM平台上的移植
qemu仿真二进制文出现chroot: failed to run command XXX
chroot 是 qemu的一个命令
Ubuntu-Base在iMX8MM平台上的移植
https://larryz.blog.csdn.net/article/details/113035997
qemu+chroot构建arm aarch64虚拟机
http://t.zoukankan.com/objectDetect-p-7614066.html
进入如下网址:
http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/
/home/forlinx/work/ubuntu-core/
ubuntu-base-18.04.5-base-arm64.tar.gz
tar xvf ubuntu-base-18.04.5-base-arm64.tar.gz -C ubuntu-base/
/home/forlinx/work/ubuntu-core/ubuntu-base/
sudo apt install qemu-user-static -y
chroot: failed to run command ‘/bin/bash’: No such file or directory
/home/forlinx/work/ubuntu-core/ubuntu-base