Linux Application Development using Code Composer Studio with a CCS Project¶
Goal¶
This wiki page describes how to build and debug a sample Hello World program using Code Composer Studio and a CCS Project. Normally, a CCS Project is used to help manage programs running on multiple processors like Arm and the DSP and possibly others.
In this simple example, there is just a program on the Arm. In this case the main difference from using the C/C++ Project is the way to specify which Compiler Toolchain to use.
Assumptions¶
The following are assumed:
- The Linux Development environment has been installed as described in Code_Composer_Installation.
- The multi-architecture version of gdb has been installed as described in Gdb_Multiarch_Installation.
- The target has an IP address which can be reached from your development host. These notes will use 10.0.103.50 as an example address. Substitute your address as needed.
Building the Program¶
- Start Code Composer Studio
- Select a new workspace. e.g. ~/helloworld2. Click the Launch Button
- Close the Getting Started Window. You may need to click the Restore Icon in the upper right to get a normal display.
- Create a new project
- File->New->CCS Project. Click on Next
- Project name: hello_ccs
- Compiler version: GNU v8.3.0
- Note: if this compiler is not in the list of compilers, please revisit the Code_Composer_Installation and make sure you did the step toward the end about "Add Linux Compiler"
- Empty Project (with main.c)
- Click on the Finish button
- Change the contents for main.c to the following
/** * main.c */ #include <stdio.h> int main(void) { printf ("Hello world from a CCS project\n"); fflush (stdout); return 0; }
- File->New->CCS Project. Click on Next
- Remove the -specs=nosys.specs flag
- Project->Properties->GNU Compiler.
- Press Edit Flags... button. Remove -specs="nosys.specs", hit OK
- You will need to do this for the Release build also but since this sample is not building the release version, this step can be skipped.
- Project->Properties->GNU Compiler.
- Build the project: One of the following:
- Project->Build
- Project->Build All
- ctrl-b
Running the Program¶
In a terminal window do the following:
- Copy the executable to the target:
cd ~/helloworld2/hello_ccs/Debug export IPADDR=10.0.103.50 rsync hello_ccs.out root@${IPADDR}:
- Execute the program
ssh root@${IPADDR} ./hello_ccs.out
You should see the following printed:
Hello world from a CCS project
Debugging the Program¶
To debug the project you need to do the following:
- Start the gdbserver program on the target. The gdbserver program will wait until the host makes a connection and will provide access to the desired application on behalf of the debugger running on the host.
- Start the gdb-multiarch program on the host from within Code Composer to run and control the target program.
The exact steps needed are as follows:
- Start gdbserver on the target.
- In a terminal window on the host
export IPADDR=10.0.103.50 ssh root@${IPADDR} gdbserver :10000 ./hello_ccs.out
From the target, you should see text like the following:Process ./hello_ccs.out created; pid = 2046 Listening on port 10000
- In a terminal window on the host
- Start debugging in Code Composer
- Create a debug configuration. Run->Debug Configurations
- Select C/C++ Remote Application.
- Click on the New Configuration button (upper left)
- Main tab
- Project: hello_ccs
- C/C++Application: Debug/hello_ccs.out
- At bottom of tab next to Using GDB (DSF) Automatic Remote Debugging Launcher. Click on Select other...
- Select Preferred Launcher
- Check Use configuration specific settings
- Select GDB (DSF) Manual Remote Debugging Launcher
- Click on OK
- Debugger Tab
- Main Tab under Debugger Options:
- GDB Debugger: Instead of gdb, replace with: gdb-multiarch
- Connection Tab under Debugger Options:
- Type: TCP
- Host name or IP: your_target_ip (use ip address on target to see)
- Port: 10000 (must match what was given to gdbserver)
- Main Tab under Debugger Options:
- Click on the Debug button (lower right)
- Main tab
- Create a debug configuration. Run->Debug Configurations
After pressing the Debug button, the following should happen:
- A build will be done (but no changes). If there had been changes, you would need to copy the new executable to the target and start gdbserver over.
- Code Composer should connect to the gdbserver on the target and stop at the printf line. There should be an arrow to the left of the printf line.
To verify that you have control of the target, try the following:
- Step over the printf line. Run->Step Over or press the Step Over icon in the tool bar.
- Step over the fflush line. Should see the output of the program in the terminal where gdbserver was started.
- Terminate the debug session. Run->Terminate or use the Terminate icon in the tool bar.
Breakpoints can be set/cleared by clicking in the gutter to the left of the line numbers in the source view.
Conclusions¶
The steps above have demonstrated how to do the following in Code Composer Studio:
- Create a CCS Project
- Add a source file and code for a simple hello world program
- Build the program
- Copy the executable to the target
- Start gdbserver on the target
- Start a debug session in Code Composer Studio
- Step through the simple program
- Terminate the debug session
A real application would be more complicated since the program being debugged would be more complex, but the same basic steps would be used.
See Building_TI_Linux_SDK_and_IPC_examples_on_Linux for a more complex example project that uses a CCS project.
Go to top