- Table of contents
- Linux App CCS C/C++ Project
Linux App CCS C/C++ Project¶
Objective¶
This wiki page will walk through the steps needed to build, run, and debug a simple hello world program on the main ARM processor of the AM62x using a C/C++ project.
Prerequisites¶
- Install Code Composer Studio and processor sdk. Code_Composer_Installation
- Install gdb-multiarch Gdb_Multiarch_Installation
- Target is powered on and running
Note¶
It would be nice to use the GDB (DSF) Automatic Remote Debugging Launcher but there is currently an incompatibility between the SSH key exchange methods supported in the AM62x target and the methods that CCS is willing to use. We are looking into a work-around and until one is available, the Manual Remote Debugging Launcher needs to be used. The serial and telnet methods of connecting also do not seem viable.
If the GDB (DSF) Automatic Remote Debugging Launcher could be used, then the program could be automatically copied to the target and gdbserver could be automatically started. This would avoid these manual steps and the process would greatly streamlined.
Steps¶
Create and build project¶
- Start CCS in a new workspace
- Close Getting Started View
- Click x next to Getting Started to close the View
- Click on Restore button in upper right so Project Explorer is visible
- Create ProjectFile->New->Project...
- Select a Wizard
- C/C++->C/C++ Project
- Next
- Templates for New C/C++ Project
- C Managed Build
- Next
- C Project:
- Project name: hello
- Use default location: checked
- Empty Project
- Cross GCC for toolchain
- Next
- Select Configurations
- Debug and release configurations both checked.
- Next
- Cross GCC Command
- Cross compiler prefix: aarch64-none-linux-gnu-
- Browse for cross compiler Path:
/home/<yourhome>/ti-processor-sdk-linux-am62xx-evm-08.06.00.42/linux-devkit/sysroots/x86_64-arago-linux/usr/bin
- Finish
- Select a Wizard
- Add Code to the project
- File->New->Source file:
- Source file name: hello.c
- Add code in source view
#include <stdio.h> int main() { printf ("Hello world\n"); fflush (stdout); return 0; }
Note that the fflush() is needed to get the output to the terminal sooner. When running the program through the method being used on this page, the output is buffered until the program runs to completion since stdout is not an actual terminal. To get the output to appear sooner while
stepping through the program, the fflush is needed.
- File->New->Source file:
- Build Project
- Project->Build Project
- or ctrl-B
Run the executable on the target¶
- Transfer file to the target
- Open the terminal view. Window->Show View->Other...->Terminal->Terminal
- Press the Open a Terminal button (shift-ctrl-alt-T)
- Local Terminal
- Enter commands in the local terminal
cd <workspace_path>/hello/Debug scp hello root@<target_ip>:
- Run the program on the target:
- Enter this command in the local terminal
ssh root@<target_ip> ./hello
- where <target_ip> is the ip address of your target
- Should see: Hello world
- Enter this command in the local terminal
Debug the program¶
- Start gdbserver on the target:
- In Local Terminal window:
ssh root@<target_ip> gdbserver :10000 ./hello
- Should see output like
Process ./hello created; pid = 4000 Listening on port 10000
- In Local Terminal window:
- Make a debug configuration:
- Run->Debug configurations
- Pick C/C++ Remote Application->right-mouse->New Configuration
- Main tab:
- At bottom of page with "Using GDB (DSF) Automatic Remote Debugging Launcher" Click on Select other...
- Check the checkbox for Use configuration specific settings
- Select "GDB (DSF) Manual Remote Debugging Launcher"
- Click OK
- At bottom of page with "Using GDB (DSF) Automatic Remote Debugging Launcher" Click on Select other...
- Debugger tab:
- Debugger Options Main tab:
- GDB debugger: change gdb to gdb-multiarch
- Debugger Options Connection tab:
- Change "Host name or IP address" from localhost to your target ip address
- Change Port number to 10000
- Debugger Options Main tab:
- Click on Debug
- Main tab:
- Pick C/C++ Remote Application->right-mouse->New Configuration
- CCS will switch to Debug Perspective
- Stopped with arrow at printf line.
- Open terminal view in the Debug Perspective (Window->Show View->Terminal)
- In Local Terminal, should see something like:
Remote debugging from host ::ffff:10.0.103.179, port 41160
where 10.0.103.179 is your host ip address. The port will vary. - Step over
- Run->Step Over
- Step over button
- or F6
- Step over again to get past the fflush()
- In Local Terminal window, should see
Hello World
- Terminate debug session
- Terminate button
- or Run->Terminate or ctrl-F2
- Run->Debug configurations
Summary¶
This page has shown the steps needed to create, build, run, and debug a simple hello world C program using a C/C++ project. The same steps would be used for a more complicated program.
Go to top