Ubuntu 模擬ARM開發環境

2021-06-20 00:46:52 字數 2491 閱讀 5223

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

先安裝ubuntu提供的arm虛擬程式:

1

sudoapt-getinstallqemu-arm-static debootstrap

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

1

build-arm-chroot karmic eabi-chroot

國內使用者可以考慮使用srt.cn的映象以加快速度:

build-arm-chroot karmic eabi-chroot

建立chroot環境的指令碼:

1

#!/bin/bash

2

droot=eabi-chroot的完整路徑

3

mount--bind /dev $droot/dev

4

mount--bind /proc $droot/proc

5

mount--bind /sys $droot/sys

6

mount--bind /dev/pts $droot/dev/pts

7

cp/etc/resolv.conf $droot/etc/resolv.conf

8

chroot $droot

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

使用    uname -a

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

在/etc/apt/sources.list中新增如下內容:

deb lucid main restricted universe multiverse

deb-src 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

5

droot=/eabi-chroot

6

umount-l $droot/dev/pts

7

umount-l $droot/sys

8

umount-l $droot/proc

9

umount-l $droot/dev

Ubuntu上模擬ARM開發環境

有乙個很明確的方向是我需要乙個arm版本的ubuntu系統,編譯一些arm平台庫是十分方便的,其實這方面是有經驗的,之前使用rk3188主機板執行ubuntu,編譯一些庫極為容易,至少依賴問題很好解決。而不再像兩年前那樣只使用乙個交叉工具鏈來編譯乙個庫,需要順帶編譯很多依賴庫。最終還是採用了乙個ar...

構建arm開發環境

規劃 交叉編譯器裝在 usr local kernel,bootloder放在 home volans arm 用於啟動的nfs檔案系統放在 home armnfs 準備工作 sudo mkdir home armnfs sudo chmod 777 home armnfs mkdir arm 上面...

構建arm開發環境

規劃 交叉編譯器裝在 usr local kernel,bootloder放在 home volans arm 用於啟動的nfs檔案系統放在 home armnfs 準備工作 sudo mkdir home armnfs sudo chmod 777 home armnfs mkdir arm 上面...