Internal specifics of Onchip breakpoints on Freescale StarCore processors is easily understood if we are familiar with its emulator. So it’s good idea to read the following two posts before going through the details below.
On Chip Breakpoints:
A descriptive diagram of the whole debug infrastructure is given below.
- EDU: Event Detection unit
- EC: Event Counter
- TB unit: Trace Buffer unit
- EEx & EED : General purpose control signals which can be configured for input or output. Usage of this is SOC specific (Derivative specific).
Before we configure the break points the processor core should be placed in DEBUG mode, this DEBUG mode can invoked using two methods:
- Send a Command to the controller
- Assert the EEx signal as soon as the core comes out of reset
Using the second method will need configuring of registers accordingly. Once the Core is in the DEBUG mode, breakpoints can be configured via JTAG. Here we are not going to discuss the details of register settings but a design level overview of how this OnChip Emulator works.
The breakpoints/watchpoints should be enabled only after programming the EDU (Event Detection Unit) registers with the configuration which defines that breakpoint. Namely the address in the memory, type of the breakpoint etc. These registers can be written via the JTAG.
So the two methods employed for enabling an already configured breakpoint/watchpoint are:
- Configure the breakpoint/watchpoint enabling register by writing into it using the JTAG port.
- Use the EEx or the EED control lines to signal the EOnCE controller to enable or disable the debug functionalities.
Once we program the debug configuration, the host needs to be informed when an event happened or when a breakpoint got hit. EOnCE will ensure that the core enters DEBUG mode by sending it a signal but for informing the HOST we need a mechanism like an interrupt.
- We can configure one out of the EEx signals to send an interrupt to the host once the core enters Debug mode.
From the above discussion it’s clear that breakpoints are supported in hardware via setting of few registers and they can be configured via EOnCE which in turn responds to JTAG interface. If there are multiple break points configured then there are mechanisms to identify which one was hit.
- Read the EOnCE controller status or monitor registers which will tell you which event has got hit
- Configure EEx or EED signal to assert an interrupt to the HOST, depending on which signal has asserted the interrupt, HOST can know which break point has got hit.
- Read the PC Breakpoint detection register from EOnCE, this gives the PC of the address which caused the event.
PC Breakpoint detection register should me used in combination with reading of EOnCE status register because debug mode can be caused by other reasons also.One important point to be noted here is that EOnCE gives many options for the usage of EEx and EED signals but the way in which it will be used is SOC specific and each platform may have different uses of these.
Similarly, if the Event counter has to count “off core” events like Cache hits or misses, the the external signals EC0 and EC1 needs to be used, this is also SOC dependent.
It’s obvious that onchip breakpoints need support in hardware, but we could still use some more clarity on how this support is provided.
- EOnCE is closely integrated with the processor core because it needs to probe address and data buses for certain reference values configured in breakpoint/watchpoint registers.
- Whenever processor core accesses an address, EOnCE comes to know about this address value and it compares it with the reference value. If they are same then, depending on the Event selector configuration an event will be raised.
- The event can be a DEBUG exception, DEBUG signal to the processor, triggering a trace, disabling a trace etc.
Similar logic can be employed for probing data values also. The above diagram we can see two comparators, A & B, these are two address buses for data access, if we do not know in which bus the data we want will be accessed then we need to configure both Comparator A & B with the reference value and then set the condition for an OR-ing of the comparisons, so that even if one comparison returns a success we will have an event raised.
MASK register: The way it works is pretty self explanatory, the address bus values sampled is masked with the MASK register value and then compared with the reference values.
Trace Buffer Unit can detect and record program flow related details and send it to an off-core module like Nexus, from Nexus it can be sent to the host using a Nexus port on the board or it can be saved in a circular buffer inside any On-Chip memory.