This is a vscode project template for yocto project cross-compile environment. It is based on the yocto project and vscode. It is a simple and easy-to-use template for yocto project cross-compile environment. It can be used to develop and debug applications on the target board. It can also be used to develop and debug applications on the host machine.
- C/C++ (ms-vscode.cpptools)
- C/C++ Extension Pack (ms-vscode.cpptools-extension-pack)
- CMake (twxs.cmake)
- CMake Tools (ms-vscode.cmake-tools)
- Task Explorer (spmeesseman.vscode-taskexplorer)
- gdbserver
- gdb
- openssh-server
The cmake-kits.json file is used to configure the cross-compile environment. You need to modify the following parameters according to your own situation:
[
{
"name": "Yocto-Poky: GCC/G++ for x86_64-pokysdk-linux",
"compilers": {
"C": "/opt/poky/3.3.4/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc",
"CXX": "/opt/poky/3.3.4/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-g++"
},
"environmentSetupScript": "/opt/poky/3.3.4/environment-setup-corei7-64-poky-linux",
"toolchainFile": "/opt/poky/3.3.4/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake"
}
]The settings.json file is used to configure the debugging and deployment environment. You need to modify the following parameters according to your own situation:
{
"customVariables": {
// Target
"TARGET_IP": "192.168.2.100",
"TARGET_GDB_PORT": "3000",
"TARGET_SSH_USER": "root",
"TARGET_SSH_PASSWORD": "",
"TARGET_EXECUTABLE_PATH": "/home/root",
"TARGET_ARCHITECTURE": "x86_64",
"EXECUTABLE_NAME": "helloWorld",
// Host
"HOST_EXECUTABLE_PATH": "${workspaceFolder}/bin",
}
}You can select the active kit by clicking the "Select a Kit" button in the lower left corner of the vscode window. The active kit is the cross-compile environment you want to use.
You can select the build variant by clicking the "Select a Build Variant" button in the lower left corner of the vscode window. The build variant is the build type you want to use. For debugging with gdb, you need to select the "Debug" build variant. For deployment to the target, you need to select the "Release" build variant.
Tasks can be run by clicking the "Run Task" button in the lower left corner of the vscode window. The following tasks are provided:
CMake: BuildCMake: ConfigureDeploy ExecutableStop GDB ServerKill GDB ServerStart GDB Server
If CMake: Build task is executed successfully, you can deploy the executable to the target by clicking the "Run Task" button in the lower left corner of the vscode window. Select the Deploy Executable task and click the "Run Selected Task" button.
If CMake: Build task is executed successfully, you can debug the executable on the target by clicking the "Run Task" button in the lower left corner of the vscode window. Select the Start GDB Server task and click the "Run Selected Task" button. Then select the Run and Debug tab in the left sidebar of the vscode window and select Launch GDB Debugger in the drop-down list. Click the "Start Debugging" button to start debugging.

