zoukankan      html  css  js  c++  java
  • Linux下基于eclipse的arm开发环境的建立

    这是我参考了网上的很多资料后,修改并验证的,有一定的参考意义。不一定面面俱到,因为有的地方说多了就显得有点啰嗦,要是还有疑问就给我留言我尽力解答。 

    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,可以开始写程序了。
     
     
     
     
     
     
      

  • 相关阅读:
    iOS之在AppDelegate中push到指定页面
    iOS之iOS中的(null)、<null>、 nil 的问题
    HTML表格属性及简单实例
    iOS多语言设置
    HTML简单介绍
    iOS-WebView(WKWebView)进度条
    OC 中property的使用
    Memory map of an object array
    2018-10-15 21:07:38 c language
    2018-10-15 00:41:45 c language
  • 原文地址:https://www.cnblogs.com/swordzj/p/2034777.html
Copyright © 2011-2022 走看看