Linux下基於eclipse的arm開發環境的建立

來源:互聯網
上載者:User

這是我參考了網上的很多資料後,修改並驗證的,有一定的參考意義。不一定面面俱到,因為有的地方說多了就顯得有點囉嗦,要是還有疑問就給我留言我儘力解答。 

1、安裝redhat9,(可以用迅雷下,速度還不錯),不一定非得用完整安裝,將開發包都裝上就可以了,vsftp也要裝,這樣大概 需要1.6g左右的空間, 這裡設定主機ip:192.168.0.3,開發板ip:192.168.0.2

ps:我在ubuntu上就怎麼也編譯不出開發板能用的程式,非得用RedHat9才行,很鬱悶!

2、在vmware上,把vmware-tools也裝上

3、用近端分享
 mount -t smbfs -o username=張劍,password="" //swordzjj/nano2410 /root/.gnome-desktop/nano/

4、把Nano2410AV2-SDK10.tgz和arm-linux-toolchains.tgz拷到/tmp上
 tar xvzf Nano2410AV2-SDK10.tgz –C /
 tar xvzf arm-linux-toolchains.tgz -C /
 
5、安裝JRE1.5.0
 ./jre-1_5_10-linux-i586-rpm.bin
 
6、安裝eclipse 3.2、cdt、漢化包
 tar zxvf eclipse-SDK-3.2.1-linux-gtk.tar.gz -C /opt
 tar zxvf org.eclipse.cdt-3.1.1-linux.x86.tar.gz -C /opt
 NLpack1-eclipse-SDK-3.2.1-gtk.zip /opt
 
7、安裝firefox-2.0
 tar zxvf firfox-2.0.0.1.tar -C /opt

8、安裝AdobeReader
 rpm -i AdobeReader_chs-7.0.0-2.i386.rpm

9、更新環境變數
vi /etc/profile,
# Path manipulation
if [ `id -u` = 0 ]; then
 pathmunge /sbin
 pathmunge /usr/sbin
 pathmunge /usr/local/sbin
 pathmunge /usr/local/arm/2.95.3/bin
 pathmunge /usr/java/jre1.5.0_10/bin
fi

vi /etc/exports
在最後加上:/opt/FriendlyARM/Nano2410A_v2/root_nfs *(rw,sync,no_root_squash)
/opt/FriendlyARM/Nano2410A_V2/root_nfs是代表要作為Nano2410A_v2的根檔案系統的共用目錄;*代表所有的客戶機都可以掛接此檔案系統目錄;rw代表客戶機以讀寫許可來掛接它們的根檔案系統;no_root_squash選項允許客戶機以主機上的root身份掛接根檔案系統。
開啟/etc/rc.local檔案,在檔案後面增加一行“/etc/init.d/nfs start”,以使開機後自動
啟動NFS服務,你也可以運行如下命令啟動、停止或重啟NFS服務:
#/etc/init.d/nfs start
#/etc/init.d/nfs stop
#/etc/init.d/nfs restart
登出後重新登陸就可以了

10、建立捷徑

Eclipse的捷徑

把eclipse目錄下的eclipse.xpm先拷到/usr/share/icons
[Desktop Entry]
Encoding=UTF-8
Name=Eclipse 3.2
GenericName[zh_CN]=Eclipse
Comment=Eclipse
Exec=/opt/eclipse/eclipse %u
Icon=eclipse.xpm
Terminal=false
Type=Application
StartupWMClass=Eclipse
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;
Categories=TextEditor;Development;X-Red-Hat-Base;Application;

firefox的捷徑

把firefox\icons\mozicon128.png先拷到/usr/share/icons/firefox.png
[Desktop Entry]
Encoding=UTF-8
Name=Firefox Web Browser 2
GenericName[zh_CN]=firefox
Comment=Firefox web browser
Exec=/opt/firefox/firefox %u
Icon=firefox.png
Terminal=false
Type=Application
StartupWMClass=Firefox-bin
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;
Categories=Network;X-Red-Hat-Base;Application; 

有X-Red-Hat-Base,捷徑就在一級菜單裡,沒有在二級菜單裡
 
11、安裝調試器
 tar jxvf gdb-6.4-tar-bz2
 cd gdb-6.4
 ./configure --target=arm-linux --prefix=/usr/local/arm-gdb -v
 make
 make install
 export PATH=$PATH:/usr/local/arm-gdb/bin
 cd gdbserver
 ./configure --target=arm-linux –host=arm-linux
 make CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc

12、eclipse的基本操作
  (1) 建立->standard make c->new c file->編寫 ->儲存 
  (2)項目->屬性->c/c++ make project->"Compiler invocation command"裡填寫/usr/local/arm/2.95.3/bin/arm-linux-gcc
(3)項目->Creat Make Target->"Target Name":copy-->"Make Target":copy
(4)運行->調試->C/C++ local Application->Debugger->"Debugger":gdbserver Debugger
 ->"GDB debugger":/usr/local/arm-gdb/bin/arm-linux-gdb->"Connection"->"Type":Tcp,"Host name or IP address":192.168.0.2 ,"Port number":1000

13、makefile的編寫
CC=arm-linux-gcc
all:
 $(CC) -g hello.c -o hello
clean:
 rm -vf hello *~

copy: all
 cp hello /var/ftp

這裡的copy是為了方便通過ftp下載到開發板

14、如何調試
    (1)先建立遠端偵錯環境
 tar zxvf lib-for-gdbserver.tgz -C /tmp
然後把解壓出來的libthread_db-1.0.so、libthread_db.so、libthread_db.so.1下載到開發板的/lib裡
 下載可以通過ftp,舉個例子要把libthread_db-1.0.so下載到開發板,可以這樣做:
 A、在主機(192.168.0.3)上啟動vsftp,然後,cp libthread_db-1.0.so /var/ftp
 B、在開發板(192.168.0.2)上,運行wget ftp://192.168.0.3/libthread_db-1.0.so
 (2)編譯時間要加上參數"-g" : arm-linux-gcc -g hello.c -o hello
 (3)在開發板上運行 ./gdbserver 192.168.0.2:1000 hello
 192.168.0.3為宿主機IP,在目標系統的1000連接埠開啟了一個調試進程,hello為要調試的程式。
出現提示:
Process /tmp/hello created: pid=80
Listening on port 1000
 (4)在主機上運行arm-linux-gdb hello或者在eclipse上點"調試"
 ......
 (gdb) target remote 192.168.0.2:1000
出現提示:
Remote debugging using 192.168.0.2:1000
[New thread 80]
[Switching to thread 80]
0x40002a90 in ??()
同時在minicom下提示:
Remote debugging from host 192.168.0.3
(gdb)
串連成功,這時候就可以輸入各種gdb命令如list、run、next、step、break,continune等進行程式調試了。
 
 ok,可以開始寫程式了。
 
 
 
 
 
 
  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.