Why I Started Using This Tool
With the Makefile working, the next job was the steps around the build: copying the binary to
the board, starting a remote debugger, attaching to it. When I started writing those out, I kept typing
the same things: the toolchain path, the board's IP address, the root user, port 2345.
I've been burned before by an IP address hard-coded in three different scripts, where I updated two and
lost an evening to the third. So this time I wanted every one of those values in one file, before I
wrote the first real automation task.
What It Does
VS Code lets each project keep its own .vscode/settings.json, and you're allowed to add
your own keys to it. I put seven values there: toolchain, bin,
localDir, remoteDir, target, user, and
gdbPort. Anything in tasks.json or launch.json can then write
${config:target} or ${config:bin}, and VS Code puts in the real value right
before the command runs.
Here's what my .vscode/settings.json looks like (paths and IP swapped for placeholders):
{
"toolchain": "C:/gcc-linaro-5.1-arm-linux-gnueabihf",
"bin": "main",
"localDir": "C:/projects/my_embedded_app",
"remoteDir": "/home/root",
"target": "192.168.1.100",
"user": "root",
"gdbPort": "2345"
}
To prove it, I made a one-line demo task that just echoes three of the settings. I ran it
from Tasks: Run Task and watched the real toolchain path, binary name, and project
folder show up in the terminal. Then I changed a value, ran it again, and the new value appeared without
touching the task file at all.
And the demo task in .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Demo Task Pull from Settings.json",
"type": "shell",
"command": "echo \"${config:toolchain} ${config:bin} ${config:localDir}\"",
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
Final Verdict
It isn't glamorous, and the demo task literally just prints some text. But this is one of those five-minute setups that pays off every time the project grows. Every build, deploy, and debug task I add from here on reads from the same seven settings. If my board gets a new IP, or I move the project to another machine, I edit one file and everything else follows.
If you're starting an embedded project in VS Code, I'd set this up before your first real task. It costs almost nothing, and it heads off the "why is deploy suddenly broken" kind of bug before you ever hit it.