## Using Soft Attach for On-Device Debugging

NEEDS REWRITING

You can debug hardware via TCF using the soft attach option. This enables you to debug an image flashed to ROM or on a memory card. Soft attach includes all the capabilities fo Stop-mode debugging but can't debug any code loaded before the OS is booted.

There are several components that must be provided to the debugger so that it can communicate with the attached hardware device. They are:

- Config_carbide.t32 - a required configuration file used to configure Carbide for soft attach debugging
- .cmm file - you must select the correct .cmm script file for the hardware otherwise it will not initialize properly and the debugger will be unable to communicate. The .cmm script files are located in the <Carbide>\plugins\com.nokia.carbide.cpp.support_3.0.x.xxx\Symbian_Support\TCF\cmm_scripts directory.
  Also, if there is a specific .cmm file for the device, like H2 or H4, especially if it includes _attach in the name, choose that version over the others to do soft attach on the hardware.
- .log file - you must have a valid .log file for the ROM image in order to debug the image

If the New Launch Configuration Wizard is used, you will be asked to identify the above files. If you used the New or Debug dialog to create a launch configuration, make sure that the above files are supplied.

The major steps to perform a soft attach are:

1. Import and build your project and the ROM image
2. Startup the device using the ROM image
3. Setup the debugger and begin debugging

#### 1. Importing and building the project and ROM image

1. Import the project
2. Build the project
3. Create a ROM image

   Enter the desired command-line arguments for the ROM image in the ROM Build Command Line text box in the Carbide ROM Build Settings panel of the Properties for <project> dialog.

#### 2. Starting up the device with the ROM image

1. Transfer the ROM image to the hardware via memory card or flash

NOTE Ensure that the hardware includes a boot loader program so that it can boot the ROM image from the memory card.

2. Power up the device

   Once the operating system has booted up, it is ready for the debugger to attach

#### 3. Setting up the debugger to debug

1. On the hardware, launch the program to debug
2. Click Run > Debug to launch the New Launch Configuration Wizard
3. In the Launch Types page
   1. Select the TCF Launch Configuration
   2. Click Next
4. In the Symbian ROM Image Settings page
   1. Enter the path to the TCF Initialization Script .cmm file
   2. Select the Target Processor
   3. Click Next
   In the Symbian ROM Image Settings page
   1. Enable Soft attach
   2. Enter the Symbian ROM Log File
   3. Click Next
5. In the New Launch Configuration page
   1. Enable the "Open launch configuration for additional customization of launch settings" option
   2. Click Finish
6. In the Debug > Symbian OS Trace 32 > New_Configuration > Connection tab
   1. Enable the "View messages between Carbide and Trace32"
   2. Click Debug

If the View messages between Carbide and Trace32 option is enabled, the Console view will show the communications between the debugger and the hardware (Figure 1). If you do not see the messages, verify that the Trace32 Communications Log is the active log view.

Figure 1. Debugger log showing .cmm file being used to initialize hardware

7. Once the debugger connects to the hardware it will halt the hardware at a random memory address (Figure 2). Press Resume in the Debug view to begin debugging.

Figure 2. Debugger stopping at a random address using soft attach

8. Debug the program in the Carbide debugger

Once the debugger is connected to the hardware you can:

- Set breakpoints in the editor view

> If breakpoints were already set in the project then an Editor view should display them as resolved. If no breakpoints have been set, now is the time to add them.

> NOTE The number of breakpoints you can set is controlled by the hardware.

- Click Suspend to halt the processor on the hardware
- Use Disconnect (preferred) to stop debugging the program. This does not halt the processor.
- Use Terminate to end the debug session

#### Related references

- Debug perspective
- Executables view
- Symbian OS Data view
- Registers view
- Breakpoint view