So made jtag-upload task.
Tested under Windows only, but under Unix should work too
Limitation:
OpenOCD must be stopped before lunch this task.
1. Add new task in tasks.json:
{
"label": "Flash - Flash jtag",
"type": "shell",
"presentation": {
"focus": true
},
"command": "${config:idf.pythonBinPathWin} ${workspaceRoot}/.vscode/flash_jtag.py",
"windows": {
"command": "${config:idf.pythonBinPathWin} ${workspaceRoot}/.vscode/flash_jtag.py"
},
"options": {
"env": {
"PATH": "${config:idf.customExtraPaths}",
"OPENOCD_SCRIPTS": "${command:espIdf.getOpenOcdScriptValue}",
"OPENOCD_CONFIG": "${command:espIdf.getOpenOcdConfigs}",
"BUILD_DIR": "${workspaceRoot}\\build"
},
},
"problemMatcher": [
{
"owner": "py",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
{
"owner": "py",
"fileLocation": "absolute",
"pattern": {
"regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
]
}
2. Create and put "flash_jtag.py" file into .vscode folder
import subprocess
import os
import json
oocdScripts = os.environ["OPENOCD_SCRIPTS"]
oocdConfig = os.environ["OPENOCD_CONFIG"]
buildDir = os.environ["BUILD_DIR"]
oocdScripts = oocdScripts.replace("\\", "/")
builoocdConfigdDir = oocdConfig.replace("\\", "/")
buildDir = buildDir.replace("\\", "/")
cmd = "openocd.exe -s " + oocdScripts + " " + oocdConfig
with open(os.path.join(buildDir, "flasher_args.json")) as f:
flasher_args = json.load(f)
for addr in flasher_args["flash_files"]:
cmd = cmd + " -c \"program_esp32 " + buildDir + "/" + flasher_args["flash_files"][addr] + " " + addr + " verify exit\""
cmd = cmd + " -c \"reset\""
# Comment this, if exit from OpenOCD not needed
cmd = cmd + " -c \"exit\""
print("Executing:\n" + cmd)
print("")
os.system(cmd)