Using VS Code with a real project#

The previous example shows how to build a target binary using XCommon CMake, how to run it on the target and how to flash the target with the binary.

If a new project is created, it should be based on the XTC Tools example examples\ExampleXCommonCMake, by copying this example into the top level of the new project. This ensures it can be built with XCommon CMake and it can be run and flashed using VS Code.

If an existing project is to be used with VS Code the .vscode directory should be copied from the example into the top-level of this project.

Note: if this .vscode directory is copied from an existing workspace, ensure the settings.json does not contain additional lines (written by VS Code). Some lines written by VS Code may contain paths which are invalid for the new project.

The tasks.json file will need to be amended to pick up the target binary built by the project for running on the target and for flashing the target.

Specifying extra arguments to xrun and xflash#

Additional command line arguments are typically required. These are supplied in the "args" list which is associated with a command,

For example, if multiple targets and corresponding XTAG adapters are connected to the host machine, an adapter id must be specified to run and flashing steps. This can be done by modifying the tasks.json file to add an argument, as shown below:

{
    "tasks": [
        {
            "label": "Run example.xe",
            "command": "xrun",
            "args": [
                // each argument is supplied on the command line is provided in the list of strings below
                "--adapter-id",
                "4NV62AKC"
                "--io",
                "${workspaceFolder}/bin/example.xe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": []
        },
        {
            "label": "Flash example.xe",
            "command": "xflash",
            "args": [
                // each argument is supplied on the command line is provided in the list of strings below
                "--adapter-id",
                "4NV62AKC"
                "${workspaceFolder}/bin/example.xe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": []
        }
    ]
}