[资料分享与下载] K60(Cortex-M4)开源开发探索(六)—— OpenOCD的配置

[复制链接]
niuyaliang 发表于 2015-2-28 17:13 | 显示全部楼层 |阅读模式
OpenOCD需要针对不同的JTAG工具和不同的目标芯片,配置一个配置文档。一般而言,配置文档分为4个部分。
 楼主| niuyaliang 发表于 2015-2-28 17:13 | 显示全部楼层
1、Daemon
         主要是配置openocd对外的通讯所使用的本地TCP/IP端口,如gdb、telnet所使用的端口。 接口Port的定义一般如下(非特殊情况,无需修改,定义了一些端口号)
 楼主| niuyaliang 发表于 2015-2-28 17:13 | 显示全部楼层
 楼主| niuyaliang 发表于 2015-2-28 17:13 | 显示全部楼层
在用telnet或gdb进行调试时,将会根据定义的端口号连接到服务程序openocd上。     
 楼主| niuyaliang 发表于 2015-2-28 17:14 | 显示全部楼层
   2、Interface
          就是openocd所操作的连接开发板的调试器。
 楼主| niuyaliang 发表于 2015-2-28 17:14 | 显示全部楼层
  1. [plain] view plaincopy
  2. # type of debug adapter  
  3. interface ft2232   
  4. # Provides the USB device description (the iProduct string) of the FTDI FT2232 device. If not specified, the FTDI default value is used.  
  5. ft2232_device_desc "USB<=>JTAG&RS232"   
  6. # Each vendor’s FT2232 device can use different GPIO signals to control output-enables, reset signals, and LEDs  
  7. ft2232_layout jtagkey   
  8. # The vendor ID and product ID of the FTDI FT2232 device  
  9. ft2232_vid_pid 0x1457 0x5118   
复制代码
 楼主| niuyaliang 发表于 2015-2-28 17:14 | 显示全部楼层
  注: 查看ID的方法:
           lsusb //查看设备的相关简要信息
 楼主| niuyaliang 发表于 2015-2-28 17:15 | 显示全部楼层
获取如下:
  1. Bus 006 Device 030: ID 1457:5118 First International Computer, Inc. OpenMoko Neo1973 Debug board (V2+)  
复制代码
 楼主| niuyaliang 发表于 2015-2-28 17:15 | 显示全部楼层
  获取更详细的信息:
  1. sudo lsusb -v -D /dev/bus/usb/006/030  
复制代码
 楼主| niuyaliang 发表于 2015-2-28 17:16 | 显示全部楼层
详细信息如下:
  1. Device: ID 1457:5118 First International Computer, Inc. OpenMoko Neo1973 Debug board (V2+)  
  2.    Device Descriptor:  
  3.    bLength                18  
  4.    bDescriptorType         1  
  5.    bcdUSB               2.00  
  6.    bDeviceClass            0 (Defined at Interface level)  
  7.    bDeviceSubClass         0   
  8.    bDeviceProtocol         0   
  9.    bMaxPacketSize0         8  
  10.    idVendor           0x1457 First International Computer, Inc.  
  11.    idProduct          0x5118 OpenMoko Neo1973 Debug board (V2+)  
  12.    bcdDevice            5.00  
  13.    iManufacturer           1 www.100ask.net  
  14.    iProduct                2 USB<=>JTAG&RS232  
  15.    iSerial                 0   
  16.    bNumConfigurations      1  
  17.    Configuration Descriptor:  
  18.    bLength                 9  
  19.    bDescriptorType         2  
  20.    wTotalLength           55  
  21.    bNumInterfaces          2  
  22.    bConfigurationValue     1  
  23.    iConfiguration          0   
  24.    bmAttributes         0x80  
  25.    (Bus Powered)  
  26.    MaxPower              100mA  
  27.    Interface Descriptor:  
  28.    bLength                 9  
  29.    bDescriptorType         4  
  30. bInterfaceNumber        0  
  31.    bAlternateSetting       0  
  32.    bNumEndpoints           2  
  33.    bInterfaceClass       255 Vendor Specific Class  
  34.    bInterfaceSubClass    255 Vendor Specific Subclass  
  35.    bInterfaceProtocol    255 Vendor Specific Protocol  
  36.    iInterface              2 USB<=>JTAG&RS232  
  37.    Endpoint Descriptor:  
  38.    bLength                 7  
  39. bDescriptorType         5  
  40. bEndpointAddress     0x81  EP 1 IN  
  41.    bmAttributes            2  
  42.    Transfer Type            Bulk  
  43.    Synch Type               None  
  44.    Usage Type               Data  
  45. wMaxPacketSize     0x0040  1x 64 bytes  
  46. bInterval               0  
  47.    Endpoint Descriptor:  
  48.    bLength                 7  
  49. bDescriptorType         5  
  50. bEndpointAddress     0x02  EP 2 OUT  
  51. bmAttributes            2  
  52. Transfer Type            Bulk  
  53. Synch Type               None  
  54. Usage Type               Data  
  55. wMaxPacketSize     0x0040  1x 64 bytes  
  56. bInterval               0  
  57.    Interface Descriptor:  
  58. bLength                 9  
  59.    bDescriptorType         4  
  60.    bInterfaceNumber        1  
  61.    bAlternateSetting       0  
  62.    bNumEndpoints           2  
  63.    bInterfaceClass       255 Vendor Specific Class  
  64.    bInterfaceSubClass    255 Vendor Specific Subclass  
  65.    bInterfaceProtocol    255 Vendor Specific Protocol  
  66.    iInterface              2 USB<=>JTAG&RS232  
  67.    Endpoint Descriptor:  
  68.    bLength                 7  
  69.    bDescriptorType         5  
  70.    bEndpointAddress     0x83  EP 3 IN  
  71.    bmAttributes            2  
  72.    Transfer Type            Bulk  
  73.    Synch Type               None  
  74.    Usage Type               Data  
  75.    wMaxPacketSize     0x0040  1x 64 bytes  
  76.    bInterval               0  
  77.    Endpoint Descriptor:  
  78.    bLength                 7  
  79.    bDescriptorType         5  
  80.    bEndpointAddress     0x04  EP 4 OUT  
  81.    bmAttributes            2  
  82.    Transfer Type            Bulk  
  83.    Synch Type               None  
  84.    Usage Type               Data  
  85.    wMaxPacketSize     0x0040  1x 64 bytes  
  86.    bInterval               0  
  87.    Device Status:     0x0000  
  88. Bus Powered)  
复制代码
 楼主| niuyaliang 发表于 2015-2-28 17:17 | 显示全部楼层
  3、board
       (1)jtag速率
        对于常见的arm、arm9,jtag配置的最大速率不能高于于cpu时钟的六分之一。如果所用的cpu时钟为60Mhz,因此jtag最大速率可设置为:
QQ图片20150228171652.png
 楼主| niuyaliang 发表于 2015-2-28 17:17 | 显示全部楼层
如果使用 QQ图片20150228171656.png
 楼主| niuyaliang 发表于 2015-2-28 17:17 | 显示全部楼层
  即使用自适应时钟,它将会用rclk自己搜索jtag工作频率,速度会很慢。
 楼主| niuyaliang 发表于 2015-2-28 17:17 | 显示全部楼层
(2)芯片复位
        这里配置的为jtag和target cpu可用的复位信号。其中复位jtag中的tap控制器的为trst信号,srst信号用于target cpu复位,它是都是可选的。最好的情况是这两个信号都有,这样openocd就可分别控制tap控制器和cpu的复位。
 楼主| niuyaliang 发表于 2015-2-28 17:18 | 显示全部楼层
4、Target
        在/usr/local/share/openocd/scripts/target目录下可以找到很多芯片的配置例程,因此参照样本添加配置。
 楼主| niuyaliang 发表于 2015-2-28 17:19 | 显示全部楼层
  配置TAP是一个通用的端口,通过TAP可以访问芯片提供的所有数据寄存器(DR)和指令寄存器(IR),配置语法为:
QQ图片20150228171851.png
 楼主| niuyaliang 发表于 2015-2-28 17:19 | 显示全部楼层
配置cpu 此处设置cpu名称以及大小端排列顺序即可。配置如下: QQ图片20150228171855.png
 楼主| niuyaliang 发表于 2015-2-28 17:19 | 显示全部楼层
在使用openocd下载映像到ram时,为了提高速度,在ram中设置一块工作区域,配置如下:
  1. $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0  
复制代码
 楼主| niuyaliang 发表于 2015-2-28 17:20 | 显示全部楼层
由于K60是Cortex-M4的内核,相比之前的arm系列有很大的不同,openocd针对cortex系列也有很多的特殊配置,所以上面的配置还只是初级的配置文档,更加详细的配置还要待今后对这一内核进入深入研究之后再添加了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

212

主题

2427

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部