OpenOCD需要针对不同的JTAG工具和不同的目标芯片,配置一个配置文档。一般而言,配置文档分为4个部分。
1、Daemon
主要是配置openocd对外的通讯所使用的本地TCP/IP端口,如gdb、telnet所使用的端口。 接口Port的定义一般如下(非特殊情况,无需修改,定义了一些端口号)
telnet_port 4444
tcl_port 6666
在用telnet或gdb进行调试时,将会根据定义的端口号连接到服务程序openocd上。
2、Interface
就是openocd所操作的连接开发板的调试器。
# type of debug adapter
interface ft2232
# Provides the USB device description (the iProduct string) of the FTDI FT2232 device. If not specified, the FTDI default value is used.
ft2232_device_desc "USB<=>JTAG&RS232"
# Each vendor’s FT2232 device can use different GPIO signals to control output-enables, reset signals, and LEDs
ft2232_layout jtagkey
# The vendor ID and product ID of the FTDI FT2232 device
ft2232_vid_pid 0x1457 0x5118
注: 查看ID的方法:
lsusb //查看设备的相关简要信息
获取如下:
Bus 006 Device 030: ID 1457:5118 First International Computer, Inc. OpenMoko Neo1973 Debug board (V2+)
获取更详细的信息:
sudo lsusb -v -D /dev/bus/usb/006/030
详细信息如下:
Device: ID 1457:5118 First International Computer, Inc. OpenMoko Neo1973 Debug board (V2+)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x1457 First International Computer, Inc.
idProduct 0x5118 OpenMoko Neo1973 Debug board (V2+)
bcdDevice 5.00
iManufacturer 1 www.100ask.net
iProduct 2 USB<=>JTAG&RS232
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 55
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2 USB<=>JTAG&RS232
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2 USB<=>JTAG&RS232
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Status: 0x0000
(Bus Powered)
3、board
(1)jtag速率
对于常见的arm、arm9,jtag配置的最大速率不能高于于cpu时钟的六分之一。如果所用的cpu时钟为60Mhz,因此jtag最大速率可设置为:
jtag_khz 10000
如果使用
jtag_rclk 3000
即使用自适应时钟,它将会用rclk自己搜索jtag工作频率,速度会很慢。(2)芯片复位
这里配置的为jtag和target cpu可用的复位信号。其中复位jtag中的tap控制器的为trst信号,srst信号用于target cpu复位,它是都是可选的。最好的情况是这两个信号都有,这样openocd就可分别控制tap控制器和cpu的复位。
reset_config trst_and_srst
4、Target
在/usr/local/share/openocd/scripts/target目录下可以找到很多芯片的配置例程,因此参照样本添加配置。配置TAP是一个通用的端口,通过TAP可以访问芯片提供的所有数据寄存器(DR)和指令寄存器(IR),配置语法为:
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0×1 -irmask 0xf -expected-id $_CPUTAPID
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
在使用openocd下载映像到ram时,为了提高速度,在ram中设置一块工作区域,配置如下:
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
由于K60是Cortex-M4的内核,相比之前的arm系列有很大的不同,openocd针对cortex系列也有很多的特殊配置,所以上面的配置还只是初级的配置文档,更加详细的配置还要待今后对这一内核进入深入研究之后再添加了。
参考链接:http://a.chinaunix.com/space.php?uid=23947686&do=blog&id=172600
参考链接:http://a.chinaunix.com/space.php?uid=23947686&do=blog&id=172600
----------------------------------------------------------------
欢迎大家转载我的文章。
转载请注明:转自古-月
欢迎继续关注我的博客