[ABANDONED] J-Link with JLinkGDBServer has to flash twice

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [ABANDONED] J-Link with JLinkGDBServer has to flash twice

    Hi,

    I'm trying to use JLink debugging with CLion, so far so good. I managed to connect the GDB Server, flash the device, debug, read registers etc.. wonderfully.
    However, when I make a change and want to start debugging again, the JLink flash download erases the flash, but doesn't seem to program the device.

    When the flash&erase fails:
    Display Spoiler

    SEGGER J-Link GDB Server V7.56d GUI Version


    JLinkARM.dll V7.56d (DLL compiled Oct 29 2021 14:01:36)


    -----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: localhost only
    Generate logfile: off
    Verify download: off
    Init regs on start: on
    Silent mode: off
    Single run mode: off
    Target connection timeout: 5000 ms
    ------J-Link related settings------
    J-Link Host interface: USB
    J-Link script: none
    J-Link settings file: none
    ------Target related settings------
    Target device: STM32H735VG
    Target interface: SWD
    Target interface speed: 4000kHz
    Target endian: little


    Connecting to J-Link...
    J-Link is connected.
    Firmware: J-Link V11 compiled Oct 26 2021 16:23:48
    Hardware: V11.00
    S/N: redacted
    Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
    Checking target voltage...
    Target voltage: 3.38 V
    Listening on TCP/IP port 2331
    Connecting to target...
    Connected to target
    Waiting for GDB connection...Connected to 127.0.0.1
    Reading all registers
    Read 2 bytes @ address 0x08049BF4 (Data = 0xB508)
    Read 4 bytes @ address 0x00000000 (Data = 0xA7D18CB9)
    Read 2 bytes @ address 0x00000000 (Data = 0x8CB9)
    Downloading 716 bytes @ address 0x08000000
    Downloading 16032 bytes @ address 0x080002D0
    Downloading 16064 bytes @ address 0x08004170
    Downloading 16016 bytes @ address 0x08008030
    Downloading 15904 bytes @ address 0x0800BEC0
    Downloading 15968 bytes @ address 0x0800FCE0
    Downloading 15904 bytes @ address 0x08013B40
    Downloading 15920 bytes @ address 0x08017960
    Downloading 15968 bytes @ address 0x0801B790
    Downloading 15984 bytes @ address 0x0801F5F0
    Downloading 16032 bytes @ address 0x08023460
    Downloading 16160 bytes @ address 0x08027300
    Downloading 16160 bytes @ address 0x0802B220
    Downloading 16176 bytes @ address 0x0802F140
    Downloading 16192 bytes @ address 0x08033070
    Downloading 16080 bytes @ address 0x08036FB0
    Downloading 16080 bytes @ address 0x0803AE80
    Downloading 16032 bytes @ address 0x0803ED50
    Downloading 16080 bytes @ address 0x08042BF0
    Downloading 16128 bytes @ address 0x08046AC0
    Downloading 7184 bytes @ address 0x0804A9C0
    Downloading 16288 bytes @ address 0x0804C5D0
    Downloading 16352 bytes @ address 0x08050570
    Downloading 16320 bytes @ address 0x08054550
    Downloading 16320 bytes @ address 0x08058510
    Downloading 16288 bytes @ address 0x0805C4D0
    Downloading 16352 bytes @ address 0x08060470
    Downloading 10344 bytes @ address 0x08064450
    Downloading 8 bytes @ address 0x08066CB8
    Downloading 220 bytes @ address 0x08066CC0
    Downloading 20 bytes @ address 0x08066D9C
    Downloading 228 bytes @ address 0x08066DB0
    Writing register (PC = 0x 800e8b4)
    Read 2 bytes @ address 0x08049BF4 (Data = 0xB508)
    Received monitor command: reset
    Resetting target
    Starting target CPU...
    ...Target halted (DBGRQ, PC = 0xFFFFFFFE)
    Reading all registers
    WARNING: Failed to read memory @ address 0xFFFFFFFE
    Read 4 bytes @ address 0x24021A04 (Data = 0x240088C4)
    Read 4 bytes @ address 0x2400891C (Data = 0x0000000E)
    Read 4 bytes @ address 0x24008924 (Data = 0x00000000)
    Read 4 bytes @ address 0x240088C4 (Data = 0x24008874)
    Read 4 bytes @ address 0x240088AC (Data = 0x08015ECD)
    Read 4 bytes @ address 0x240088F4 (Data = 0x240080C4)
    Reading 32 bytes @ address 0x240088F8
    Read 4 bytes @ address 0x240088F0 (Data = 0x00000000)
    Read 4 bytes @ address 0x240088C4 (Data = 0x24008874)
    Read 4 bytes @ address 0x240088EC (Data = 0x00000000)
    Read 4 bytes @ address 0x24008918 (Data = 0x240088C0)
    Reading 2044 bytes @ address 0x240080C4
    Reading 64 bytes @ address 0xFFFFFFC0
    WARNING: Failed to read memory @ address 0xFFFFFFC0
    WARNING: Failed to read memory @ address 0xFFFFFFFE
    Reading 64 bytes @ address 0xFFFFFBC0
    WARNING: Failed to read memory @ address 0xFFFFFBC0
    WARNING: Failed to read memory @ address 0xFFFFFBFE
    WARNING: Failed to read memory @ address 0xFFFFFFF4
    Reading 64 bytes @ address 0xFFFFFFC0
    WARNING: Failed to read memory @ address 0xFFFFFFC0
    WARNING: Failed to read memory @ address 0xFFFFFFF0
    Reading 64 bytes @ address 0xFFFFFFC0
    WARNING: Failed to read memory @ address 0xFFFFFFC0
    WARNING: Failed to read memory @ address 0xFFFFFFF0


    GDB ends with the following output:

    Source Code

    1. 0x00000000 in ?? ()
    2. Program received signal SIGTRAP, Trace/breakpoint trap.
    3. 0xfffffffe in ?? ()
    4. (gdb)



    For reference, the diff between a success and a failure log is the following:
    Display Spoiler

    Difference-File

    1. diff --git a/logs b/logs-failed
    2. index aa40178..663a02a 100644
    3. --- a/logs
    4. +++ b/logs-failed
    5. @@ -82,4 +82,32 @@ Writing register (PC = 0x 800e8b4)
    6. Read 2 bytes @ address 0x08049BF4 (Data = 0xB508)
    7. Received monitor command: reset
    8. Resetting target
    9. -Starting target CPU...
    10. \ No newline at end of file
    11. +Starting target CPU...
    12. +...Target halted (DBGRQ, PC = 0xFFFFFFFE)
    13. +Reading all registers
    14. +WARNING: Failed to read memory @ address 0xFFFFFFFE
    15. +Read 4 bytes @ address 0x24021A04 (Data = 0x240088C4)
    16. +Read 4 bytes @ address 0x2400891C (Data = 0x0000000E)
    17. +Read 4 bytes @ address 0x24008924 (Data = 0x00000000)
    18. +Read 4 bytes @ address 0x240088C4 (Data = 0x24008874)
    19. +Read 4 bytes @ address 0x240088AC (Data = 0x08015ECD)
    20. +Read 4 bytes @ address 0x240088F4 (Data = 0x240080C4)
    21. +Reading 32 bytes @ address 0x240088F8
    22. +Read 4 bytes @ address 0x240088F0 (Data = 0x00000000)
    23. +Read 4 bytes @ address 0x240088C4 (Data = 0x24008874)
    24. +Read 4 bytes @ address 0x240088EC (Data = 0x00000000)
    25. +Read 4 bytes @ address 0x24008918 (Data = 0x240088C0)
    26. +Reading 2044 bytes @ address 0x240080C4
    27. +Reading 64 bytes @ address 0xFFFFFFC0
    28. +WARNING: Failed to read memory @ address 0xFFFFFFC0
    29. +WARNING: Failed to read memory @ address 0xFFFFFFFE
    30. +Reading 64 bytes @ address 0xFFFFFBC0
    31. +WARNING: Failed to read memory @ address 0xFFFFFBC0
    32. +WARNING: Failed to read memory @ address 0xFFFFFBFE
    33. +WARNING: Failed to read memory @ address 0xFFFFFFF4
    34. +Reading 64 bytes @ address 0xFFFFFFC0
    35. +WARNING: Failed to read memory @ address 0xFFFFFFC0
    36. +WARNING: Failed to read memory @ address 0xFFFFFFF0
    37. +Reading 64 bytes @ address 0xFFFFFFC0
    38. +WARNING: Failed to read memory @ address 0xFFFFFFC0
    39. +WARNING: Failed to read memory @ address 0xFFFFFFF0
    40. \ No newline at end of file
    Display All



    Running the program again makes it all work correctly where the old code is overwritten and it flashes happily.

    My question then is, is it possible to force JLinkGDBServerCL to erase the storage? And if not, how could I fix this?

    For completeness, the GDB server args I'm passing are:

    Source Code

    1. -select USB -device STM32H735VG -if SWD -speed 4000 -ir
  • Hi,

    Neither of the 2 logs do really make sense to me right now.
    Could you please send a J-Link logfile for each case (1 working, 1 non-working)?
    wiki.segger.com/Enable_J-Link_log_file#J-Link_GDB_Server


    BR
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • I've attached a zip with two files, one "gdb_log_good.txt" for when the flash succeeded and "gdb_log_bad.txt" for when the flash did not succeed.
    I've also tried running JLinkGDBServerCL with the -singlerun flag but that didn't help unfortunately.
    Files
    • gdb_log.zip

      (621.19 kB, downloaded 199 times, last: )
  • Hi,

    I have an idea where the problem may come from.
    Not sure where (or even if) you can enable “reset before download” in CLion, but can you please turn it on and try again?


    BR
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Thanks for the hint Alex!
    It was indeed necessary to reset the target before downloading.
    To do this, I had to:
    1. allow local .gdbinit scripts in my project by adding a `.gdbinit` to my home directory with the following content:

    Source Code: %HOME%/.gdbinit

    1. set auto-load local-gdbinit on
    2. add-auto-load-safe-path /

    2. add a hook to the local .gdbinit that resets the target when that hook is reached, by adding the following .gdbinit to the root of my project:

    Source Code: %PROJECT_ROOT%/.gdbinit

    1. define target hookpost-remote
    2. monitor reset
    3. end
  • If you can provide an ELF file that shows the problem without reset and runs on an eval board, we can fix the weakness in the flash algo, so it will work even without reset.

    BR
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.