So, now we need debugger for our Launchpad. Since lmicdi have limited command set (am I wrong?), I need full-fledged debugger, so I’ll use OpenOCD.
Since at time of writing this, Launchpad support is not yet merged into official OpenOCD, I’ll use code from OpenOCD review system (gerrit). While I’m not quite sure what that means, , that doesn’t stops me from trying to clone source tree and compiling it!
Here we go!
First we need to download master source tree, and then apply diffs from OpenOCD review system.
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
git fetch http://openocd.zylin.com/openocd refs/changes/22/922/14 \
&& git checkout FETCH_HEAD
That should download needed source and apply patches…
Then, after we have source, let’s configure it!
LDFLAGS=`pkg-config --libs libusb-1.0` \
CFLAGS=`pkg-config --cflags libusb-1.0` \
CPPFLAGS=-I/opt/local/include ./configure \
--enable-maintainer-mode --enable-ti-icdi --prefix=/opt/local
Lets explain commands and parameters.
./bootstrap Since we are using code from git, it doesn't have configure script, so this command will create it using auto-tools
LDFLAGS, CFLAGS, and CPPFLAGS are set to correct values by using pkg-config tool for configure script
--enable-maintainer-mode has to be used, because we are building from git.
--enable-ti-icdi we want to have support for the TI/Stellaris ICDI
--prefix= I like to keep everything I installed to /opt/local, where Mac ports also install it's packages...
sudo make install
That should install it to /opt/local, or whatever –prefix was set to. Now, let’s check is everything ok!
You need two terminals, one for OpenOCD and other for gdb.
In first one start OpenOCD:
While starting OpenOCD, you will probably get a dialog that asks you does OpenOCD is allowed to accept incoming connections (or something like that). You should allow it!
In second one start gdb:
This –tui parameter is optional, it just says to gdb to use a terminal user interface.
You should now see licence of gdb and build parameter, and in the last line it should be “(gdb)”. Now we need to connect our gdb session to OpenOCD server running in other terminal….
Next command is supposed to be typed in gdb’s prompt! This will connect gdb session to OpenOCD session, which is connected to Launchpad!
target extended-remote :3333
And you should get output similar to this:
Remote debugging using :3333
0x000002b0 in ?? ()
Note: First line should be the same, while second (and/or third….) line will probably wary…
Actually, you can’t do almost anything, because we don’t have file with debugging symbols loaded, and didn’t compiled binary with debugging enabled. To exit from gdb, just type q and press Return, and to exit from OpenOCD press Control+C
In next few days, I’ll try to learn how to debug, and will write here what I find out!