https://blog.csdn.net/yanceylu/article/details/108570423
嵌入式开发有时会在ARM设备上使用ubuntu文件系统。开发者常常会面临这样一个问题,想预先交叉编译并安装一些应用程序,但是交叉编译的环境配置以及依赖包的安装十分繁琐,并且容易出错。想直接在目标板上进行编译和安装,但是ARM的资源和处理能力有限,会非常耗费时间。在这里给大家推荐一个ubuntu下好用的工具qemu-arm-static,这是QEMU用户模式下的ARM仿真器。
通过qemu-arm-static,我们在x86的ubuntu PC机上,可以模拟ARM处理器,就像运行在ARM上一样进行各种操作。这样既实现了ARM环境,又利用了x86 PC的处理能力
- Install 18.04 base
$ mkdir ~/rootfs && cd ~/rootfs
$ wget http://cdimage.ubuntu.com/ubuntu-base/releases/18.04.2/release/ubuntu-
base-18.04.2-base-arm64.tar.gz
$ mkdir ubuntu-rootfs
$ tar -xvf ubuntu-base-18.04.2-base-arm64.tar.gz -C ubuntu-rootfs
$ cd ubuntu-rootfs
$ ls
4.Install qemu-user-static on PC to simulate arm64 environment
$ apt-get install qemu-user-static
$ cp /usr/bin/qemu-aarch64-static usr/bin
$ cp -b /etc/resolv.conf etc/
5.Simulate arm64 environment
$ cd ../
$ vi ch-mount.sh
(copy the content to 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
(chroot to arm64 filesystem)
$ ./ch-mount.sh -m ubuntu-rootfs/
6.Install package and configuration
# chmod 777 tmp
#echo nameserver 8.8.8.8 > /etc/resolv.conf or #echo nameserver 8.8.4.4 > /etc/resolv.conf
# apt-get update
Install package you need
apt-get install \
language-pack-en-base \
sudo \
ssh \
net-tools \
network-manager \
iputils-ping \
rsyslog \
bash-completion \ htop \
resolvconf \
dialog \
vim
apt-get install 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
- Add user
$ useradd -s '/bin/bash' -m -G adm,sudo yourusername
$ echo "Set password for yourusername:"
$ passwd yourusername
$ echo "Set password for root:"
$ passwd root
3) Set host name
$ echo 'ubuntu.yourusername' > /etc/hostname
8.Configure the serial port
$ sudo cp -ra /home/sk/bld_server2/users/skamiya/yocto/L4.14.98/imx-yocto-bsp-
ft/build-8qxpmek-xwayland/tmp/work/imx8qxpmek-poky-linux/systemd-
serialgetty/1.0-r5/image/* ubuntu-rootfs/
|