Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
182 views

How To Create and Debugging Linux Applications Using Sourcery Codebench For Arm Gnu Linux

how to create and debugging Linux applications using sourcery codebench for arm gnu linux

Uploaded by

mihaiM500
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
182 views

How To Create and Debugging Linux Applications Using Sourcery Codebench For Arm Gnu Linux

how to create and debugging Linux applications using sourcery codebench for arm gnu linux

Uploaded by

mihaiM500
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

HOW-TO GUIDE: CREATING AND DEBUGGING LINUX APPLICATIONS USING SOURCERY CODEBENCH FOR ARM GNU/LINUX

KATHLEEN OLIVER, TECHNICAL MARKETING ENGINEER

w w w.m e n t o r.c o m

H O W - T O W H I T E P A P E R

Creating and Debugging Linux Applications Using Sourcery CodeBench for ARM GNU/Linux

INTRODUCTION
These steps give an example of using Mentor Embedded Sourcery CodeBench Professional to create and debug an application that will run on a target running Linux. These steps were tested on a PandaBoard using the Mentor Embedded Linux Kit for PandaBoard kernel image, rootfs, u-boot, and MLO.

PREREQUISITES
Install CodeBench for ARM GNU/Linux Professional 2011.09 on Linux. Download and install the free Mentor Embedded Linux Kit for PandaBoard from http://www.mentor.com/embedded-software/downloads/linux-kits/. Follow the instructions in the PandaBoard Installation and Getting Started Guide to configure your SD card and boot the PandaBoard using the Mentor Embedded Linux Kit for PandaBoard images.

PROCEDURE
1. From the Host machine, start CodeBench for ARM GNU/Linux. 2. Create and build an application. 3. Set up your debug launch configuration and debug your application.

CREATING AND BUILDING AN APPLICATION


This first step to creating and building applications using Sourcery CodeBench is to create a project to work in. You will then need to add your source code and compile it to run on your target. Tip: Refer to the Sourcery CodeBench documentation (Help > Help Contents) for more information about creating projects in Sourcery CodeBench.

PROCEDURE
1. From CodeBench, select File > New > C or C++ Project. The New Project wizard opens.

a. Give your project a name and select the type of project to create. To start with example code, from the Project type area, select Executable > Factorial C Project. b. Click Next. This opens the Configuration page of the Project wizard. c. From the Processor list, select Cortex-A9. Note: We are using sysroot from the Mentor Embedded Linux Kit for PandaBoard, which is at the file system root location. If the sysroot on the target is not at the file system root location, enter the pathname to the location of the installed sysroot on the target. See also: Installing runtime support files on the target. d. Click Finish to create the project. 2. Add files to your project.
w w w. m e nto r. co m

Creating and Debugging Linux Applications Using Sourcery CodeBench for ARM GNU/Linux

3. Add the path to the include files and libraries in your project: a. From the Project Explorer, right-click the project and select Properties. This opens the Properties dialog box for the project. b. On the left of the Properties dialog box, expand C/C++ Build and select Settings. This displays the Settings pane on the right side of the Properties window.

c. From the Settings pane, select the Tool Settings tab. i. To add include paths, expand Sourcery CodeBench C/C++ Compiler and select Includes. ii. To add library paths, expand Sourcery CodeBench C Linker and select Libraries. Add any libraries that your project uses to the Libraries list. d. Click Apply to apply your changes. e. Click OK to close the Properties dialog box. 4. To build your project, right-click the project and select Build Project.

w w w. m e nto r. co m

Creating and Debugging Linux Applications Using Sourcery CodeBench for ARM GNU/Linux

NEXT STEP
Set up your debug launch configuration and debug your applications.

DOWNLOADING APPLICATIONS FROM CODEBENCH TO THE TARGET AND DEBUGGING


After building your applications you can download them to the target PandaBoard to run and debug them.

PREREQUISITES
Create and build an application. See Creating and Building an Application for the PandaBoard Using CodeBench. The PandaBoard must be booted and running Linux which is configured to support SSH and gdbserver. NOTE: If youre using the rootfs that ships with MEL-Lite for PandaBoard, this requirement is already met.

PROCEDURE
1. Select your project in the C/C++ Projects view. 2. Create a Debug launch configuration for your project: a. Select Run > Debug Configurations. This opens the Debug Configurations dialog box.

3. Select the Sourcery CodeBench Debug launch group and click New launch configuration.

w w w. m e nto r. co m

Creating and Debugging Linux Applications Using Sourcery CodeBench for ARM GNU/Linux

4. Select the Main tab of the launch configuration.

a. Enter a Name. b. Select Copy and launch application on remote system. c. Select the Connection for the target. If a connection to the remote system does not exist, click New to create one. This opens the New Connection dialog box. i. Enter the IP address for the target in the Host name field and enter a Connection name to label this connection.

ii. Click Finish to create the connection.


w w w. m e nto r. co m 5

Creating and Debugging Linux Applications Using Sourcery CodeBench for ARM GNU/Linux

d. Optionally, in the Remote path field, enter the path to the location to download your application to on the target with a filename for the application. If you dont do this, your application is downloaded to $HOME. e. Click Apply. 5. Select the Debugger tab for the launch configuration. a. Select the Shared Libraries tab and do the following: i. Select the Translate the specified shared library pathnames and set the pathname on target to the location of the sysroot that you setup on the PandaBoard. See Installing runtime support files on the target. ii. If you have additional shared libraries, click Add to add them to the Additional shared library directories list. iii. Click Apply. b. Select the Connection tab and to the following. i. Enter the Host name or IP address for the target. ii. Set the Port number to 10000. iii. Click Apply.

6. Click Debug to download your application to the target and begin debugging.
w w w. m e nto r. co m

Creating and Debugging Linux Applications Using Sourcery CodeBench for ARM GNU/Linux

7. If the Enter Password dialog box opens, enter the user ID and password for your kernel. For the MEL-Lite for PandaBoard kernel, the User ID is Root and there is no password, so leave the password field blank:

RESULTS
This copies your application to the target and starts your debugging session, which opens the Debug Launch Configuration. Refer to the Sourcery CodeBench Debugger documentation (Help > Help Contents) for more information about debugging with GDB.

INSTALLING RUNTIME SUPPORT FILES ON THE TARGET


NOTE: For more detailed information on this topic, refer to Section 3.6 of the Sourcery CodeBench for ARM/GNU Linux Getting Started Guide. In order to run and debug programs produced by Sourcery CodeBench on a GNU/Linux target, you must install runtime support files on the target. You may also need to set appropriate build options so that your executables can find the correct dynamic linker and libraries at runtime. The runtime support files, referred to as the sysroot, are found in the arm-none-linux-gnueabi/libc directory of your Sourcery CodeBench installation. The sysroot consists of the contents of the etc, lib, sbin, and usr directories. There may be other directories in arm-none-linux-gnueabi/libc that contain additional sysroots customized for particular combinations of command-line compiler flags, or multilibs. Refer to Section 3.2, Library Configurations of the Sourcery CodeBench Getting Started guide for a list of the included multilibs in this version of Sourcery CodeBench, and the corresponding sysroot directory pathnames. For each included multilib, Sourcery CodeBench provides both the full sysroot, unpacked on the host in the same directory hierarchy as it should be installed on the target, and a minimal sysroot packaged as a single .tar.bz2 file for easy transfer to and installation on the target. The minimal sysroot is suitable for initial development of many applications; it is much smaller than the full sysroot because it does not include locale, timezone, or character set conversion support. If your application requires some of those features, you may use the minimal sysroot as a base and copy the additional files required manually from the full sysroot.

w w w. m e nto r. co m

Creating and Debugging Linux Applications Using Sourcery CodeBench for ARM GNU/Linux

You have these choices for installing the sysroot on the target: You can install the files in the filesystem root on the target (that is, installing the files directly in /etc/, /lib/, and so on). All applications on the target then automatically use the Sourcery CodeBench libraries. This method is primarily useful when you are building a GNU/Linux root filesystem from scratch. If your target board already has a GNU/Linux filesystem installed, overwriting the existing C library files is not recommended, as this may break other applications on your system, or cause it to fail to boot. You can install the sysroot in an alternate location and invoke your application through the sysroot-run utility. If you are just getting started with Sourcery CodeBench, this may be the easiest way to get your application running on the target. The QEMU user-space emulator, which runs on GNU/Linux host systems, can likewise be invoked as sysroot-qemu to access the sysroot files from your Sourcery CodeBench installation directory on the host system. This is the recommended way to run QEMU and is also used when running user-space QEMU from the Sourcery CodeBench IDE. You can install the sysroot in an alternate location and build your application with the -rpath and --dynamic-linker linker options to specify the sysroot location. Setting the environment variable LD_LIBRARY_PATH on the target is not sufficient, since executables produced by Sourcery CodeBench depend on the Sourcery CodeBench dynamic linker included in the sysroot as well as the Sourcery CodeBench runtime libraries.

For additional information, please visit: mentor.com/embedded

Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

For the latest product information, call us or visit:

w w w.m e n t o r.c o m

2012 Mentor Graphics Corporation, all rights reserved. This document contains information that is proprietary to Mentor Graphics Corporation and may be duplicated in whole or in part by the original recipient for internal business purposes only, provided that this entire notice appears in all copies. In accepting this document, the recipient agrees to make every reasonable effort to prevent unauthorized use of this information. All trademarks mentioned in this document are the trademarks of their respective owners.

MGC 02-12

TECH10530-w

You might also like