|
|||
An Embedded Processor Architecture With Extensive Support For SoC Debug by Richard Curnow, Mark Hill, Andrew Jones, SuperH (UK) Ltd.
4.2 Single step and nested exceptions The SH-5 has a single-step feature, where an exception is launched on the completion of each instruction. This is activated through a bit in the machine status register, so single-stepping can be configured on a per-thread basis and saved through context switches. The SH-5 handles nested exceptions (referred to as ‘panics') which occur within the critical section of another exception handler. Thus watchpoints can be safely used within exception and interrupt handlers, and such handlers can be single-stepped. 4.3 Branch tracing A branch trace channel can be programmed to generate trace messages when particular types of branch occur. Any combination of the following branch types can be selected:
An activity related to debug is that of software performance optimisation. The SH-5 supports this with performance counters. These can be set to count on a range of conditions (e.g. branches taken/not taken, cache misses/hits), or on the number of hits taken by the instruction and operand address/value watchpoints described in section 4.1. 4.5 Shadow PC register There is a read-only memory-mapped register containing a copy of the current PC. The register also provides the current ASID value. Reading this register is non-intrusive. The primary uses of this register are:
5. ADVANCED SYSTEM DEBUG The system-level debug features of the SH-5 are described in the following sections. 5.1 Debug module The SH5 core has an IP block called the debug module (DM), which is dedicated to supporting the attachment of a debug tool and managing CPU and system trace. The DM provides a debug-link interface through which the on-chip SuperHyway interconnect can be brought off-chip. The debug link can either be layered onto the SH-5's JTAG port, or it can use the dedicated higher-performance SHdebug link connection. The debug link's functional capabilities are the same regardless of which external connection is used. A 16Mbyte region of the SH-5 physical address space is mapped to remote memory across the debug link. Any access made to this region will be passed to debug adaptor (or host). This allows debug code to reside outside the SH-5 on-board memory. In particular, no debug monitor ROM is required, nor does space need to be provided in on-board RAM for use by the debug monitor. Combined with the CPU control features described in section 5.3, this allows an SH-5 board to be booted with no onboard ROM at all. This novel feature is very convenient for software development, since it avoids the need to keep removing an onboard ROM to reprogram it, as would be necessary for most systems. More importantly it allows memory resources on the host to be used transparently. This means that SH-5 based systems can be debugged without perturbing the memory footprint of the application in order to make space for debug code or data. In the other direction, the debug adaptor can use the debug link to inject any type of SuperHyway request into the SH-5. Any SH-5 physical location can be read or written from the debug host without any co-operation from the SH-5 CPU, and with no direct effect on the SH-5 CPU's operation. This has benefits such as these:
The FIFO and debug link modes do not affect the SuperHyway, so are less intrusive than the RAM buffer mode in that respect. These options provide a trade-off of performance against intrusiveness. Since all these destinations run slower than the CPU, a choice of two options exists when the CPU generates more traceable hits than can be sent to the selected destination. These are:
5.2 Bus analyzer Because a logic analyzer cannot be connected to the system bus on an SoC, the SH-5 contains two independent bus analyzer channels (BA) that can be programmed to monitor the on-chip SuperHyway interconnect. Each BA is a module attached to the on-chip SuperHyway bus. A BA module can be programmed to match particular conditions arising on the bus (e.g. request made by a particular module, request accessing a particular physical address). When a hit occurs, a number of actions can occur depending on how the bus analyzer has been programmed. These include:
When the SH-5 handles debug exceptions, panics and soft resets, it selects between two separate vectors when generating the handler address. The selection is based on the value of a memory-mapped register. The first base vector, which is the default, can only be modified through the instruction stream. It can be used by SH-5 software to handle panics and debug exceptions arising when no debugger is in use. The second vector is memory-mapped, so can be modified by a remote debugger. In addition, the SH-5 has a memory-mapped control register to allow suspend, resume and reset. These registers allow a debug host to take control of an SH-5 without co-operation from the running software. In particular, the boot address can be set so that the SH-5 boots from remote code accessed over the debug link. The SH-5 can be selectively forced in to real mode when a debug event (exception or interrupt) is launched. In real mode, both the instruction and data cache states are frozen. The benefits are:
5.4 Off chip triggers The SH-5 supports a trigger-in pin and a trigger-out pin. These can be used to signal debug events in both directions. The trigger-in pin's state can be used in pre-condition settings that enable particular watchpoint channels (IA, IV, OA, branch, bus analyzer). This allows the programmer to only enable an internal SH-5 debug channel when some particular external event has occurred. The SH-5 can be programmed to modify the state of the trigger-out pins when one of its watchpoint channels matches. This allows an internal SH-5 event to be signalled to external equipment, e.g. to trigger an oscilloscope connected to external pins, or to signal to another CPU in a multi-core design. This allows powerful multi-core debug solutions to be built. 5.5 Fast printf The fast printf mechanism causes a special type of trace message to be sent from the SH-5 over the debug link, whenever a value is written to a special memory-mapped register. With suitable adaptor software to interpret the message, this allows arbitrary tracing code to be inserted into the SH-5 software. For example, a fast printf message could be generated at certain critical points in the program so that its progress can be monitored. The fast printf capability can also be used as a signalling mechanism between debug agent code running on the SH-5 and support code running on the debug adaptor/host. 5.6 Debug interrupt The SH-5 has a debug interrupt, which is signalled to the CPU by the debug module (DM) under certain conditions. One such condition is a write to a particular memory mapped DM register. This allows the debug host to take control of the SH-5, for example, if the user has pressed Ctrl-C. 6. CHAINING AND FILTERING Chaining allows a sequence of debug events to be detected and acted on. It is achieved through chain latches. Each IA, IV, OA and bus analyzer channel can be programmed to set or clear a particular chain latch when a hit is detected. Each channel can be configured to be enabled only when a particular chain latch is set. This allows a channel to be made conditional on a sequence of hits occurring on other channels, for example:
Related to the chain latches are the event counters. A channel can be configured to match only when a particular event counter is zero. Channels can be selectively programmed to decrement an event counter when a match occurs. This mechanism allows conditions such as raising an exception on the 100th store to a variable. Tracing can be made conditional on the chain latches and event counters too, to avoid generation of unnecessary trace messages. The chain latch and event counter settings are memory-mapped, and can be examined and modified from the debug host. Additionally, the IA, IV, OA and branch tracing channels can be made conditional on
Some examples follow of how the architecture can be applied to SOC debug problems. 7.1 Device register modifications Suppose software programs a register in an IP block to have a particular value, and later that value is found to have changed unexpectedly. To diagnose this, one of the bus analyzer channels can be programmed to match on writes to the register. Then any write, from any SuperHyway initiator, will be captured (either as a trace message or through an interrupt.) 7.2 Corrupted data in the cache Suppose some data is used successfully in a function, and later the same data is found to be corrupted. An unexpected store to the data can be detected by programming an OA channel to match on the address of the affected variable. To limit the number of hits, an IA channel can be programmed to match at the end of the function, and its action can be to set a chain latch. This chain latch can be used as a precondition for the OA channel, to cascade the conditions together. Suppose no spurious store is found. The next theory might be that the cache block is evicted to memory and then reloaded, and gets corrupted in the process. One bus analyzer channel can be programmed to match on requests from the CPU to external memory for the physical address of the variable. The other channel can be programmed to capture responses from the memory to the CPU. From the trace data that is generated, the data read from memory can be examined. Similarly, the data stored to memory earlier on can be traced. If the stored and loaded data differ, this might indicate a problem with the set-up of the memory controller or with the memory itself. 8. CONFIGURABILITY During development of a new SOC, the debug module would be included to provide full access to all the debug features. Once the SOC and its software are mature, new generations of the SOC may be produced, e.g. to reduce the die size. As part of such optimisations, it is possible to remove the Debug Module from the design, saving the area occupied by its logic and by the 1kbyte buffer memory. 9. TOOL SUPPORT 9.1 Hardware The SH-5 debug architecture supports two types of off-chip debug connection:
At the adaptor end of the link, an FPGA can be used to implement the link protocol and message buffering. The FPGA is typically interfaced to a debug host workstation via a high speed connection such as Ethernet. SuperH currently market the MicroProbe unit, which performs this function together with a C/C++ toolchain hosted on PC, SUN or Linux. The JTAG connection provides a lower-cost, lower-speed (typically 20MHz) solution, implemented through JTAG to USB interfaces, or JTAG to Ethernet interfaces. With a difference of typically 5 in operating frequency and 4 in output bandwidth, the SHdebug link outperforms JTAG by approximately
9.2 Software SuperH have already ported GDB to support the SH-5 as a remote target. This port is currently supported on Solaris, Linux and Microsoft Windows. The trace features have been extensively targeted by in-house software and SuperH is working with 3rd parties to develop best in class trace tools for the SuperH architecture. 10. CONCLUSION SH-5 evaluation devices are available now and a range of tools, operating systems and application software has been successfully ported and debugged using the features of the SHdebug architecture. The debug features described in this paper have already proven to be invaluable for:
SH-5: The 64 Bit SuperH Architecture. Prasenjit Biswas, Atsushi Hasegawa et al. IEEE Micro July/August 2000 (Vol 20 No. 4) pp 28-39. 12. GLOSSARY BA: Bus analyzer |
Home | Feedback | Register | Site Map |
All material on this site Copyright © 2017 Design And Reuse S.A. All rights reserved. |