This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Running GDB with SES and nRF52840DK

RTT seems to be mostly working using the viewer with the command:

JLinkRTTViewer -device nRF52840_xxAA

It seems I need to re-connect each time I start a debug from SES, but this is okay. What I really need thought is to get gdb communicating during a debug. Starting with the command:

JLinkGDBServer -device nRF52840_xxAA -endian little -if SWD -speed 400kHz

seems to connect but then hangs without a prompt, and I can't run any gdb commands, anything typed in the window has no effect. I running under Ubuntu 18.04

> uname -a
Linux granite10192.168.1.23 4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

SEGGER J-Link GDB Server V6.73b (beta) Command Line Version

JLinkARM.dll V6.73b (DLL compiled May 15 2020 17:24:15)

Command line: -device nRF52840_xxAA -endian little -if SWD -speed 400kHz
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      yes
Generate logfile:              off
Verify download:               off
Init regs on start:            off
Silent mode:                   off
Single run mode:               off
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 nRF52840_xxAA
Target interface:              SWD
Target interface speed:        400kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Mar 17 2020 14:43:00
Hardware: V1.00
S/N: 683455871
Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...
Connected to target
Waiting for GDB connection...

Parents
  • Something is not going right. Sometimes it seems to work, most of the time not. For example:

    1)

    • Debug -> Debugger -> Target Connection to "GDB Server"
    • Debug -> GDB Server -> Type to "J-Link"

    2) In one termal:

    > JLinkGDBServer -device nRF52840_xxAA -endian little -if SWD -speed 400kHz
    SEGGER J-Link GDB Server V6.73b (beta) Command Line Version

    JLinkARM.dll V6.73b (DLL compiled May 15 2020 17:24:15)

    Command line: -device nRF52840_xxAA -endian little -if SWD -speed 400kHz
    -----GDB Server start settings-----
    GDBInit file:                  none
    GDB Server Listening port:     2331
    SWO raw output listening port: 2332
    Terminal I/O port:             2333
    Accept remote connection:      yes
    Generate logfile:              off
    Verify download:               off
    Init regs on start:            off
    Silent mode:                   off
    Single run mode:               off
    Target connection timeout:     0 ms
    ------J-Link related settings------
    J-Link Host interface:         USB
    J-Link script:                 none
    J-Link settings file:          none
    ------Target related settings------
    Target device:                 nRF52840_xxAA
    Target interface:              SWD
    Target interface speed:        400kHz
    Target endian:                 little

    Connecting to J-Link...
    J-Link is connected.
    Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Mar 17 2020 14:43:00
    Hardware: V1.00
    S/N: 683455871
    Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
    Checking target voltage...
    Target voltage: 3.30 V
    Listening on TCP/IP port 2331
    Connecting to target...
    Connected to target
    Waiting for GDB connection...

    3) My .gdbinit file:

    define hlt
      monitor reset
    end
    define ld
      file pca10056/blank/ses/Output/Debug/Exe/twi_sensor_pca10056.elf
    end
    alias dsc=disconnect
    alias to=advance
    ld
    target remote localhost:2331
    hlt

    4) In second terminal:

    > arm-none-eabi-gdb
    GNU gdb (7.10-1ubuntu3+9) 7.10
    Copyright (C) 2015 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <gnu.org/.../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-linux-gnu --target=arm-none-eabi".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <www.gnu.org/.../>.
    Find the GDB manual and other documentation resources online at:
    <www.gnu.org/.../>.
    For help, type "help".
    Type "apropos word" to search for commands related to "word".
    0x00005798 in TMP117_write_reg (pntr=0 '\000', val=60)
        at /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c:174
    174    ret_code_t TMP117_write_reg(uint8_t pntr, uint16_t val) {
    Resetting target
    (gdb)

    5)

    There should not be a breakpoint at line 174? This is left over from something previous, I will now try and clear all break points, put a single breakpoint at the beginning of main() in main.c and stop there

    (gdb) del
    (gdb) b
    Breakpoint 1 at 0x5798: file /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c, line 174.
    (gdb) del
    Delete all breakpoints? (y or n) y
    (gdb) b
    Breakpoint 2 at 0x5798: file /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c, line 174.
    (gdb)

    6)

    Note, the breakpoint can't be deleted. The two attempts have different replies, but the breakpoint still remains. I will now try and reset again, and clear all breakpoints

    (gdb) b
    Breakpoint 1 at 0x5798: file /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c, line 174.
    (gdb) del
    Delete all breakpoints? (y or n) y
    (gdb) b
    Breakpoint 2 at 0x5798: file /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c, line 174.
    (gdb) hlt
    Resetting target
    (gdb) b
    Note: breakpoint 2 also set at pc 0x5798.
    Breakpoint 3 at 0x5798: file /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c, line 174.
    (gdb) del
    Delete all breakpoints? (y or n) y
    (gdb) b
    Breakpoint 4 at 0x5798: file /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c, line 174.
    (gdb)

    Still can't delete it,

    (gdb) cl 174
    Deleted breakpoint 4
    (gdb) b
    Breakpoint 5 at 0x5798: file /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c, line 174.
    (gdb)

    Still can't delete it. Let's try and put a breakpoint at the beginning of main and stop there

    (gdb) b main
    Breakpoint 6 at 0x5b4c: file /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c, line 359.
    (gdb) c
    Continuing.

    Breakpoint 5, 0x00005798 in TMP117_write_reg (pntr=0 '\000', val=60)
        at /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c:174
    174    ret_code_t TMP117_write_reg(uint8_t pntr, uint16_t val) {
    (gdb)

    It skipped the breakpoint at the beginning of main and kept going until the breakpoint at line 174, and bt doesn't work.

    (gdb) bt
    #0  0x00005798 in TMP117_write_reg (pntr=0 '\000', val=60)
        at /home/martin/Dropbox/Nordic/SDK/Workspace/Peripheral/twi_sensor/main.c:174
    #1  0x1a2e058a in ?? ()
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)
    (gdb)

    Some other questions: I need gdb so I can do the equivalent of calling a function at a breakpoint. Is it possible to do something like this directly in SES using jlink rather than GDB Server? I see there is a debug window, but it doesn't respond to gdb like commands.

    Second question, running SES with jlink, I can see variables in the local window, and I can see some variables in the global window, but I can't see my static global variables in the global window, although when I hover over them with the mouse, I can see their values.

    Finally, have I missed some documentation that explains how to use gdb with SES, the Segger documentation has almost no information.

    When I quite everything, and started back up, the break point situation seemed to get better. But when I changed the code, and rebuilt the binary, the break points stopped working correctly again. It looks like there is something going wrong with the GDB Server and running gdb (at least to me).

  • Hi,

     

    My apologies for the late response

    For the questions related to segger embedded studio, and the advanced debugging features you're trying to do, I would recommend that you contact Segger directly and ask them, as they have more knowledge about their products than we do.

     

    kw_martin said:
    Some other questions: I need gdb so I can do the equivalent of calling a function at a breakpoint

    This is possible in gdb. Please see this thread: https://devzone.nordicsemi.com/f/nordic-q-a/24081/call-function-from-gdb-at-breakpoint

    If you think there's any breakpoints present, you can list these in gdb by entering "info b". I suspect that you are halting the CPU at certain points in time, thus you see it running on different stages of your firmware.

     

    Kind regards,

    Håkon

Reply Children
No Data
Related