OpenOCD V0.8.0, mbed LPC1768, cmsis-dap - problems

Hi Everyone,

I am trying to get OpenOCD up and running correctly with an mbed LPC1768. The setup/versions I am running is:

  • OS X 10.9.4;

    GNU ARM GCC 8.4 2014 Q2 from launchpad;

    mbed LPC1768 with firmware version 141212;

    OpenOCD V0.8.0 installed via homebrew;


  • I am using the simplest possible code, it just blinks one of the built in led’s on the mbed lpc1768 every 100ms, I have exported this from the mbed online compiler, compiled with my local GCC and put the bin on to the mbed in the normal way. This works without issue.

    I then start OpenOCD with the default mbed-lpc1768.cfg config file, this finds the board without problem.

    I launch gdb, halt the mbed, load the code and when I attempt to start the code it does not function as expected, gdb output below:

    stevembp:HelloWorld steve$ arm-none-eabi-gdb HelloWorld.elf 
    GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140529-cvs
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "--host=x86_64-apple-darwin10 --target=arm-none-eabi".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>...
    Reading symbols from /Users/steve/Documents/Development/HelloWorld/HelloWorld.elf...done.
    (gdb) 
    (gdb) 
    (gdb) target remote localhost:3333
    Remote debugging using localhost:3333
    0x00000000 in __isr_vector ()
    (gdb) mon reset halt
    target state: halted
    target halted due to debug-request, current mode: Thread 
    xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
    (gdb) load
    Loading section .text, size 0x6f9c lma 0x0
    Loading section .ARM.exidx, size 0x8 lma 0x6f9c
    Loading section .data, size 0xb4 lma 0x6fa4
    Start address 0x308, load size 28760
    Transfer rate: 67 bytes/sec, 7190 bytes/write.
    (gdb) continue
    Continuing.
    lpc1768.cpu -- clearing lockup after double fault
     
    Program received signal SIGINT, Interrupt.
    0x00000000 in __isr_vector ()
    

    The output from the OpenOCD session is:

    stevembp:Development steve$ openocd -f /usr/local/share/openocd/scripts/board/mbed-lpc1768.cfg 
    Open On-Chip Debugger 0.8.0 (2014-08-27-15:37)
    Licensed under GNU GPL v2
    For bug reports, read
        http://openocd.sourceforge.net/doc/doxygen/bugs.html
    Info : only one transport option; autoselect 'cmsis-dap'
    Info : CMSIS-DAP: SWD  Supported
    Info : CMSIS-DAP: Interface Initialised (SWD)
    adapter speed: 10 kHz
    adapter_nsrst_delay: 200
    cortex_m reset_config sysresetreq
    Info : CMSIS-DAP: FW Version = 1.0
    Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
    Info : DAP_SWJ Sequence (reset: 50+ '1' followed by 0)
    Info : CMSIS-DAP: Interface ready
    Info : clock speed 10 kHz
    Info : IDCODE 0x2ba01477
    Info : lpc1768.cpu: hardware has 6 breakpoints, 4 watchpoints
    Info : accepting 'gdb' connection from 3333
    undefined debug reason 7 - target needs reset
    target state: halted
    target halted due to debug-request, current mode: Thread 
    xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
    Warn : negative acknowledgment, but no packet pending
    Warn : negative acknowledgment, but no packet pending
    Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1001). Workaround: increase "set remotetimeout" in GDB
    Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1027). Workaround: increase "set remotetimeout" in GDB
    target state: halted
    target halted due to debug-request, current mode: Thread 
    xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
    Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (5069). Workaround: increase "set remotetimeout" in GDB
    Warn : Verification will fail since checksum in image (0x00000000) to be written to flash is different from calculated vector checksum (0xefff6cc6).
    Warn : To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
    Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (401105). Workaround: increase "set remotetimeout" in GDB
    Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1158). Workaround: increase "set remotetimeout" in GDB
    target state: halted
    target halted due to debug-request, current mode: Thread 
    xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
    Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (5029). Workaround: increase "set remotetimeout" in GDB
    Error: lpc1768.cpu -- clearing lockup after double fault
    Polling target lpc1768.cpu failed, GDB will be halted. Polling again in 100ms
    Polling target lpc1768.cpu succeeded again
    

    The actual code that is being compiled and flashed is below:

    #include "mbed.h"
     
    DigitalOut myled(LED1);
     
    int main() {
        myled = 0;
        while(1) {
            myled = !myled;
            wait(0.1);
        }
    }
    

    I do not believe this is an issue with the code, the way that I am compiling it or the mbed as when I use pyOCD the same elf binary works as expected and I can step through the code.

    I have also tried this using the current OpenOCD development stream (also installed via homebrew) and I get exactly the same output.

    Any help would be gratefully received.

    Kind Regards,

    Steve

    Hi Steve,

    That program counter just after the mon reset halt looks like trouble. I have an LPC1768 board that I’ve pretty much set aside after endless frustration trying to get openOCD and/or GDB to sync up after reset. The fact that the bootloader always runs complicates things. IMO if you’re using NXP parts it might be worth the $$ for one of the commercial development tools. If you search the forums you’ll find a number of recommendations, all of whom apparently have solved that problem.

    Some things I’ve done to get ST parts to sync up using openOCD:

  • - issue *reset halt* via telnet session to openocd before connecting with gdb
  • - load the code via telnet session before connecting with gdb
  • - try *mon gdb_sync* from GDB
  • With NXP parts:

  • - at times I've seemed to have intermittent success adding a delay of a few msec in crt0.s to allow openocd to get control
  • - To do the above you have to get the code into the device. I've sometimes fallen back on the serial port bootloader (the one I've been maligning) for that. Of course that only works if your board supports it.
  • I know it *has* to be simpler than I make it sound or NXP would not be so popular...

    -Hugh

    Try to add these lines to the cfg file

    reset_config trst_and_srst

    adapter_nsrst_delay 20

    lpc17xx.cpu configure -event gdb-attach {

    reset halt

    }

    lpc17xx.cpu configure -event gdb-detach {

    resume

    }