Yocto Programming with VSCode
This guide describes how to use Visual Studio Code (VSCode) to develop and debug applications on the VAR-SOM-MX8M-NANO.
C/C++ Application Development and Debugging using CMake
VSCode has C/C++ and CMake extensions that make it easy to develop, build, and debug C/C++ applications. Microsoft has a detailed guide for getting started with CMake on Linux.
This section will extend Microsoft's guide to support cross compiling for Variscite IMX8 Yocto images.
Setup Host Computer Environment
Install VSCode
$ sudo snap install --classic code
Install VSCode Extensions
To learn how to install and manage extensions using VSCode, please review Using extensions in Visual Studio Code
Instead, we will install the extensions using the command line:
$ code --install-extension ms-vscode.cmake-tools $ code --install-extension ms-vscode.cpptools
Install required dependencies (tested with Ubuntu 20.04):
$ sudo apt update $ sudo apt-get install build-essential gdb cmake $ sudo snap install --classic code
Install Yocto Toolchain
To install the toolchain, follow Yocto Toolchain installation guide.
Build a "Hello World" CMake project using VSCode
Create an empty project directory and open VSCode:
$ mkdir ~/var-hello-world $ cd ~/var-hello-world $ source /opt/fsl-imx-xwayland/5.4-zeus/environment-setup-aarch64-poky-linux $ code .
Open the VSCode Command Palette (Ctrl+Shift+P
) and run the CMake: Quick Start
command.
Enter a project name and select 'Create an Executable'. This will create a new "Hello World" CMake project.
Next, select a kit informing VSCode where the toolchain compiler is. Open the Command Palette (Ctrl+Shift+P
) and run the CMake: Select a kit
command and select aarch64-poky-linux
Open the Command Palette (Ctrl+Shift+P
) and run the CMake: Build
command
Deploy the binary to the target device:
$ scp build/hello root@192.168.0.174:
Run the binary on the target device:
# ./hello Hello, world!