Below document will hopefully save others some work. May be some better ways but this seems to work. I found the online wiki did not work for OMAP-L137 thus documented the changes I made to get things functional. Additionally setup needed for Eclipse debugging.
Building GDB into OMAP-L137 MontaVista Distribution
Use In Eclipse
The current demo MontaVista distribution does not contain GDB and gdbserver for debugging the OMAP-L137 thus leaving it to the developer to create a proper environment. The current documentation helps but needs some additional changes to function properly. Additionally the end of this document includes some information on what is needed to setup an Eclipse debug environment.
This document references the wiki link below, providing changes where needed:
· Download GDB source from http://ftp.gnu.org/gnu/gdb/. For this example the latest is http://ftp.gnu.org/gnu/gdb/gdb-6.8.tar.bz2
· Configure and cross compile gdb, note that the prefix value used in the configure commands below should reflect the locations you want to use in your actual install, the paths shown here are based on the getting started guide.
· Montavista toolchain is installed at /opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin
· Filesystem is installed at /home/user/workdir/filesys where ‘user’ is installation dependent.
· Commands which are displayed due to word wrap are actually all on one line.
Configure first (change 'user' to your home directory) and run as root:
host# cd /home/user/workdir/filesys
host# tar zxvf gdb-6.8.tar.gz
host# cd gdb-6.8
host# ./configure --host=i686-pc-linux-gnu --target=armv5tl-montavista-linux-gnueabi --prefix=/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le
Note that the install command is expecting to be able to write to your MontaVista installation directory, it is easier to run everything as root, alternately you will have to change permissions on the install /opt directory. Using 'sudo' had problems as well.
Before cross compiling the Makefile needs to be modified to remove warnings. If this is not done the script build execution will abort due to warnings. Find the following lines and make changes (sudo vi Makefile or gedit Makefile), note the file is read only thus run sudo or edit as root:
CFLAGS_FOR_BUILD = -g -O2
CFLAGS_FOR_BUILD = -g -w -O2
CFLAGS = -g -O2
CFLAGS = -g -w -O2
If for any reason you forget to change the Makefile the cache will remember the prior CFLAGS settings and terminate with errors. To restart after you run 'make' without the -w you must be sure to run 'make distclean' first, then below if cache is not cleared properly:
(may be a few others but errors when execute 'make && make install' will identify, for some reason 'make distclean' does not seem to run correctly or aborts early).
The cache must be removed else the edit to CFLAGS will be detected and the build aborted. Alternatively it may be easier to delete the gdb-6.8 directory and simple extract it again.
Assuming CFLAGS changed as directed now do the build:
host# sudo make && make install
Now cross compile gdbserver as root. All commands are on same line. Note to change the /home/user to your user name prior to execution.
host# cd gdb/gdbserver
host# CC=/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-gcc ./configure --host=armv5tl-montavista-linux-gnueabi --prefix=/home/user/workdir/filesys
host# make && make install
Now copy the file system to the target boot device, in this example a formated USB pen drive:
cp -Rf /home/user/workdir/filesys/* /media/disk-1
host IP address: 192.168.100.1 target IP address: 192.168.100.2
Command line GDB:
· Run gdbserver on target, reference wiki sample 'c' code for example below.
target# cd /opt/sample
target# /gdb-6.8/gdb/gdbserver/gdbserver 192.168.100.1:10000 ./sample
Process ./sample created; pid = 733
Listening on port 10000
At this point of time target is waiting for connection from the host
· Run gdb on host. Set /home/user to your home directory in below examples.
· Note that the sysroot is needed else shared library version problems will occur.
host# cd /home/user/targetfs/opt/sample (or wherever your program is)
host# /opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/armv5tl-montavista-linux-gnueabi-gdb ./sample
GNU gdb 6.8
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=armv5tl-montavista-linux-gnueabi"...
(gdb) set sysroot /home/user/workdir/filesys
(gdb) set solib-search-path /home/user/workdir/filesys/lib
(gdb) target remote 192.168.100.2:1000
Remote debugging using 18.104.22.168:1000
0x400007e0 in _start ()
Assuming Eclipse is installed, and typically project created, reference the below link for background information. In this case using V3.2.2, an older version but that available with Ubuntu.
Specifically #5, Application Debug with Eclipse and GDB, section 5.4.2.
Create a .gdbinit file in your Eclipse workspace directory. Place the following in it, replacing /home/user with the proper directory:
set sysroot /home/user/workdir/filesys
set solib-search-path /home/user/workdir/filesys/lib
Under the Eclipse Debugger/Main tab (Run->Debug) set the following (changing /home/user to proper directory):
Debugger: gdbserver Debugger
stop at startup at: main (checked)
GDB Debugger: /opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/armv5tl-montavista-linux-gnueabi-gdb
GDB Command Line: /home/user/workspace/.gdbinit
GDB Command Set: Standard (Linux)
Protocol: mi2 (this is important else can not mix C and C++ code, also other problems could arise).
In this example using TCP, thus Debugger/Connections tab:
Host Name or IP Address: 192.168.100.2
Port Number: 10000
With the target executing gdbserver click Debug and connection should be made and debugging possible.
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.