BELK-TN-009: Integrating Visual Studio Code with a cross-toolchain

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
Bora5-small.jpg Applies to Bora
BORA Xpress.png Applies to BORA Xpress
BORALite-TOP.png Applies to BORA Lite
1200px-Visual Studio Code 1.35 icon.svg.png Applies to Visual Studio Code


Warning-icon.png This technical note was validated against specific versions of hardware and software. What is described here may not work with other versions. Warning-icon.png

History[edit | edit source]

Version Date Notes
1.0.0 June 2020 First public release

Introduction[edit | edit source]

This Technical Note (TN) shows how to integrate Visual Studio Code (VSC) and a cross-toolchain in order to

  • cross-build a Makefile-based application
  • capture errors generated by the cross-tools to edit erroneous lines easily.

Testbed[edit | edit source]

To test the procedure, the same testbed described here was used. Therefore, the application used to validate the procedure is freertos_hello_world. In any case, the configuration described here can be easily adapted to different use cases.

With regard to VSC, the following version was used:

Version: 1.41.1 (system setup)
Commit: 26076a4de974ead31f97692a0d32f90d735645c0
Date: 2019-12-18T14:58:56.166Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 6.1.7601

VSC/cross-toolchain integration[edit | edit source]

This example shows how to build the freertos_hello_world application and how to catch errors generated by the cross-toolchain in order to edit the erroneous source files accordingly.

As it was tested on a Windows PC, it requires Cygwin to work.

First, create a Default Build Task as described here. The tasks.json file should look like this:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Cross build",
            "type": "shell",
            "command": "SET PATH=e:\\Xilinx\\SDK\\2019.1\bin\\;e:\\Xilinx\\SDK\\2019.1\\gnu\\aarch32\\nt\\gcc-arm-none-eabi\\bin\\;c:\\cygwin64\\bin\\;%PATH% && make",
            "options": {
                "cwd": "${workspaceRoot}/Debug"
            },
            "problemMatcher": "$gcc",
            "presentation": {
                "reveal": "always",
                "panel": "new"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}


By pressing 'Ctrl+Shift+B, the build process is started:

Starting the cross-building process


If there are syntax errors, Ctrl + Left click ...

The output of the cross-toolchain


... allows to jump to the erroneous line:

Catching the syntax error


This example makes use of the C/C++ extension. It is convenient to configure it so that it can access include files although they are outside the project's directory. By pressing Ctrl+Shift+P and selecting C/C++ Edit Configurations (JSON), it is possible to create a c_cpp_properties.json:


Catching the syntax error


Then, modify the includePath variable as shown in the following box:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/../freertos_hello_world_bsp/ps7_cortexa9_0/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c11",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}


After modifying includePath, no more issues are reported in the PROBLEMS window:

The output of the cross-toolchain


For more details, please see also this page.