Official VSCode Extension for ESP-IDF Projects - jtag upload

simark1979
Posts: 5
Joined: Wed Sep 09, 2020 5:18 pm

Official VSCode Extension for ESP-IDF Projects - jtag upload

Postby simark1979 » Wed Sep 09, 2020 5:27 pm

Question to extension developers:
When jtag uploading will be implemented in official extension?
Uploading via serial port takes to much time.
And in my case, impossible: my device has no serial port on pcb, jtag only
So I cannot use your extension(

Does anybody implemeted this future?

Thank you!

boarchuz
Posts: 604
Joined: Tue Aug 21, 2018 5:28 am

Re: Official VSCode Extension for ESP-IDF Projects - jtag upload

Postby boarchuz » Thu Sep 10, 2020 4:42 am

You already got some very helpful answers here:
https://github.com/espressif/vscode-esp ... issues/161
(Actually it looks like this was just approved but you posted much earlier, so sorry for the attitude)

Perhaps a VS Code task that builds and then executes the command provided by pwmb would work for you.
https://code.visualstudio.com/docs/editor/tasks

simark1979
Posts: 5
Joined: Wed Sep 09, 2020 5:18 pm

Re: Official VSCode Extension for ESP-IDF Projects - jtag upload

Postby simark1979 » Fri Sep 11, 2020 4:53 am

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:
  1.         {
  2.             "label": "Flash - Flash jtag",
  3.             "type": "shell",
  4.             "presentation": {
  5.                 "focus": true
  6.             },
  7.             "command": "${config:idf.pythonBinPathWin} ${workspaceRoot}/.vscode/flash_jtag.py",
  8.             "windows": {
  9.                 "command": "${config:idf.pythonBinPathWin} ${workspaceRoot}/.vscode/flash_jtag.py"
  10.             },
  11.             "options": {
  12.                 "env": {
  13.                     "PATH": "${config:idf.customExtraPaths}",
  14.                     "OPENOCD_SCRIPTS": "${command:espIdf.getOpenOcdScriptValue}",
  15.                     "OPENOCD_CONFIG": "${command:espIdf.getOpenOcdConfigs}",
  16.                     "BUILD_DIR": "${workspaceRoot}\\build"
  17.                 },
  18.             },
  19.             "problemMatcher": [
  20.                 {
  21.                     "owner": "py",
  22.                     "fileLocation": [
  23.                         "relative",
  24.                         "${workspaceFolder}"
  25.                     ],
  26.                     "pattern": {
  27.                         "regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
  28.                         "file": 1,
  29.                         "line": 2,
  30.                         "column": 3,
  31.                         "severity": 4,
  32.                         "message": 5
  33.                     }
  34.                 },
  35.                 {
  36.                     "owner": "py",
  37.                     "fileLocation": "absolute",
  38.                     "pattern": {
  39.                         "regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
  40.                         "file": 1,
  41.                         "line": 2,
  42.                         "column": 3,
  43.                         "severity": 4,
  44.                         "message": 5
  45.                     }
  46.                 }
  47.             ]
  48.         }

2. Create and put "flash_jtag.py" file into .vscode folder
  1. import subprocess
  2. import os
  3. import json
  4.  
  5. oocdScripts = os.environ["OPENOCD_SCRIPTS"]
  6. oocdConfig = os.environ["OPENOCD_CONFIG"]
  7. buildDir = os.environ["BUILD_DIR"]
  8.  
  9. oocdScripts = oocdScripts.replace("\\", "/")
  10. builoocdConfigdDir = oocdConfig.replace("\\", "/")
  11. buildDir = buildDir.replace("\\", "/")
  12.  
  13. cmd = "openocd.exe -s " + oocdScripts + " " + oocdConfig
  14.  
  15. with open(os.path.join(buildDir, "flasher_args.json")) as f:
  16.     flasher_args = json.load(f)
  17.  
  18. for addr in flasher_args["flash_files"]:
  19.     cmd = cmd + " -c \"program_esp32 " + buildDir + "/" + flasher_args["flash_files"][addr] + " " + addr + " verify exit\""
  20.  
  21. cmd = cmd + " -c \"reset\""
  22.  
  23. # Comment this, if exit from OpenOCD not needed
  24. cmd = cmd + " -c \"exit\""
  25.  
  26. print("Executing:\n" + cmd)
  27. print("")
  28.  
  29. os.system(cmd)

User avatar
ESP_Soumesh
Posts: 19
Joined: Tue Jul 09, 2019 2:21 pm

Re: Official VSCode Extension for ESP-IDF Projects - jtag upload

Postby ESP_Soumesh » Tue Sep 15, 2020 1:26 am

OpenOCD must be stopped before lunch this task.
Yes because the task need to connect via openocd to upload bins

Who is online

Users browsing this forum: No registered users and 45 guests