通過三大服務的配置,我們可以在ARM中下載內核和文件系統。我們通過在虛擬機中編程,得到的程序不能在ARM中運行,需要經過一個交叉編譯。得到的可執行程序可以在ARM中運行,此時不能在虛擬機Linux中運行。
1、將工具鏈拷貝到/opt下,解壓(此/opt在samba中配置成共享文件夾)
sudo tar -xvf toolchain-4.5.1-farsight.tar.bz2
2、進入目錄:toolchain-4.5.1-farsight/bin
cd toolchain-4.5.1-farsight/bin
3、執行pwd后,復制下面的路徑
/opt/toolchain-4.5.1-farsight/bin
4、在環境變量中增加工具鏈路徑(注意:增加環境變量的時候不能刪掉其它的環境變量,不然會造成其它程序不能運行。)
sudo vi /etc/environment
加入 :/opt/toolchain-4.5.1-farsight/bin(接在引號后面),保存退出
5、使生效:
source /etc/environment
查看效果: arm ,之后,雙擊TAB!
測試:
1、編寫hello.c
#include <stdio.h>
int main(void)
{
printf("hello world\n");
return 0;
}
2、交叉編譯:
arm-none-linux-gnueabi-gcc -o arm_hello hello.c
3、拷貝到/opt/rootfs
cp arm_hello /opt/rootfs
4、在開發板中執行:
[root@farsight /]# ./arm_hello