• cBPM调试——codeblocks 配置交叉编译和调试环境


    http://www.cnblogs.com/pang1567/p/3587217.html


    我要用codeblocks交叉编译和调试arm开发板上的程序,宿主机是ubuntu12.04.开发板是嵌入式linux操作系统。

    1、配置交叉编译环境

    image

    由 上到下,1处直接选择即可。2处是你交叉编译器安装位置,3 4 5 6 可以在你交叉编译器安装位置下的bin目录找到,arm-linux-gdb默认是不安装的,需要我们自己安装,安装arm-linux-gdb和 gdbserver需要另外安装(如果没有安装的话),arm-linux-gdb安装目录最好也选择为交叉编译器安装目录。即/usr/local /arm/arm-linux-4.4.3。

    2、arm-linux-gdb和gdbserver安装方法

    注:arm-linux-gdb的安装路径是/usr/local/arm/arm-linux-4.4.3

    arm-linux-gdb的编译安装
    下载gdb-6.8.tar.bz2至工作目录

    gdb源码下载:http://ftp.gnu.org/gnu/gdb/

    命令如下:

    $tar -jxvf gdb-6.8.tar.bz2
    $cd gdb-6.8
    $./configure --target=arm-linux --enable-sim --prefix=/usr/local/arm/arm-linux-4.4.3

    --prefix用于指定安装路径

    $make
    $sudo make install
    完成后可以在/usr/local/arm/arm-linux-4.4.3/bin下找到arm-linux-gdb文件
    arm-linux-gdbserver的编译安装
    进入./gdb/gdbserver

    命令如下:

    $cd gdb/gdbserver./configure --target=arm-linux --host=arm-linux
    $make CC=arm-linux-gcc
    (CC=arm-linux-gcc用于指定arm-linux编译器)
    编译成功后在当前目录下会生成gdbserver文件,拷贝至开发板上(可放入开发板/usr/bin/目录下,这样在任何目录下均可执行gdbserver命令)

    3、配置nfs文件共享。

    (1)sudo apt-get install nfs-kernel-server
    sudo apt-get install portmap nfs-common
    Ubuntu 上默认是没有安装 Ubuntu nfs 服务器的,因此我们首先安装 Ubuntu nfs 服务器端:
    $sudo apt-get install nfs-kernel-server
    在一些文档中,提出还需要使用 apt-get 来手动安装 nfs 的客户端 nfs-common,以及端口映
    射器 portmap,但其实这是没有必要的,因为在安装 nfs-kernel-server 时,apt 会自动为我们把它们安装好。
    (2)sudo vim /etc/exports
    加入这么一行:
    /home/somebody/nfs_root/rootfs_mini/ *(rw,sync,no_root_squash)
    (/home/somebody/nfs_root/rootfs_mini/ 是我的根文件系统所在的位置)
    Ubuntu nfs 允许挂载的目录及权限在文件/etc/exports 中进行了定义。
    例如,我们要将根目录下的 rootfs 目录共享出来,那么我们需要在/etc/exports 文件末尾添加
    如下一行:/rootfs *(rw,sync,no_root_squash)
    其中: /rootfs 是要共享的目录, *代表允许所有的网络段访问, rw 是可读写权限,sync 是资料
    同步写入内存和硬盘,no_root_squash 是 Ubuntu nfs 客户端分享目录使用者的权限,如果客
    户端使用的是 root 用户,那么对于该共享目录而言,该客户端就具有 root 权限。
    其它 Ubuntu nfs 常用的参数有:
    ro 只读访问
    rw 读写访问 sync 所有数据在请求时写入共享
    async nfs 在写入数据前可以响应请求
    secure nfs 通过 1024 以下的安全 TCP/IP 端口发送
    insecure nfs 通过 1024 以上的端口发送
    wdelay 如果多个用户要写入 nfs 目录,则归组写入(默认)
    no_wdelay 如果多个用户要写入 nfs 目录,则立即写入,当使用 async 时,无需此设置。
    hide 在 nfs 共享目录中不共享其子目录
    no_hide 共享 nfs 目录的子目录
    subtree_check 如果共享/usr/bin 之类的子目录时,强制 nfs 检查父目录的权限(默认)
    no_subtree_check 和上面相对,不检查父目录权限
    all_squash 共享文件的 UID 和 GID 映射匿名用户 anonymous,适合公用目录。
    no_all_squash 保留共享文件的 UID 和 GID(默认)
    root_squash root 用户的所有请求映射成如 anonymous 用户一样的权限(默认)
    no_root_squas root 用户具有根目录的完全管理访问权限
    anonuid=xxx 指定 nfs 服务器/etc/passwd 文件中匿名用户的 UID
    anongid=xxx 指定 nfs 服务器/etc/passwd 文件中匿名用户的 GID
    (3)

    修改挂载点的属性
    chmod 777 /home/somebody/nfs_root/rootfs_mini/
    (4)
    重启 nfs
    sudo /etc/init.d/nfs-kernel-server restart
    sudo /etc/init.d/portmap restart
    (5)
    在本机上测试
    showmount -e
    sudo mount -t nfs –o nolock 192.168.2.10:/home/somebody/nfs_root/rootfs_mini/ /mnt/nfs/
    ls -l /mnt/nfs/
    nfs mount 默认选项包括文件锁,依赖于portmap提供的动态端口分配功能。
    解决方法:kill 文件锁(lockd)或者mount -o nolock

    于是尝试mount -o nolock -t nfs 192.168.1.24:/home/test /mnt/nfs,正常工作。

    nfs mount device or resource busy

    这是因为多次挂载的原因,因此要先umount /mnt/nfs 一下 ,如果还是挂载不成功需要重启开发板来试试。
    注:可以通过一个符号链接来 export NFS 目录,但在/etc/exports 下所添加的挂载点应为真
    正的目录。比如建一符号链接
    ln -s /home/pub/work/freerunner/out/target/product/freerunner /home/jgyang/nfsroot 
    这样在开发板上设置的内核命令行中设置的 NFS 目录就可是:/home/jgyang/nfsroot,但在
    /etc/exports 文 件 中 export 出 的 目 录 应 当 是 实 际 的 NFS 所 在 的 目 录 , 即
    /home/pub/work/freerunner/out/target/product/freerunner。
    这样有两个好处,一是可以省去开发板中启动参数命令过长的麻烦;二是在重新编译 androi之后可以直接使用生成的 NFS,而不必再重新拷贝一份。

    4、修改工程的调试属性

    我 通过网络来实现gdb的远程调试,这样我需要将宿主机的一个目录挂载到开发板上,这就是nfs的作用了。选择什么目录随意。挂载/home /project、目录到开发板的/gdbserver目录下。然后再宿主机/home/project/目录下建立工程,修改项目调试属性。

    点击项目右键,点击属性。

    image

    image

    修改debug的ip地址和端口,端口任意,但是ip地址是开发板的ip地址。这是为了连接开发板的gdbserver而设置的。

    这样设置就基本完成了。可以开始调试了。

    5、调试示例

    前边我们已经将gdbserver拷贝到/usr/bin目录下。所以我们进入挂载目录/gdbserver运行

    gdbserver 192.168.0.232:1111 ./bin/debug/usb 这里ip地址是宿主机的,端口自定,但是要和codeblock一样。./bin/debug/usb 是指生成的二进制可调试文件。

    然后再宿主机开始调试吧,如下图

    image

    image

    <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
    阅读(69) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~
    评论热议
  • 相关阅读:
    POJ 2007 Scrambled Polygon (极角排序)
    POJ 1113 Wall (凸包 + 思维)
    POJ 2074 Line of Sight(求直线交点 + 思维)
    POJ 1584 A Round Peg in a Ground Hole(凸多边形判断 + 点是否在多边形内 + 点到线段的最短距离)
    HDU 4623 Crime (状压DP + 数学优化)
    P4755 Beautiful Pair
    CF235C Cyclical Quest
    luoguP4449 于神之怒加强版
    扩展KMP
    P4397 [JLOI2014]聪明的燕姿
  • 原文地址:https://www.cnblogs.com/ztguang/p/12648961.html
Copyright © 2020-2023  润新知