Summary: Tips for using Lauterbach Trace32 ICD with Windows CE.
Using Lauterbach Trace32 JTAG Debugger
A JTAG debugger is a powerful tool for debugging ""BSPs"". It provides advanced debugging capabilities by using the on-chip debug module implemented on the CPU. The term "JTAG debugger" refers to an
In-Circuit Debugger (ICD)_emulator using
JTAG as the communication interface to the CPU on-chip debug module. This article will cover the basic steps for using the
Lauterbach Trace32 ICD with Windows CE. Advanced topics can be found in the "Trace32 ICD Online Help" installed with the Trace32 application.
Capabilities
Why use an ICD when you have the Windows CE kernel debugger? A couple of reasons:
*No Kernel Debugger - There may be times when using the kernel debugger is simply not an option. Bootloader development is one example. Another example is when you need to debug a device running in a retail environment with no KITL available to run the kernel debugger. You can use an ICD in these scenarios because it connects directly to the CPU's debug module. As long as your CPU supports a hardware debug interface such as JTAG and you have access to the interface pins, you can use an ICD to connect to the target device at any time.
*Hardware-Assisted Debugging - The Windows CE kernel debugger provides basic debugging features such as simple breakpoints, single step execution, and memory/register access. An ICD offers more advanced debugging capabilities such as hardware-assisted conditional breakpoints and trace captures.
Using Lauterbach Trace32 ICD
Lauterbach Trace32 ICD is designed to work with many different processors. The debugger consists of a hardware debugger module and an interface probe to connect to the target device.
Setting up the Debugger
Trace32 needs to be configured for your target CPU. This step is typically performed by running a startup script. Example startup scripts are provided with Trace32 for various development boards such as Mainstone. You can use the examples as starting point and modify it for your needs. But it is best to obtain the startup script for your specific device from the CPU silicon vendor or the device manufacturer.
Startup scripts have the file extension .cmm. To run the startup script in Trace32, choose the "File" menu and select "Run Batchfile...". Use the dialog window to locate and select the startup script. The startup script will typically connect the debugger to the target. Refer to the section "Attaching to the Debugger" below for the command to manually do this.
Entering Commands
Enter commands at the "B::" command prompt located at the bottom of the debugger window.
@@Image("http://channel9.msdn.com/wiki/images/cmdprompt.jpg", "command prompt")@@
There are buttons listing the available commands at each level. In the screenshot above, all of the top level commands are listed.
After entering a command, the next level subcommands are listed.
@@Image("http://channel9.msdn.com/wiki/images/cmdbuttons.jpg", "command buttons")@@
Attaching the Debugger
Run the following command to attach the debugger to the target device:
[SYStem.Mode.Attach]
Loading Symbols
After attaching the debugger, the first thing you would want to do is load symbols for the module you want to debug. Symbols in Windows CE are stored in PDB files (.pdb extension). Load symbols using the following command:
Data.LOAD.eXe <PDB filename> /reloc .text at <address> /reloc .data at <address>
This command requires the relocated addresses for the code and data sections. You can find the addresses from the output of the ROMIMAGE (or ""DskImage"" for Image Update builds) tool when building the image. When you run blddemo, the output of ROMIMAGE is redirected to the file %_FLATRELEASEDIR%\makeimg.out. If you manually run MAKEIMG (or ROMIMAGE for the boot loader), make sure to redirect the output to a file so you can view it at a later time. If the module has multiple code and data sections, specify all of them in the command.
The following example shows how to load symbols for NK.EXE.
*Open the MAKEIMG output file, makeimg.out, and find the section containing the output of ROMIMAGE. The output should look similar to the following:
*** calling dskimage.exe [C:\WM600\release\GSample.cfg.xml]
…
Filename [DataType] Start [PhysSize] [RealSize] Comments
------------------------------- -------- -------- -------- -------- ----------------
nk.exe CODE 84929000 349264 349264 o32_rva=00001000
nk.exe CODE 8497f000 10400 10400 o32_rva=000c9000
…
nk.exe DATA 849a7208 2048 441352 FILLER
nk.exe DATA 84a3f030 3704 4096 FILLER
*Note the relocated addresses for the code and data sections for NK.EXE.
*Locate the symbol file NK.PDB on your development machine.
*Issue the symbol load command and specify the symbol path and relocated addresses:
Data.load.exe C:\WM600\release\nk.pdb /reloc .text at 0x8492000 /reloc .text at
0x8497f000 /reloc .data at 0x849a7208 /reloc .data at 0x843f030
Source Path Mapping
Trace32 automatically creates a source path mapping between the PDB file and source code. This information is stored in the PDB file. If the default mapping is incorrect, you can change the mapping or specify additional source search path using the following command:
[sYmbol.SourcePATH.SetRecurseDir] <source path>
The specified directory and all subdirectories will be added to the source search path. Because Trace32 recursively loads the directory information, it is best to not specify a very shallow directory since this can cause Trace32 to take very long to execute the command.
Browsing Symbols
Once you have symbols loaded, there are several ways to browse symbols. Use the following command to display all symbols:
sYmbol.browse
You can also select the type of symbols to display using subcommands. Examples:
View functions:
sYmbol.browse.Function
View variables:
sYmbol.browse.Var
You can also select "Symbols" from the "View" menu to browse symbols. If the debugger is in break state, you can click on the symbol name from the symbol browse window to display the function code or the value of a variable.
Source File Listing
Use the following command to view a list of source files used to generate the loaded modules:
sYmbol.List.SOURCE
You can then click on a source file in the list to open the file in Trace32.
Additional Info
The "Trace32 Online Help" installed with the Trace32 application contains user guides for basic and advanced debugger features. It also contains an index for all commands. Please refer to the online help for additional info for using Trace32.
Go up to
BSP Advanced FeaturesGo up to
Big Book of BSP
Thank you for contributing to this BSP Wiki. To ensure your comments and concerns receive proper exposure, include bspwiki""@""microsoft"".""com when providing feedback or topical suggestions.