Chinaunix首页 | 论坛 | 博客
  • 博客访问: 194840
  • 博文数量: 23
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 428
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-05 12:46
个人简介

博客转移至CU。之前的百度空间博客http://hi.baidu.com/williwill。

文章分类

全部博文(23)

文章存档

2014年(18)

2013年(5)

我的朋友

分类: 嵌入式

2014-02-28 01:55:34

  • 首先安装libusb和libreadline5;

        以ubuntu为例:
  1. sudo apt-get install libusb lib32readline5
  • 然后下载安装JLink_Linux_V422;

        地址为:        按照包中的README文档进行安装

  1. cp -d libjlinkarm.so.* /usr/lib
  2. ldconfig
  3. cp 45-jlink.rules /etc/udev/rules.d/
  4. groupadd plugdev // Creates new group "plugdev"
  5. usermod -a -G plugdev // Appends user to the group "plugdev"
注意cp的-d选项,保留链接属性;还有最后的添加group完毕后,我仍然需要sudo才能执行start和JLinkGDBServer,否则出现Can not connect to J-Link via USB之类的错误,原因未查。
  • 现在可以运行sudo ./start;

        第一次会更新JLink的firmware,然后会自动重启JLInk。
        CTRL+C关闭
  • 启动GDB Server;


  1. sudo ./JLinkGDBServer

        出现如下片段就说明成功:

  1. SEGGER J-Link GDB Server V4.22

  2. JLinkARM.dll V4.22 (DLL compiled Dec 17 2010 17:41:06)

  3. Listening on TCP/IP port 2331

  4. J-Link connected
  5. Firmware: J-Link ARM V8 compiled Dec 16 2010 20:21:29
  6. Hardware: V8.00
  7. S/N: 68000019
  8. Feature(s): RDI, FlashDL, FlashBP, JFlash, GDBFull

  9. J-Link found 1 JTAG device, Total IRLen = 4
  10. JTAG ID: 0x0032409D (ARM9)

  • 安装GDB;

        交叉编译调试环境下需要安装类似arm-linux-gdb,如果你的交叉工具链已经包含gdb,则可以跳过这步了。
        如果用的是buildroot自己编译的交叉工具的话,记得make menuconfig选上
  1. [*] Build gdb for the Host

        另外
  1. Thread library implementation (linuxthreads) --->

        需要选为linuxthreads,否则编译过程会在linux-thread-db.c报错。
  • 另开一个终端,启动GDB;

    1. arm-linux-gdb -x ~/work/gdb.cmd -ex "connect_jei 127.0.0.1 2331" /home/biu/work/u-boot-2014.01/u-boot
    其中gdb.cmd为一段用于初始化CPU之类的gdb命令。
        s3c2440的初始化可以参考:
        其他可以参考JLinkGDBServer文档UM08005_JLinkGDBServer.pdf来进行修改
        运行结果如下:
  1. GNU gdb (GDB) 7.5.1
  2. Copyright (C) 2012 Free Software Foundation, Inc.
  3. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  4. This is free software: you are free to change and redistribute it.
  5. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
  6. and "show warranty" for details.
  7. This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-buildroot-linux-uclibcgnueabi".
  8. For bug reporting instructions, please see:
  9. <http://www.gnu.org/software/gdb/bugs/>...
  10. Reading symbols from /home/biu/work/u-boot-2014.01/u-boot...done.
  11. warning: Unable to find dynamic linker breakpoint function.
  12. GDB will be unable to debug shared library initializers
  13. and track explicitly loaded dynamic code.
  14. 0x00000000 in ?? ()
  15. Target endianess set to "little endian"
  16. Expected an decimal digit (0-9)
  17. Writing register (CPSR = 0x000000D3)
  18. Select auto JTAG speed (8000 kHz)
  19. Writing 0x00000000 @ address 0x53000000
  20. Writing 0xFFFFFFFF @ address 0x4A000008
  21. Writing 0x00007FFF @ address 0x4A00001C
  22. Writing 0xFF000000 @ address 0x4C000000
  23. Writing 0x00000005 @ address 0x4C000014
  24. Writing 0x0007F021 @ address 0x4C000004
  25. Writing 0x22111110 @ address 0x48000000
  26. Writing 0x00000700 @ address 0x48000004
  27. Writing 0x00000700 @ address 0x48000008
  28. Writing 0x00000700 @ address 0x4800000C
  29. Writing 0x00000700 @ address 0x48000010
  30. Writing 0x00000700 @ address 0x48000014
  31. Writing 0x00000700 @ address 0x48000018
  32. Writing 0x00018009 @ address 0x4800001C
  33. Writing 0x00018009 @ address 0x48000020
  34. Writing 0x008E04EB @ address 0x48000024
  35. Writing 0x000000B2 @ address 0x48000028
  36. Writing 0x00000030 @ address 0x4800002C
  37. Writing 0x00000030 @ address 0x48000030
  38. (gdb)
  • 调试程序;

        以uboot为例
  1. (gdb) load
        就会把启动时最后一个参数指定的文件下载到开发板RAM中,下载地址为编译uboot的链接地址,GDBServer在下载完毕后还会把PC指向程序 首地址

  1. Downloading 304 bytes @ address 0x33F80000
  2. Downloading 304 bytes @ address 0x33F80130
  3. Downloading 304 bytes @ address 0x33F80260
  4. .
  5. .
  6. .
  7. Downloading 128 bytes @ address 0x33FF9984
    Downloading 17 bytes @ address 0x33FF9A04
    Writing register (PC = 0x33F80000)

  1. (gdb) l
        可以看到start.S的内容

点击(此处)折叠或打开

  1. (gdb) l
  2. 1    /*
  3. 2     * armboot - Startup Code for ARM920 CPU-core
  4. 3     *
  5. 4     * Copyright (c) 2001    Marius Gr?ger <mag@sysgo.de>
  6. 5     * Copyright (c) 2002    Alex Züpke <azu@sysgo.de>
  7. 6     * Copyright (c) 2002    Gary Jennejohn <garyj@denx.de>
  8. 7     *
  9. 8     * SPDX-License-Identifier:    GPL-2.0+
  10. 9     */
  11. 10    
  12. (gdb)
  13. 11    #include <asm-offsets.h>
  14. 12    #include <common.h>
  15. 13    #include <config.h>
  16. 14    
  17. 15    /*
  18. 16     *************************************************************************
  19. 17     *
  20. 18     * Jump vector table as in table 3.1 in [1]
  21. 19     *
  22. 20     *************************************************************************
  23. (gdb)
  24. 21     */
  25. 22    
  26. 23    
  27. 24    .globl _start
  28. 25    _start:    b    start_code
  29. 26        ldr    pc, _undefined_instruction
  30. 27        ldr    pc, _software_interrupt
  31. 28        ldr    pc, _prefetch_abort
  32. 29        ldr    pc, _data_abort
  33. 30        ldr    pc, _not_used

        然后就是具体的GDB调试过程了。

  1. (gdb) break 117
  2. Breakpoint 1 at 0x33f80064: file start.S, line 117.
  3. (gdb) c
  4. Continuing.

  5. Breakpoint 1, start_code () at start.S:142
  6. 142        ldr    r0, =pWTCON
  7. (gdb)

        参考链接:http://blog.csdn.net/samantha_sun/article/details/6245504
                            
                            等








阅读(4816) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~