Skip to content

Instantly share code, notes, and snippets.

@robotdad
Created July 20, 2016 00:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robotdad/7e573a6b39058c8ee1c32b184141afaf to your computer and use it in GitHub Desktop.
Save robotdad/7e573a6b39058c8ee1c32b184141afaf to your computer and use it in GitHub Desktop.
vscode-arduino-jsons
{
"version": "0.2.0",
"configurations": [
{
"name": "Arduino attach (Windows)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "C:/Users/mgoodner/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb.exe",
"targetArchitecture": "ARM",
"program": "D:/Source/Sketchbook/builds/${fileBasename}.elf",
"setupCommands": [
{"text": "target remote localhost:3333"},
{"text": "file D:/Source/Sketchbook/builds/${fileBasename}.elf"},
{"text": "monitor reset halt"}
],
"customLaunchSetupCommands": [
{"text": "monitor reset init"}
],
"launchCompleteCommand": "exec-continue",
"debugServerPath": "C:/Users/mgoodner/AppData/Local/Arduino15/packages/arduino/tools/openocd/0.9.0-arduino/bin/openocd.exe",
"debugServerArgs": "-s \"C:/Users/mgoodner/AppData/Local/Arduino15/packages/arduino/tools/openocd/0.9.0-arduino/share/openocd/scripts/\" -f \"C:/Users/mgoodner/AppData/Local/Arduino15/packages/arduino/hardware/samd/1.6.6/variants/arduino_zero/openocd_scripts/arduino_zero.cfg\"",
"serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
"filterStderr": true,
"externalConsole": true,
"cwd": "${cwd}"
},
{
"name": "Arduino attach (Mac)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "/Users/Marc/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb",
"targetArchitecture": "ARM",
"program": "/Users/Marc/Documents/Arduino/builds/${fileBasename}.elf",
"setupCommands": [
{"text": "target remote localhost:3333"},
{"text": "file /Users/Marc/Documents/Arduino/builds/${fileBasename}.elf"},
{"text": "monitor reset halt"}
],
"customLaunchSetupCommands": [
{"text": "monitor reset init"}
],
"launchCompleteCommand": "exec-continue",
"debugServerPath": "/Users/Marc/Library/Arduino15/packages/arduino/tools/openocd/0.9.0-arduino/bin/openocd",
"debugServerArgs": "-s \"/Users/Marc/Library/Arduino15/packages/arduino/tools/openocd/0.9.0-arduino/share/openocd/scripts/\" -f \"/Users/Marc/Library/Arduino15/packages/arduino/hardware/samd/1.6.6/variants/arduino_zero/openocd_scripts/arduino_zero.cfg\"",
"serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
"filterStderr": true,
"externalConsole": true,
"cwd": "${cwd}"
},
{
"name": "Arduino attach (Linux)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "/home/marc/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb",
"targetArchitecture": "ARM",
"program": "/home/marc/Arduino/builds/${fileBasename}.elf",
"setupCommands": [
{"text": "target remote localhost:3333"},
{"text": "file /home/marc/Arduino/builds/${fileBasename}.elf"},
{"text": "monitor reset halt"}
],
"customLaunchSetupCommands": [
{"text": "monitor reset init"}
],
"launchCompleteCommand": "exec-continue",
"debugServerPath": "/home/marc/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino/bin/openocd",
"debugServerArgs": "-s \"/home/marc/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino/share/openocd/scripts/\" -f \"/home/marc/.arduino15/packages/arduino/hardware/samd/1.6.6/variants/arduino_zero/openocd_scripts/arduino_zero.cfg\"",
"serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
"filterStderr": true,
"cwd": "${workspaceRoot}"
}
]
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"windows": {
"command": "C:\\Program Files (x86)\\Arduino\\arduino.exe"
},
"linux": {
"command": "/home/marc/arduino-1.6.9/arduino"
},
"osx": {
"command": "/Applications/Arduino.app/Contents/MacOS/Arduino"
},
"isShellCommand": true,
"showOutput": "always",
"echoCommand": true,
"tasks": [
{
"suppressTaskName": true,
"taskName": "Verify",
"isBuildCommand": true,
"args":[ "--verify", "--verbose", "${file}"],
"problemMatcher":
{
"owner":"ino",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern":
{
"regexp": "^(.*):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"suppressTaskName": true,
"taskName": "Upload",
"args":["--upload", "--verbose", "${file}"],
"problemMatcher":
{
"owner":"ino",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern":
{
"regexp": "^(.*):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
@robotdad
Copy link
Author

The examples here are showing how to use VS Code to drive the Arduino IDE from VS code for build/deploy (tasks.json). The launch.json file shows how to attach VS Code to an Arduino Zero for debugging. No, sorry it will not work with an AVR board. It should be able to be modified for other boards that have the hardware to support OpenOCD connections.

You need to set the Arduino IDE to the board you are using and specify the port before using the tasks.json. Make sure to close it at least once so the choices are set to the Arduino preferences file used during build/deploy. Both examples will need to be modified for your environment as paths to tools etc. are from my machines and haven't been parameterized. Also, I set the build.path option in the Arduino IDE preferences so I know where the .elf file is dropped for the debug example (not necessary if all you care about is build/deploy).

The launch.json example for debug requires that you have the C++ Extenstion installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment