This will allow you to start and stop OpenOCD automatically while keeping it minimized.
Modify or create .vscode/tasks.json in your project:
Code: Select all
{
"version": "2.0.0",
"tasks": [
{
"label": "Build and Start OpenOCD",
"dependsOn": ["Start OpenOCD", "Build"],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Build",
"type": "shell",
"command": "cmd.exe",
"args": [
"/C", "cd /D "${workspaceFolder}" && call C:\Espressif\idf_cmd_init.bat && idf.py build"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "Start OpenOCD",
"type": "shell",
"windows": {
"command": "cmd.exe",
"args": [
"/C", "start", "/MIN", "openocd.exe",
"-c", "set ESP_RTOS none",
"-f", "interface/ftdi/esp32_devkitj_v1.cfg",
"-f", "target/esp32s3.cfg",
"-c", "transport select jtag"
]
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Stop OpenOCD",
"type": "shell",
"windows": {
"command": "taskkill",
"args": ["/F", "/IM", "openocd.exe"]
},
"problemMatcher": []
}
]
}☑ Keeps OpenOCD minimized (doesn't interrupt your work).
☑ Runs automatically before debugging.
☑ Stops OpenOCD after debugging to free system resources.
Modify .vscode/launch.json to match your ESP32-S3 setup:
Code: Select all
{
"version": "0.2.0",
"configurations": [
{
"name": "OpenOCD ESP32",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceFolder}/build",
"program": "${workspaceFolder}/build/RK-LedBlink.elf",
"miDebuggerPath": "xtensa-esp32-elf-gdb.exe",
"setupCommands": [
{ "text": "target remote 127.0.0.1:3333" },
{ "text": "set remote hardware-watchpoint-limit 2" },
{ "text": "monitor reset halt" },
{ "text": "flushregs" },
{ "text": "mon program_esp build/bootloader/bootloader.bin 0x0 verify" },
{ "text": "mon program_esp build/partition_table/partition-table.bin 0x8000 verify" },
{ "text": "mon program_esp build/RK-LedBlink.bin 0x10000 verify" },
{ "text": "monitor reset halt" },
{ "text": "flushregs" }
],
"preLaunchTask": "Build and Start OpenOCD",
"postDebugTask": "Stop OpenOCD"
}
]
}The addresses for bootloader.bin, partition-table.bin, and RK-LedBlink.bin must match your build configuration.
To find the correct addresses, check flasher_args.json inside build/ after running idf.py build.
Example command:
sh
Copy
Edit
cat build/flasher_args.json
OpenOCD starts automatically and runs in the background.
launch.json ensures the debugger loads the firmware correctly.
The task system builds, starts OpenOCD, and stops it after debugging.
VSCode may show a warning like "Debug anyway?" → Click it to continue debugging.
☑ This method automates debugging without annoying popups.
☑ OpenOCD runs minimized and does not steal focus.
☑ Correct memory addresses are fetched from the build system.
☑ Debugging in VS Code becomes smooth and efficient.
Now, start debugging like a pro!
✔ Used instead of
✔ Used ☑ instead of
✔ Added clearer instructions on memory addresses (flasher_args.json).
✔ Ensured everything follows proper BBCode syntax.