Wednesday, January 17, 2007

Cross-Compiling GDB on Linux for Powerpc Platform

I'm a Software Engineer working with Embedded Systems. Currently, I'm working with Powerpc SoC Processor - AMC-440EP.

When I first started working in this project I built my Development Environment, which includes PowerPC toolchain, Linux Kernel and root file system plus some extra libraries I need in my project. However, at this stage I forgot to build with my toolchain a PowerPC Debugger. Thus, I have to cross-compile gdb (http://www.gnu.org/software/gdb/) and gdbserver for remote debugging.

The steps to cross-compile GDB are:

Download the latest GDB version from http://www.gnu.org/software/gdb/download/

Decompress the tarball you have just downloaded:

tar -xjvf gdb-6.6.tar.bz2

cd gdb-6.6

Run the configuration script as follows:

./configure --target=powerpc-linux --enable-sim-powerpc \

--enable-sim-hostendian=little \

--with-solib-absolute-prefix=/path/to/libdir \ (to ensure it'll use the right libraries)

--prefix=/path/to/the/installation/of/toolchain

make

make install

Then, change directory to:

cd ./gdb/gdbserver

Run the configuration script for gdbserver:

export CC=powerpc-440-linux-gnu-gcc

./configure --host=powerpc-linux \ --prefix=path/to/the/installation/of/toolchain

make

make install

That's all. No, you have a functional powerpc cross-compiled gdb and gdbserver. You can start debugging your powerpc embedded application.

Cheers,

Itzhak

No comments: