Marus/cortex-debug

OpenOCD does not get stopped after the debug session on Windows

boraozgen opened this issue · 0 comments

Describe the bug

OpenOCD does not get stopped after the debug session on Windows. This causes the next session to fail with Error: libusb_open() failed with LIBUSB_ERROR_ACCESS.

To Reproduce
Steps to reproduce the behavior:

  1. Start debug session
  2. Stop debug session
  3. Check task manager

Expected behavior

OpenOCD should exit when the debug session is closed.

Environment (please complete the following information):

  • Cortex-Debug: 1.2.1
  • OS: Windows 11
  • GDB Version: GNU gdb (GNU Arm Embedded Toolchain 10.3-2021.10) 10.2.90.20210621-git

Please include launch.json

{
    "name": "Debug openocd",
    "type": "cortex-debug",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "executable": "${command:cmake.getLaunchTargetPath}",
    "servertype": "openocd",
    "configFiles": [
        "scripts/openocd.cfg",
    ],
    "runToEntryPoint": "main",
}

openocd.cfg

# Interface
source [find interface/stlink.cfg]
# Transport selection
transport select hla_swd
# Target
source [find target/stm32f4x.cfg]

Attach text from Debug Console

Redacting required, will share if needed.

Additional context

As a workaround I added a postDebugTask to the launch config.

{
	"type": "shell",
	"label": "Kill OpenOCD",
	"command": "taskkill",
	"args": [
		"/F",
		"/IM",
		"openocd.exe"
	],
	"problemMatcher": []
}