This guide describes how to use Visual Studio Code to build, flash, and debug with the MXChip AZ3166 IoT DevKit.
This is a companion to the Quickstart Guide. Please ensure you have completed the following steps of the Quickstart Guide before continuing.
Note: It is not necessary to install the tools described in the quickstart guide. Tool installation will be covered in the next section below.
This section shows how to configure your development environment with the new vcpkg-ce
, short for "configure environment", bootstraps project dependencies from a manifest file, vcpkg-configuration.json
. This makes it easy to express which compilers and build tools are required by a project. Upon activation, the tools specified by the manifest are added to the path of the current shell. If the tools are not present, vcpkg-ce
acquires them and installs them to a common location. The vcpkg-ce
tool runs in user mode without elevation.
vcpkg-ce
is in early preview. To report problems or provide feedback, please open issues at https://github.com/microsoft/vcpkg-ce.
-
Download and install Visual Studio Code.
-
Download and install the ST-LINK Drivers. Restart your computer after installation is complete.
-
Open an Administrator PowerShell terminal and enable execution of PowerShell scripts.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
-
Open a new PowerShell terminal and navigate to the following path in the repo.
getting-started\MXChip\AZ3166
-
Install
vcpkg-ce
.iex (iwr -useb aka.ms/vcpkg-init.ps1)
-
Download, install, and activate developer tools.
vcpkg activate
-
Run the following code to confirm that CMake version 3.20 or later is installed.
cmake --version
-
Use this terminal to complete the remaining tasks in this guide.
-
Download and install Visual Studio Code.
-
Open a new bash terminal and navigate to the following path in the repo.
getting-started\MXChip\AZ3166
-
Create
/etc/udev/rules.d/99-az3166.rules
to permit non-root access to the device.echo -e 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE:="0666"\nKERNEL=="ttyACM*", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE:="0666"' | sudo tee /etc/udev/rules.d/99-az3166.rules
-
Install
curl
andlibncurses5
using your package manager.sudo apt install curl libncurses5
-
Install
vcpkg-ce
.. <(curl aka.ms/vcpkg-init.sh -L)
-
Download, install, and activate developer tools.
vcpkg activate
-
Ensure the following lines in getting-started\MXChip\AZ3166.vscode\tasks.json have been commented out.
// This must be commented out to run on Linux. // "options": { // "shell": { // "executable": "cmd.exe", // "args": [ "/c" ] // } // }
-
Run the following code to confirm that CMake version 3.20 or later is installed.
cmake --version
-
Use this terminal to complete the remaining tasks in this guide.
-
Connect the Micro USB cable from the DevKit to your computer. If it is already connected, disconnect and reconnect it.
-
Launch Visual Studio Code from a PowerShell terminal.
code .
-
Accept the popup that appears in the lower right corner prompting you to install recommended extensions.
If it does not appear, you can also invoke the “Extensions: Show Recommended Extensions” command from the Command Palette (
Ctrl-Shift-P
).Completing this step will install the following extensions: C/C++ and CMake Tools.
-
If prompted for a Configure Preset, select "arm-gcc-cortex-m4".
-
If on the right side of the Status Bar, No Build Preset is selected:
Click it and choose the "arm-gcc-cortex-m4" Build Preset.
-
Navigate to the Run and Debug view (
Ctrl-Shift-D
) and select the Launch configuration. -
Press
F5
to start debugging the application.Visual Studio Code will build and flash the application to the device, then pause the debugger at the application entry point.
-
Press
F5
to resume execution. The debugger is now running and connected the device.
vcpkg-ce
only modifies the path in the shell in which it is activated. If you close your shell and wish to restore the development environment in a future session:
-
Open a new PowerShell terminal.
-
Re-activate
vcpkg-ce
.. ~/.vcpkg/vcpkg activate
-
Launch Visual Studio Code.
code .