gdb / x86_64 / chroot friendly debugger launch script

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

gdb / x86_64 / chroot friendly debugger launch script

1,546 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by culyun on Tue Dec 27 05:32:07 MST 2011
Code Red has a couple of wiki pages that talk about using the LPC-Link under Linux:

  http://support.code-red-tech.com/CodeRedWiki/UsingGDB
  http://support.code-red-tech.com/CodeRedWiki/LPCLinkDiagnostics

This bash script (see below) is used to bootstrap the backend debugger for gdb.

eg.

(gdb) target extended-remote | /home/me/scripts/initArmTarget crt_emu_lpc11_13_nxp -p2 -pLPC1227/301 -wire=winusb
Why??

I'm using an x86_64 ArchLinux distribution.  I installed LPCXpresso in a i686 chroot, but wanted to use vim, bash, make, and Code-Sourcerie's cross compiler instead of the LPCxpresso eclipse-bundle...  Anyway enough blabber.

Here's the script.  It may be a bit buggy, but it's 1.20 am (yawns)

------------------

#!/bin/bash

script=`readlink -f $BASH_SOURCE`

if [ `arch` != 'i686' ] ; then exec schroot -p -- "$script" "$@" ; fi

debuggerBinPath='/usr/local/lpcxpresso_4.1.0_164/lpcxpresso/bin'
debugger="$1" ; shift ; 

# Reattach the LPC Link USB debugger, if required
# See http://support.code-red-tech.com/CodeRedWiki/LPCLinkDiagnostics

dfuDevices=`"$debuggerBinPath"/dfu-util -l`

if [ "${dfuDevices/0x0471:0xdf55/found it}" != "$dfuDevices" ] ; then
  "$debuggerBinPath"/dfu-util -d 0x471:0xdf55 -c 0 -t 2048 -R -D "$debuggerBinPath"/LPCXpressoWIN.enc
  sleep 1 
fi

# Start the debugger backend

exec "$debuggerBinPath"/"$debugger" "$@"
ok chaps, i hope this helps..  Next step is to hook this up to pyclewn and vim!
0 Kudos
Reply
1 Reply

1,292 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by culyun on Fri Dec 30 05:42:36 MST 2011
Well the good news is integrated vim debugging with the LPC-Link works a charm..

To start a vim hosted debugging session,
run pyclewn from the tty.

pyclewn -p arm-eabi-gdb -g async


Pyclewn will bootstrap vim and present you with an empty buffer.
NB. I'm not using Code Red's GCC tool chain here..

I'll automate this soon, but for the moment run
:Cmapkeys
from the vim console.  This script adds some nice key bindings for typical debugging stuff (step, breakpoints, continue, etc.).  More on Pyclewn's site.

The buffer should now be showing Pyclewn's console, which is a mixture of gdb and its own goodness.

Next, load an executable file into the debugger using the
:Cfile
command.  Pyclewn exports all (most?) of gdb's commands under the ":C" prefix, so for example gdb's list command is exported as ":Clist", etc.

Next, connect to the LPC-Link

:Ctarget extended-remote \| ./initArmTarget crt_emu_lpc11_13_nxp -4 -pLPC1227/301 -wire=winusb


NB. The initArmTarget script should be put in a more sensible location, but I'm still developing the tools...

Wait... Anywhere from 1 s to 15 s on my PC.  The variation depends on whether the LPC-Link dfu code needs to be downloaded to the USB-debugger

Voila, main.c should be shown in all its glory.

At this point you should refer to the Pyclewn documentation, but I have to say that it works really well... Well almost.  There is currently one caveat.  The current Pyclewn release (1.7) has a bug that crashes vim when issuing the
:Cdbgvar
command.  This has been fixed in trunk.  I couldn't wait for another release, so I just hack-installed Pyclewn trunk into my system.

As a contingency, you can use :Cprint (ie. gdb) to inspect variables, but it's a pain..

Happy hacking.
0 Kudos
Reply