Saturday, February 16, 2008

Debugging Techniques with an RTOS

Mainly, there are two types of host/target connection for debugging.

1. Dedicated debug connection - here link has no additional function, other than debug.
2. Communication link - used for other purposes, as well as debug.

Dedicated Debug Connection

Typically, this is based upon the JTAG standard. Prior to JTAG becoming common, Motorola introduced Background Debug Mode (BDM), which worked in a similar way. Almost all new processor designs incorporate a JTAG interface for debug.It is a synchronous serial protocol and low-cost connectors are used. Some kind of adapter is required to interface to the host computer. A big advantage of this type of debug connection is that it will even function with a target that is barely working.

So long as the processor has power and a valid clock, a JTAG connection may normally be established. Typically, a target processor is "frozen" (not executing code) while it is communicating with the host over a JTAG connection.

Communication Link

Generally this would be a serial line (RS232, RS422) or Ethernet. However, there are many other possibilities also: USB, PCI Bus, BlueTooth, IRDA. A key requirement is a working target. The hardware must be fully functional - the processor must be capable of executing code and the communications interfaces must be working. The software must, of course, work to the extent that the communications protocols can be supported.This type of RTOS-aware debugging is necessarily more complex. The big advantage of RTOS-aware debugging, over such a link, is flexibility. The target may continue to run while the debugger communicates with it. This is called "run mode debugging."

Debug Modes: There are broadly two modes of RTOS-aware debugging: stop mode and run mode.

Stop Mode

This mode, which is sometimes referred to as the "freeze mode," occurs when the entire system is stopped – when there is no code execution at all. This mode happens when a breakpoint is hit or the operator intervenes. Typically, the target connection is JTAG. Stop mode debug is quite satisfactory for the vast majority of situations and is only problematic on the rare occasions: the bug being sought is closely tied in with the dynamic interaction between tasks.

Run Mode

Run mode is a more sophisticated RTOS-aware debugging set-up, as it allows just parts of a system to be stopped. For example -Just the current task stops, defined group of tasks stop, All tasks stop (but interrupts are still serviced).Run mode needs sophisticated software support on the target.

RTOS-aware Debug Functionality: The two key areas of functionality are the ability to view data and the control of RTOS functions and objects.

Viewing

All of the information concerning the status of a running system is contained in its memory. Meaningful viewing of this data is a matter of knowing where it is located and how it is tructured and formatted. It is necessary to be able to view a list of tasks in the system along with their running state and priority. For each individual task, it is desirable to view local variables, registers and stack.Lists and information about other RTOS objects (e.g. mailboxes, semaphores, messages) are also required.

Controlling

A task-aware debugger may also exercise some control over the target system. There are various possibilities for controlling tasks - a task may be suspended,a new instance of a task may be spawned, a task's priority may be adjusted.

No comments: