GDB Command Line and Vector Catch

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

GDB Command Line and Vector Catch

1,049 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JAlvarez on Tue Jul 10 12:57:36 MST 2012
Two questions:

1. How can the "vector catch" option be enabled when using GDB from the command line?

2. Would this handler to break into the debugger in a hard fault work with the LPCXpresso toolchain?

void HardFault_Handler (void) {
  if (CoreDebug->DHCSR & 1) { // check C_DEBUGEN == 1 -> Debugger Connected
    __breakpoint (0); // halt program execution here
  }
  while (1); // enter endless loop otherwise
}

It came from this Keil app note.

http://www.keil.com/appnotes/files/apnt209.pdf
Application Note 209 - Using Cortex-M3 and Cortex-M4 Fault Exceptions

Thanks.

BTW - The command line GDB document in the Wiki should be updated to list the LPC18xx/LPC43xx driver (crt_emu_lpc18_43_nxp).

http://support.code-red-tech.com/CodeRedWiki/UsingGDB
0 Kudos
Reply
2 Replies

933 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Wed Jul 11 08:21:32 MST 2012

Quote: JAlvarez

2. Would this handler to break into the debugger in a hard fault work with the LPCXpresso toolchain?

void HardFault_Handler (void) {
  if (CoreDebug->DHCSR & 1) { // check C_DEBUGEN == 1 -> Debugger Connected
    __breakpoint (0); // halt program execution here
  }
  while (1); // enter endless loop otherwise
}



Basically, yes, but you'll need to replace the " __breakpoint (0)" with something like...

    asm ("bkpt 0x0;");
Note that when executed , you'll probably get the debugger reporting an unknown breakpoint when it halts.

I would also suggest that you take a look at:

http://support.code-red-tech.com/CodeRedWiki/DebugHardFault

http://knowledgebase.nxp.com/showthread.php?t=1921


Quote:

BTW - The command line GDB document in the Wiki should be updated to list the LPC18xx/LPC43xx driver (crt_emu_lpc18_43_nxp).

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

Thanks, now updated.

Regards,
CodeRedSupport
0 Kudos
Reply

933 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JAlvarez on Wed Jul 11 07:26:46 MST 2012
In case others are looking for this, the option is -vc as indicated in the --help output (below) of the crt_emu* utilities.

C:\Tools>crt_emu_lpc18_43_nxp --help
Usage:
 crt_emu_lpc18_43_nxp [-v | -info-x | -flash-x] [arguments]
 Standalone use (without GDB):
-v                 Display version and build date information only.
-info-target       Connects to target (without stopping) and returns
                   information on processor and chip. Format will be XML if
                   -mi specified, else text. Same as 'mon info,all' in GDB.
-info-emu          Show list of emulators possible.
-info-scan         List devices on shared scan chain. The output from this
                   command can be used as the file for the '-scan=' option
                   provided all IR lengths are known, and a '*' is appended
                   to the IR Length value of the device to connect.
-flash-x           Perform operation on flash and then quit. 'x' is one of:
   driver          load external flash driver
                   (e.g. -flash-driver="<path>\LHF00L28.cfx"
   erase           erase all flash page by page
   mass            mass erase all flash
   load=file       erase/load ELF file to target (e.g. '-flash-load=test.axf')
   load-exec=file  erase/load ELF file to target and start code execution from
                   reset
                   Note: Flash options may need -p, -c, and/or -x to be used.
   protect=        Set flash read protection level (e.g. -flash-protect=1)
                   Note: Restricted for use with -flash-load option. Accepts a
                   comma-separated list (e.g. LMI FMPPEn|FMPREn).
-load-base=x       Base address/offset of binary file. Use with '-flash-load'.
                   May be specified in hex or decimal (e.g. '-load-base=0x200')
 Arguments for use with GDB (in 'target extended-remote |' command):
-p                 Set 'package' (chip and/or board, e.g. -pChipName. Package
                   implies XML file name or entry in XML file for chip/board.
                   Note: This argument is not needed for certain auto-detect
                   chips (e.g. LMI).
-c                 Set xtal speed for chip, if needed, and optionally PLL (KHz)
                   (e.g. -c8000[,50000])
-lfile             Log file enable (e.g. '-lFileName'). If no file is given,
                   log output is stderr (also default if -# used without -l).
-#                 Log level. Default is Comms (1). Levels are:
                   0=none, 1=comms, 2=+target, 3=+parse-errs, 4=+commands
-e                 Select emulator by number 0-9 if more than one is available
                   (see '-info-emu')
-s                 Maximum emulator speed (KHz) (e.g. -s1000)
                   Note: Defaults to auto-detect.
-xpath             Set path for XML files (and other chip/board data files)
                   (e.g. -xc:\xml)
-g                 Progress meter for extended operations (e.g. flash load)
-mi                Assume GDB communication via MI. Output will be for
                   Eclipse consumption vs. user readable.
-reset=            Cortex-M reset method. Default is SYSRESETREQ, specified as
                   '-reset=system'. VECTRESET is '-reset=core'.
-rd=ddd            Reset delay time in milliseconds after nSRST release
                   Note: This is a stablize period before debug connect.
-rh=hhh            Reset hold time in milliseconds for nSRST assert
-scan=             ASCII configuration file for shared JTAG scan chains
                   (e.g. -scan=C:\Projects\scanconfig.txt)
-wire=             Wire type. Supported types are jtag (ARM7/ARM9 default),
                   swd (CM0/CM3 default), hid, and winusb. Compound types
                   include winusbjtag, hidswd, etc.
-swv-port=         Set SWV server port (e.g. -swv-port=9990)
-server=           Server mode (socket) with host:port or :port
-vc                Reset vector catch (simulated on some parts)
0 Kudos
Reply