NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Hosted C66x GDB

From Texas Instruments Wiki
Jump to: navigation, search

TIBanner.png


Hosted C66x GDB

Description[edit]

C66x GDB is an implementation of a GDB Server debugging stub for the Texas Instruments C66x DSP. It allows developers to utilize the standard features of GDB (GNU Debugger) to gain visibility to and debug the C66x DSP cores in the heterogeneous DSP + ARM KeyStone II system-on-chips. It is comprised of a GDB Server library that must be integrated into the DSP application to be debugged and a version of GDB that has been compiled to support the C66x DSP.

Integration[edit]

OpenCL[edit]

The C66x GDB Server library has been integrated with the latest version of the OpenCL runtime, therefore no additional integration steps are required in order to debug an application that has been created with OpenCL. Simply launch the OpenCL application and follow the steps described in the Running GDB section.

Bare-metal[edit]

Currently the GDB server library only supports integration with applications that utilize DSP/BIOS. Apart from including the GDB Server library and include files to the project, four main resources must be allocated to the server -

  • One DSP interrupt
  • A channel of the EDMA
  • A parameter ram entry of the EDMA
  • A section in memory that is available to all cores

The first three resources may be allocated by the Framework Components library or may be explicitly specified, depending on the initialization routines invoked. The memory region is exposed from the library as a data section named .gdb_server and should be placed in DDR3 RAM using the .cfg script in DSP BIOS. A snippet of the .cfg script is shown below with the necessary changes.

<syntaxhighlight lang='javascript'> // Ensure these two modules are included var Hwi = xdc.useModule('ti.sysbios.family.c64p.Hwi'); var Cache = xdc.useModule('ti.sysbios.family.c66.Cache');

// Place the .gdb_server section in DDR3 Program.sectMap[".gdb_server"] = "DDR3"; </syntaxhighlight>

Initializing GDB Server with Framework Components EDMA Manager[edit]

The following code initializes the GDB Server by first allocating a resources from the Framework Components EDMA manager and passing the resources to the initialization call.

<syntaxhighlight lang='c'> // prototypes in GDB_server.h int GDB_server_initGlob(int intNum, int edmaChannelController, void *edmaMgrHandle); int GDB_server_initLocal(void); </syntaxhighlight>

<syntaxhighlight lang='c'> // initialize the EDMA Manager /.../ // perform this step only on DSP0 if (DNUM == 0) {

    // allocate the EDMA resources
    gdb_channel = EdmaMgr_alloc(1);
    // initialize the server with EDMA channel controller 1
    if (!gdb_channel || GDB_server_initGlob(4, 1, gdb_channel) != 0)

return RETURN_FAIL; }

// wait for all cores to finish waitAtCoreBarrier();

// Start up the gdb server on all the cores if (GDB_server_initLocal() != 0) return RETURN_FAIL; </syntaxhighlight>

Initializing GDB Server explicitly[edit]

The following code initializes the GDB Server explicitly.

<syntaxhighlight lang='c'> // prototype in GDB_server.h GDB_server_init(int intNum, int edmaChannelController, int edmaChannel, int pramEntry); </syntaxhighlight>

<syntaxhighlight lang='c'>

int main() {

    // initialize DSP/BIOS tasks, etc.
    /.../
    // initialize the server with DSP interrupt 4, using EDMA channel controller 1,
    // EDMA channel 0, and Parameter Ram entry 0
    // error == 0 means success
    error = GDB_server_init(4,1,0,0);
    // start DSP/BIOS
    BIOS_start();

} </syntaxhighlight>

Installation[edit]

EVM[edit]

The MCSDK HPC release includes pre-compiled binaries which are packaged in *.ipk (Debian-style software installation package format). They can be installed natively on the target EVMs with the following steps.

  • Copy IPK files to target filesystem

The IPK files are located under [mcsdk-hpc install dir]/mcsdk_hpc_<version>/images directory.

  • Log on to the EVM as root user, and install the IPKs using the 'opkg install' command:

<syntaxhighlight lang="bash">

> opkg install gdbc6x_<ver>_cortexa15hf-vfp-neon.ipk
> opkg install gdbproxymod_dkms_<ver>.ipk
> opkg install gdb_server_<ver>_cortexa15hf-vfp-neon.ipk

</syntaxhighlight>

NOTE: To install the IPKs from the x86 Ubuntu machine which hosts the EVM filesystem, use the following commands: <syntaxhighlight lang="bash">

> sudo dpkg -x gdbc6x_<ver>_cortexa15hf-vfp-neon.ipk /evmk2h_nfs
> sudo dpkg -x gdbproxymod_dkms_<ver>.ipk /evmk2h_nfs
> sudo dpkg -x gdb_server_<ver>_cortexa15hf-vfp-neon.ipk /evmk2h_nfs

</syntaxhighlight>

In the above commands, "/evmk2h_nfs" is the root directory of the EVM filesystem.

HPC[edit]

Add the mcsdk-hpc PPA to your system if you haven’t already.

<syntaxhighlight lang="bash">

deb http://ppa.launchpad.net/ti-keystone-team/keystone-hpc-3.0.1.1/ubuntu precise main
deb-src http://ppa.launchpad.net/ti-keystone-team/keystone-hpc-3.0.1.1/ubuntu precise main

</syntaxhighlight>

  • Add the two lines from the sources.list entry to the /etc/apt/sources.list file in your Ubuntu file system.
  • Run:

<syntaxhighlight lang="bash">

> sudo apt-get update

</syntaxhighlight>

Run the following commands to install gdbc6x <syntaxhighlight lang="bash">

> sudo apt-get install gdbproxy-mod-dkms
> sudo apt-get install gdbc6x

</syntaxhighlight>

Running GDB[edit]

OpenCL[edit]

Ensure that GDB and the proper kernel modules are installed:

  • Ensure gdbc6x is installed

<syntaxhighlight lang='bash'>

> which gdbc6x
/usr/bin/gdbc6x

</syntaxhighlight>

  • Add the current user to the 'dspdbg' group in order to allow debugging

<syntaxhighlight lang='bash'>

> usermod -a -G dspdbg <user_to_add_to_group>

</syntaxhighlight>

  • Ensure the gdbserverproxy kernel module is installed

<syntaxhighlight lang='bash'>

> lsmod
Module                  Size  Used by
gdbserverproxy          4488  0
cmemk                  25339  0
uio_module_drv          5048  0

</syntaxhighlight>

  • If gdbserverproxy is not installed insert it with the proper command

<syntaxhighlight lang='bash'>

> sudo modprobe gdbserverproxy

</syntaxhighlight>

  • Build the OpenCL application with debugging symbols on and optimizations turned off. The OpenCL example matmpy makefile is used as an example:

<syntaxhighlight lang='bash'> EXE = matmpy CPP_FLAGS = -g -fopenmp -I/usr/include CL6X_FLAGS = -g CLOCL_FLAGS = -g

include ../make.inc

$(EXE): main.o kernel.out @$(CPP) $(CPP_FLAGS) main.o $(LD_FLAGS) $(LIBS) -lrt -lgomp -o $@

kernel.out: ccode.obj </syntaxhighlight>

  • Ensure that the TI_OCL_DEBUG flag is set

<syntaxhighlight lang='bash'>

> export TI_OCL_DEBUG=1

</syntaxhighlight>

  • Build and run the OpenCL application. The following prompt will appear as soon as the application begins:

<syntaxhighlight lang='bash'> gdbc6x -iex "target remote /dev/gdbtty0" -iex "symbol-file /usr/share/ti/opencl/dsp.out" -iex "add-symbol-file /tmp/openclWZJ7nY.out 0xa6c00000" -iex "b exit" -iex "b ocl_matmpy"

Press any key, then enter to continue </syntaxhighlight>

  • Copy and execute the prompt in a new window. GDB should launch and will set a breakpoint at the entry point of the OpenCL kernel. In the original window, press any key, then enter in order to continue into the OpenCL kernel and begin debugging.

<syntaxhighlight lang='bash'> Remote debugging using /dev/gdbtty0 0xa09d6390 in ?? () Reading symbols from /usr/share/ti/opencl/dsp.out...done. add symbol table from file "/tmp/openclWZJ7nY.out" at .text_addr = 0xa6c00000 (y or n) y Reading symbols from /tmp/openclWZJ7nY.out...done. Breakpoint 1 at 0xa09d5a74: file exit.c, line 64. Breakpoint 2 at 0xa6c00020: file kernel.cl, line 34. (gdb) c Continuing.

Breakpoint 2, ocl_matmpy (a_AP=0xc040000, b_AP=0xc040000, c_AP=0xa6800000, b_column_AP=0x820000, a_wid_AS=1024, a_hgt_AS=1024)

   at kernel.cl:34

34 const global float *b, (gdb) </syntaxhighlight>

At this point, GDB has halted the core. Once the debugging symbols are loaded, source stepping, setting breakpoints, and all features that are part of GDB should be available. For more information on GDB useage, refer to the GDB Documentation


Bare-metal[edit]

Ensure that GDB and the proper kernel modules are installed by following the instructions specified in the OpenCL section.

  • Load the application to be debugged to the DSP(s) using the mpm command:

<syntaxhighlight lang='bash'>

> mpmcl reset dsp0
reset succeeded
> mpmcl load dsp0 GDB_enabled_app.out
load succeeded
> mpmcl run dsp0
run succeeded

</syntaxhighlight>

  • Run gdbc6x and attach to the desired DSP by using the target remote command. Each DSP is assigned a device file in /dev named gdbtty*, where * signifies the DSP number.

<syntaxhighlight lang='bash'>

> gdbc6x
  1. attach to dsp0

(gdb) target remote /dev/gdbtty0 Remote debugging using /dev/gdbtty0 0x0080ae4c in ?? ()

  1. add symbols

(gdb)add-symbol-file GDB_enabled_app.out <address_of_code> </syntaxhighlight>

At this point, GDB has halted the core. Once the debugging symbols are loaded, source stepping, setting breakpoints, and all features that are part of GDB should be available. For more information on GDB useage, refer to the GDB Documentation

It is important to note that multiple instances of GDB may be running at the same time, as long as they are each debugging different DSPs. For example, GDB session 1 can attach to DSP0 (/dev/gdbtty0) while GDB session 2 attaches to DSP1 (/dev/gdbtty1).

Limitations[edit]

  • Breakpoints in shared memory are not completely supported. When a breakpoint is set in shared memory the core being debugged will halt at the breakpoint,but other cores may also halt. Currently there is no way to restart other cores which may have halted.
  • Breakpoints in SPLOOP are not allowed. If a breakpoint is detected to be in an SPLOOP it will be placed at an instruction that executes before the SPLOOP. Breakpoints at the drain phase of the SPLOOP (possibly immediately after an SPKERNEL instruction is encountered) are also not allowed, but checking is not performed. If this case is encountered, execution of the DSP cannot be restarted, but its state may still be observed. The DSP will report its state as SIGHUP (signal hangup). In order to ensure this case is not encountered while debugging, turn compiler optimizations off.
  • Breakpoints in branch delay slots are not allowed. If a breakpoint is detected to be in a branch delay slot, it will be moved to a more appropriate place.


Last updated: 09/05/2014

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Hosted C66x GDB here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Hosted C66x GDB here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Hosted C66x GDB here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Hosted C66x GDB here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Hosted C66x GDB here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Hosted C66x GDB here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Hosted C66x GDB here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Hosted C66x GDB here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Hosted C66x GDB here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity