This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Software breakpoints with J-Link probe

Hi,

I am not able to make software breakpoints working with a Segger J-Link probe.

As an exemple, here is my assert callback function:

void __attribute__((noreturn)) __assert_func(const char *file, int line, const char *func, const char *failedexpr) {
  asm volatile("bkpt");
  abort();
}

My program should be stopped automatically when entering any assert function. In general, I would like to stop the execution of my program using the asm volatile("bkpt") instruction.

Using an ST-Link v2 probe, the code above works. Unfortunately, it doesn't work with a Segger J-Link probe. Any experience with this ? Is any specific configuration require to make this working ?

Note: I use the latest available J-Link firmware "SEGGER J-Link Lite-Cortex-M V8.00" with SEGGER J-Link V5.12 software.

Parents
  • Thanks @hungbui. ; are missing in your code ;)

    My problem is not a compilation issue. Is use the exact same code with the GNU GDB debugger and it works. With a J-Link Lite probe, I get the following messages:

    Read 4 bytes @ address 0x00023544 (Data = 0x46F7BE01)
    Starting target CPU...
    Read 4 bytes @ address 0x00023544 (Data = 0x46F7BE01)
    Starting target CPU...
    [etc...]
    

    The software breakpoint is not working with my setup unfortunately :(

    Update 2016/05/25:

    The following code can be used with GCC:

    static inline void break_here(void) {
      __asm volatile(
        "bkpt #0x01\n\t"
        "mov pc, lr\n\t"
      );
    }
    

    This code only works with my Segger J-Link lite probe and the Segger tools 5.10m. It doesn't work with the the latest Segger version5.12...

    Update 2016/07/08:

    The error has been reported to Segger and they fix the problem. GDB 7.10 changed something in the way breakpoints halt execution, and current SEGGER JLinkGDBServer had problems to correctly inform GDB about the BKPT.

    Software breakpoints work fine again from Segger tools version V5.12h. You should update the tools manually to the latest available version. You can download it from here: www.segger.com/.../jlink

Reply
  • Thanks @hungbui. ; are missing in your code ;)

    My problem is not a compilation issue. Is use the exact same code with the GNU GDB debugger and it works. With a J-Link Lite probe, I get the following messages:

    Read 4 bytes @ address 0x00023544 (Data = 0x46F7BE01)
    Starting target CPU...
    Read 4 bytes @ address 0x00023544 (Data = 0x46F7BE01)
    Starting target CPU...
    [etc...]
    

    The software breakpoint is not working with my setup unfortunately :(

    Update 2016/05/25:

    The following code can be used with GCC:

    static inline void break_here(void) {
      __asm volatile(
        "bkpt #0x01\n\t"
        "mov pc, lr\n\t"
      );
    }
    

    This code only works with my Segger J-Link lite probe and the Segger tools 5.10m. It doesn't work with the the latest Segger version5.12...

    Update 2016/07/08:

    The error has been reported to Segger and they fix the problem. GDB 7.10 changed something in the way breakpoints halt execution, and current SEGGER JLinkGDBServer had problems to correctly inform GDB about the BKPT.

    Software breakpoints work fine again from Segger tools version V5.12h. You should update the tools manually to the latest available version. You can download it from here: www.segger.com/.../jlink

Children
  • I really don't know what problem you're having but I can tell you this code works with GCC every time, including on the current JLINK version, I use it in my hardfault handler to toss me out to the debugger and I was using it today because .. it's been Hardfault Wednesday

    .....

        volatile uint32_t __attribute__((unused)) pc_ret	= stacked_data[ 6 ];
        volatile uint32_t __attribute__((unused)) xPSR		= stacked_data[ 7 ];
    
    	__BKPT(0);
    }
    
  • Thanks for your help @rols. With my setup, the processor is not stopped when I use your code.

    • JLinkARM.dll V5.12f
    • Target device nRF51822_xxAA
    • Firmware: J-Link Lite-Cortex-M V8
    • GNU ARM C/C++ J-Link Debugging version 3.2.1.201604190915
    • arm-none-eabi-gcc.exe (GNU Tools for ARM Embedded Processors) version 5.3.1 20160307

    But it's working with the Segger tools version 5.10m.

  • try the segger forums then because it seems none of the rest of us have this issue - they may have something to suggest.

  • Yes, I posted a message on the Segger forum and I also opened an issue on the gnuarmeclipse Github repo. Thanks for your help !

Related