Visual Studio Code

From KONNEKTING Wiki
Revision as of 05:44, 10 August 2018 by Konnekting (talk | contribs)
Jump to navigation Jump to search

Hotkeys

  • F1 - InputConsole
  • F5 - Start Debugging
  • CTRL+ALT+R - Verify Arduino Project
  • CTRL+ALT+U - Upload Arduino Project
  • CTRL-Shift+O - Current outline: Shows list of variables and methods of current opened file

User-Settings

{
    "arduino.path": "/home/achristian/arduino-1.8.5", // <-- Your Arduino IDE folder
    "arduino.logLevel": "verbose",
    "C_Cpp.intelliSenseEngine": "Tag Parser",
    "C_Cpp.clang_format_fallbackStyle": "LLVM", // <-- For using the correct code formatter when doing auto-format
    "arduino.additionalUrls": [
         // Arduino 3rd party core download URLs you use
        "http://digistump.com/package_digistump_index.json",
        "http://downloads.arduino.cc/Hourly/samd/package_samd-hourly-build_index.json",
        "https://github.com/esp8266/Arduino/releases/download/2.4.0-rc2/package_esp8266com_index.json"
    ],
    "C_Cpp.default.browse.path": [
        "/media/bigdisk/Programming/Arduino/Sketchbook/libraries",         // <-- Path to the Arduino Libraries Folder (typically in Sketchbook folder)
        "/home/achristian/arduino-1.8.5/hardware/arduino",                 // <-- Path to base Arduino hardware folder for common Arduino API
        "/home/achristian/.arduino15/packages",                            // <-- Path to the downloaded Arduino Cores like ESP8266, Arduino Zero, ...
        "${workspaceRoot}"                                                 // <-- Variable pointing to your current project workspace root
    ],
    "editor.wordWrap": "on"    
}

Debugging

Visual Studio Code is storing the dbug configuration in a file called "launch.json".

{
    // Verwendet IntelliSense zum Ermitteln möglicher Attribute.
    // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
    // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Arduino - STLink v2",
            "type": "arduino",
            "request": "launch",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "MIMode": "gdb",
            "targetArchitecture": "arm",
            "miDebuggerPath": "/home/achristian/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb",
            "debugServerPath": "/home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino6-static/bin/openocd",
            "debugServerArgs": " -f /home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino6-static/share/openocd/scripts/interface/stlink-v2.cfg -f /media/bigdisk/Programming/Arduino/at91samdXXZero.cfg -s /home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino6-static/share/openocd/scripts",

            "customLaunchSetupCommands": [
                {
                    "text": "target remote localhost:3333"
                },
                {
                    "text": "file \"${file}\""
                },
                {
                    "text": "load"
                },
                {
                    "text": "monitor reset halt"
                },
                {
                    "text": "monitor reset init"
                }
            ],
            "stopAtEntry": true,
            "serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
            "launchCompleteCommand": "exec-continue",
            "filterStderr": true,
            "args": []
        },
        {
            "name": "Arduino - Atmel ICE - SAMD",
            "type": "arduino",
            "request": "launch",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "MIMode": "gdb",
            "targetArchitecture": "arm",
            "miDebuggerPath": "/home/achristian/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gdb",
            "debugServerPath": "/home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino6-static/bin/openocd",
            "debugServerArgs": " -d2 -s /home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino6-static/share/openocd/scripts/ -f /home/achristian/.arduino15/packages/arduino/hardware/samd/1.6.19/variants/arduino_zero/openocd_scripts/arduino_zero.cfg",
            "customLaunchSetupCommands": [
                {
                    "text": "target remote localhost:3333"
                },
                {
                    "text": "file \"${file}\""
                },
                {
                    "text": "load"
                },
                {
                    "text": "monitor reset halt"
                },
                {
                    "text": "monitor reset init"
                }
            ],
            "stopAtEntry": true,
            "serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
            "launchCompleteCommand": "exec-continue",
            "filterStderr": true,
            "args": [],
            "logging": { "trace": true, "traceResponse": true, "engineLogging": true }
        }
    ]
}

Copy & paste the content shown here to you file and adapt the paths contained in the following parameters to match your system/installation:

  • miDebuggerPath
  • debugServerPath
  • debugServerArgs

ST-Link v2

For ST-Link v2 there's an extra file that you need to download to your harddrive and set the path accordingly:

https://raw.githubusercontent.com/DeqingSun/Debug-Arduino-Zero-with-ST-Link-V2/master/at91samdXXZero.cfg

For more information about VSC with STLinkv2, see: https://github.com/DeqingSun/Debug-Arduino-Zero-with-ST-Link-V2