DA-660-8/16-LXUser’s Manual
Programmer’s Guide
5-3
Obtaining help
Use the Linux man utility to obtain help on many of the utilities provided by the tool chain. For
example to get help on the armv5b-linux-gcc compiler, issue the command:
#man armv5b-linux-gcc
Cross Compiling Applications and Libraries
To compile a simple C application, just use the cross compiler instead of the regular compiler:
#mxscaleb-gcc –o example –Wall –g –O2 example.c
#mxscaleb-strip –s example
#mxscaleb-gcc -ggdb –o example-debug example.c
Tools Available in the Host Environment
Most of the cross compiler tools are the same as their native compiler counterparts, but with an
additional prefix that specifies the target system. In the case of x86 environments, the prefix is
i386-linux- and in the case of the DA-660 Xscale boards, it is
mxscaleb-
.
For example the native C compiler is gcc and the cross C compiler for Xscale in DA-660 is
mxscaleb-gcc
.
The following cross compiler tools are provided:
ar
Manage archives (static libraries)
as Assembler
c++, g++
C++ compiler
cpp C
preprocessor
gcc C
compiler
gdb Debugger
ld Linker
nm
Lists symbols from object files
objcopy
Copies and translates object files
objdump
Displays information about object files
ranlib
Generates indexes to archives (static libraries)
readelf
Displays information about ELF files
size
Lists object file section sizes
strings
Prints strings of printable characters from files (usually object files)
strip
Removes symbols and sections from object files (usually debugging information)
Debugging with GDB
First compile the program must with option -ggdb. Use the following steps:
1.
To debug a program called
hello-debug
on the target, use the command:
#gdbserver 192.168.4.142:2000 hello-debug
This is where 2000 is the network port number on which the server waits for a connection
from the client. This can be any available port number on the target. Following this is the
name of the program to be debugged (hello-debug), plus that program’s arguments. Output
similar to the following will be sent to the console:
Process hello-debug created; pid=38
2.
Use the following command on the host to change to the directory that contains
hello-debug
:
cd /my_work_directory/myfilesystem/testprograms