012:Keil调试技术(转)

转自:http://bbs.armfly.com/simple/?t526.html

嵌入式软件开发中的一个基本需求就是能通过终端来输出调试信息,一般可通过2种方式实现:一种是使用串口线连接板上的UARTPC上的COM口,通过PC上的超级终端来查看调试信息;另一种则是采用半主机机制,但有可能不被所用的工具链支持。基于Cortex-M3核的软件调试突破了这样的限制,Cortex-M3内核提供了一个ITM(Instrumentation TraceMacrocell)接口,通过SWV(Serial Wire Viewer)可调试由SWO引脚接收到的ITM数据。ITM实现了32个通用的数据通道,基于这样的实现,CMSIS规定用通道0作为终端来输出调试信息,通道31用于操作系统的输出调试(特权模式访问)。在core_cm3.h中定义了ITM_SendChar()函数,因此可通过调用该函数来重写fputc,以在应用程序中通过printf打印调试信息,并可通过ITM Viewer查看这些调试信息。有了这样的实现,嵌入式软件开发者就可以在不配置串口和使用终端调试软件的情况下输出调试信息,在一定程度上减少了工作量

基本概念:

SWD
The J-Link and J-Trace support ARMs Serial WireDebug (SWD). SWD replaces the 5-pin JTAG port with a clock (SWDCLK)and a single bi-directional data pin (SWDIO), providing all thenormal JTAG debug and testfunctionality. 
Pin 13 of SWD:
SWO – Serial Wire Output trace port. (Optional,not required for SWD communication.)

SWO
J-Link can be used with devices that supportSerial Wire Output (SWO). Serial Wire Output (SWO) support meanssupport for a single pin output signal from the core. It iscurrently tested with Cortex-M3 only.

SWV
The Instrumentation Trace Macrocell (ITM) andSerial Wire Output (SWO) can be used to form a Serial Wire Viewer(SWV). The Serial Wire Viewer provides a low cost method ofobtaining information from inside the MCU. The SWO can output tracedata in two output formats, but only one output mechanism is validat any one time. The 2 defined encodings are UART and Manchester.The current J-Link implementation only supports UART encoding.Serial Wire Viewer uses the SWO pin to transmit different packetsfor different types of information. The three sources in theCortex-M3 core which can output information via this pinare:
- Instrumentation Trace Macrocell (ITM) forapplication-driven trace source that supports printf-styledebugging. It supports 32 different channels, which allow it to beused for other purposes such as real-time kernel information aswell.
- Data Watchpoint and Trace (DWT) for real-timevariable monitoring and PC-sampling, which can in turn be used toperiodically output the PC or various CPU-internal counters, whichcan be used to obtain profiling information from thetarget.
- Timestamping. Timestamps are emitted relative topackets.

LPC177x/178x debug support
- A JTAG debug interface is included.
- Serial Wire Debug is included. Serial Wire Debugallows debug operations using only 2 wires, simple trace functionscan be added with a third wire.
- The Embedded Trace Macrocell (ETM) is included.The ETM provides instruction trace capabilities.
- The Data Watchpoint and Trace (DWT) unit isincluded. The DWT allows data address or data value matches to betrace information or trigger other events. The DWT includes 4comparators and counters for certain internal events.
- An Instrumentation Trace Macrocell (ITM) isincluded. Software can write to the ITM in order to send messagesto the trace port.
- The Trace Port Interface Unit (TPIU) isincluded. The TPIU encodes and provides trace information to theoutside world. This can be on the Serial Wire Viewer pin or the4-bit parallel trace port.
- A Flash Patch and Breakpoint (FPB) is included.The FPB can generate hardware breakpoints and remap specificaddresses in code space to SRAM as a temporary method of alteringnon-volatile code. The FPB includes 2 literal comparators and 6instruction comparators.


http://www.keil.com/support/docs/3051.htmhttp://www.keil.com/support/man/do

posted @ 2013-01-12 18:23  afeibfp  阅读(1377)  评论(0编辑  收藏  举报