cortex-debug: JLink: Remote doesn't know how to detach (from interpreter-exec console "detach")

I have a need identical #445 (embedded developer need to flash program often but not always single step debugging).

cortex debug v1.6.6 I use latest jflash 7.80d GDB from GNU Arm Embedded Toolchain 10.3-2021.10

my launch.json:

        {
            "type": "cortex-debug",
            "request": "launch",
            "servertype": "jlink",
            "cwd": "${workspaceRoot}",
            // https://vector-of-bool.github.io/docs/vscode-cmake-tools/debugging.html
            "executable": "${command:cmake.launchTargetPath}",
            "name": "Flash program (J-Link)",
            "device": "STM32U575QI",
            "interface": "swd",
            "serverArgs": [
            ],
            "ipAddress": null,
            "serialNumber": null,
            "postLaunchCommands": [
                "monitor reset",
                "monitor go",
                "detach",
            ],
            "showDevDebugOutput": true,
        },

the output:

-> 13^done
14-interpreter-exec console "monitor reset"
-> @"Resetting target\r\n"
Resetting target
-> 14^done
15-interpreter-exec console "monitor go"
-> 15^done
16-interpreter-exec console "detach"
-> ~"Detaching from program: C:\\FW.axf, Remote target\n"
Detaching from program: C:\FW.axf, Remote target
-> &"Remote doesn't know how to detach\n"
Remote doesn't know how to detach
-> 16^error,msg="Remote doesn't know how to detach"
Failed to launch GDB: Remote doesn't know how to detach (from interpreter-exec console "detach")

This is the end of jlink log file. It seems “detach” doesn’t go down to jlink. Problem must be in GDB

00-00000824-00-00004386-000E: $qRcmd,676f#2c
03-00000000-00-00004386-001D: Received monitor command: go

03-00000000-00-00004386-0017: Starting target CPU...

02-00000000-00-00004386-0022: T1344 004:389.720 JLINK_IsHalted()
02-00000000-00-00004386-0028: T1344 004:389.747 - 0.028ms returns TRUE
02-00000000-00-00004386-003D: T1344 004:389.775 JLINK_GoEx(MaxEmulInsts = -1, Flags = 0x00)
02-00000000-00-00004386-0035: T1344 004:389.808   CPU_ReadMem(4 bytes @ 0xE0001000)
02-00000000-00-00004387-0036: T1344 004:390.131   CPU_WriteMem(4 bytes @ 0xE0001004)
02-00000000-00-00004387-001B: T1344 004:390.717 - 0.943ms
01-00000824-00-00004387-0006: $OK#9a
00-00000824-00-00004401-0005: $D#44
01-00000824-00-00004401-0004: $#00

“Disconnect” instead of “detach” works but from what I read here disconnect will not let the target run.

I want to be able to flash my target and if possible avoid to do a manual reset (power on or external) to effectively run the program. Can you help me out ?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19

Most upvoted comments

@haneefdm You are quite pessimistic here. We took the effort and got involved here, so of course we also considered to engage further…

Will be fixed in today’s version (V7.82b) which is expected to go online within the next 4 hours from now. https://www.segger.com/downloads/jlink/

I finished testing and it appears that JLink detach is working as expected. Mind you this is not an exhaustive test and Cortex-Debug does a few things beyond what gdb calls for for a clean detach and I didn’t want to disable any of that. All gdb servers have some latent issues with detach and hence our cleanup prior to detach.

I know in my own company, they will appreciate this even though they may have to modify the tests to change expected false -ve to a +ve.

Thanks @SEGGER-Alex, @atsju

I am closing this now.

Reopened as promised. I will test V7.82b this weekend. I don’t think any changes will be required for this extension as we do the same thing for all gdb-servers.

Thanks again @SEGGER-Alex

@atsju, you can have a go at V7.82b when it is available…you may be able to get to it before I can.

@atsju I am closing this. If SEGGER wants to engage on this can re-open. I don’t have any hope for that.