歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 模擬ARM開發環境

Ubuntu 模擬ARM開發環境

日期:2017/2/28 16:07:10   编辑:Linux教程

為了簡化開發和測試過程,Ubuntu從9.10開始提供靜態的ARM虛擬功能,可以直接在PC機上建立ARM機器的chroot環境,既可以編譯,也可以測試程序。相比於交叉編譯而言,這種方法雖然編譯速度較慢,但配置方便,還具備直接調試的功能。

先安裝Ubuntu提供的ARM虛擬程序:

sudo apt-get install qemu-arm-static debootstrap

接著,使用build-arm-chroot命令建立chroot系統:

build-arm-chroot karmic eabi-chroot

國內用戶可以考慮使用srt.cn的鏡像以加快速度:

build-arm-chroot karmic eabi-chroot http://ubuntu.srt.cn/ubuntu-ports/

建立chroot環境的腳本:

#!/bin/bash
DROOT=eabi-chroot的完整路徑
mount --bind /dev $DROOT/dev
mount --bind /proc $DROOT/proc
mount --bind /sys $DROOT/sys
mount --bind /dev/pts $DROOT/dev/pts
cp /etc/resolv.conf $DROOT/etc/resolv.conf
chroot $DROOT

chroot成功後,就進入了模擬arm開發環境。

使用 uname -a

可以觀察到架構的變化。此後,新建或修改/etc/apt/sources.list,

在/etc/apt/sources.list中添加如下內容:

deb http://ports.ubuntu.com/ lucid main restricted universe multiverse
deb-src http://ports.ubuntu.com/ lucid main restricted universe multiverse

然後在終端輸入 apt-get update更新之後,就可以按需裝軟件、開發程序了。

在更新時出現如下錯誤信息:
E: Internal Error, Could not perform immediate configuration (2) on mountall。

解決辦法:
#mountall
# dpkg --force-all -i /var/cache/apt/archives/mount_2.XX.X-0ubuntu1_i386.deb
# apt-get -f install
# apt-get -V dist-upgrade

在終端輸入:exit 退出模擬arm開發環境。然後按順序卸載剛才掛載的目錄。

建立退出chroot環境腳本:

#!/bin/bash
#exit the ubuntu arm
#umount the directory of eabi-chroot

DROOT=/eabi-chroot
umount -l $DROOT/dev/pts
umount -l $DROOT/sys
umount -l $DROOT/proc
umount -l $DROOT/dev

Copyright © Linux教程網 All Rights Reserved