qemu-arm-static
嵌入式開發有時會在ARM設備上使用ubuntu文件系統。開發者常常會面臨這樣一個問題,想預先交叉編譯并安裝一些應用程序,但是交叉編譯的環境配置以及依賴包的安裝十分繁瑣,并且容易出錯。想直接在目標板上進行編譯和安裝,但是ARM的資源和處理能力有限,會非常耗費時間。在這里給大家推薦一個ubuntu下好用的工具qemu-arm-static,這是QEMU用戶模式下的ARM仿真器。
通過qemu-arm-static,我們在x86的ubuntu PC機上,可以模擬ARM處理器,就像運行在ARM上一樣進行各種操作。這樣既實現了ARM環境,又利用了x86 PC的處理能力。
安裝使用
首先要確保在x86 ubuntu上使用root權限。
安裝
apt install qemu-user-static
1
下載ubuntu arm文件系統并解壓
wget http://cdimage.ubuntu.com/ubuntu-base/releases/xenial/release/ubuntu-base-16.04.6-base-armhf.tar.gz
mkdir rootfs
tar zxvf ubuntu-base-16.04.6-base-armhf.tar.gz -C rootfs/
1
2
3
配置
cp /usr/bin/qemu-arm-static rootfs/usr/bin/
cp /etc/resolv.conf rootfs/etc/resolv.conf (確保網絡可用)
mount -t proc /proc rootfs/proc
mount -t sysfs /sys rootfs/sys
mount -o bind /dev rootfs/dev
1
2
3
4
5
chroot
切換root路徑,進入ARM環境。此時你就可以當成OS和ubuntu真的運行在ARM處理器上了,做你想做的事情。
chroot rootfs
uname -a
Linux OptiPlex 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 armv7l armv7l armv7l GNU/Linux
1
2
3
qarm
上面的配置和使用方法是不是多少有些繁瑣。我個人寫了一個tool可以更加方便的使用qemu-arm-static,叫qarm。
git clone https://github.com/yangbolu1991/qarm.git
cd qarm
cp qarm /usr/sbin
————————————————
? ? ? ? ? ? ? ? ? ? ? ? ? ? 版權聲明:本文為博主原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。
? ? ? ? ? ? ? ? ? ? ? ??
原文鏈接:https://blog.csdn.net/yanceylu/article/details/108570423