Ubuntu 模拟ARM开发环境

为了简化开发和测试过程,Ubuntu从9.10开始提供静态的ARM虚拟功能,可以直接在PC机上建立ARM机器的chroot环境,既可以编译,也可以测试程序。相比于交叉编译而言,这种方法虽然编译速度较慢,但配置方便,还具备直接调试的功能。

先安装Ubuntu提供的ARM虚拟程序:

1sudo apt-get install qemu-arm-static debootstrap

接着,使用build-arm-chroot命令建立chroot系统:

1build-arm-chroot karmic eabi-chroot

国内用户可以考虑使用srt.cn的镜像以加快速度:

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

建立chroot环境的脚本:

1#!/bin/bash
2DROOT=eabi-chroot的完整路径
3mount --bind /dev $DROOT/dev
4mount --bind /proc $DROOT/proc
5mount --bind /sys $DROOT/sys
6mount --bind /dev/pts $DROOT/dev/pts
7cp /etc/resolv.conf $DROOT/etc/resolv.conf
8chroot $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。

解决办法:

1#mountall
2# dpkg --force-all -i /var/cache/apt/archives/mount_2.XX.X-0Ubuntu1_i386.deb
3# apt-get -f install
4# apt-get -V dist-upgrade

在终端输入:exit 退出模拟arm开发环境。然后按顺序卸载刚才挂载的目录。

建立退出chroot环境脚本:

1#!/bin/bash
2#exit the Ubuntu arm
3#umount the directory of eabi-chroot
4
5DROOT=/eabi-chroot
6umount -l $DROOT/dev/pts
7umount -l $DROOT/sys
8umount -l $DROOT/proc
9umount -l $DROOT/dev
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值