Skip to content

Commit 0b1e06e

Browse files
gcampbell-msftaleunryanwinter
authored
Adding VS and CMakePresets Support (#297)
* Merged PR 342104: Adding option for VS to Getting Started Guides (CMakeSettings.json) Created CMakeSettings.json template and launch.vs.json template in order to allow for building of embedded cmake projects in VS. Also using new postRemoteConnectCommands field in launch.vs.json in order to flash the board. Related work items: #1362476, #1362477, #1362479, #1362489, #1362490, #1362491 * Merged PR 348557: Removed unnecessary reset flag Removed unnecessary reset flag from the NXP launch.vs.json debug server args. * Merged PR 342106: Morphing VS Getting Started Guides to use CMakePresets.json Changed Getting Started Guide to use CMakePresets.json. This doesn't break anything in VSCode as the CMakePresets.json has a configured Configure Preset AND Build Preset. Related work items: #1362481, #1362482, #1362483, #1362484, #1362489, #1362490, #1362491 * remove cmakesettings.json * Fix broken image links * removed empty defaults * removed extra } Co-authored-by: Alan Leung <34582775+aleun@users.noreply.github.com> Co-authored-by: Ryan Winter <ryanwinter@outlook.com>
1 parent d573491 commit 0b1e06e

30 files changed

+557
-12
lines changed

MXChip/AZ3166/.vs/launch.vs.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"version": "0.2.1",
3+
"configurations": [
4+
{
5+
"project": "CMakeLists.txt",
6+
"projectTarget": "mxchip_azure_iot.elf (app\\mxchip_azure_iot.elf)",
7+
"name": "Launch",
8+
"type": "cppdbg",
9+
"request": "launch",
10+
"cwd": "${workspaceRoot}",
11+
"program": "${debugInfo.fullTargetPath}",
12+
"MIMode": "gdb",
13+
"miDebuggerPath": "arm-none-eabi-gdb",
14+
"miDebuggerServerAddress": "localhost:3333",
15+
"debugServerPath": "openocd",
16+
"debugServerArgs": "-f board/stm32f4discovery.cfg",
17+
"serverStarted": "Listening on port .* for gdb connections",
18+
"filterStderr": true,
19+
"stopAtConnect": true,
20+
"hardwareBreakpoints": {
21+
"require": true,
22+
"limit": 6
23+
},
24+
"postRemoteConnectCommands": [
25+
{
26+
"text": "-target-download",
27+
"ignoreFailures": false
28+
},
29+
{
30+
"text": "-interpreter-exec console \"monitor reset halt\"",
31+
"ignoreFailures": false
32+
}
33+
]
34+
}
35+
]
36+
}

MXChip/AZ3166/.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"debugServerArgs": "-f board/stm32f4discovery.cfg",
3939
"serverStarted": "Listening on port .* for gdb connections",
4040
"filterStderr": true,
41-
"stopAtEntry": true,
41+
"stopAtConnect": true,
4242
"hardwareBreakpoints": {
4343
"require": true,
4444
"limit": 6

MXChip/AZ3166/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
2424
include(utilities)
2525

2626
# Define the Project
27-
project(mxchip_azure_iot C ASM)
27+
# CXX enables IntelliSense only. Sources are still compiled as C.
28+
project(mxchip_azure_iot C CXX ASM)
2829

2930
# Disable common networking component, MXCHIP has it's own
3031
set(DISABLE_COMMON_NETWORK true)

MXChip/AZ3166/CMakePresets.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": 2,
3+
"configurePresets": [
4+
{
5+
"name": "arm-gcc-cortex-m4",
6+
"generator": "Ninja",
7+
"binaryDir": "${sourceDir}/build",
8+
"cacheVariables": {
9+
"CMAKE_BUILD_TYPE": "Debug",
10+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install",
11+
"CMAKE_TOOLCHAIN_FILE": {
12+
"type": "FILEPATH",
13+
"value": "${sourceDir}/../../cmake/arm-gcc-cortex-m4.cmake"
14+
}
15+
},
16+
"architecture": {
17+
"value": "unspecified",
18+
"strategy": "external"
19+
},
20+
"vendor": {
21+
"microsoft.com/VisualStudioSettings/CMake/1.0": {
22+
"intelliSenseMode": "linux-gcc-arm"
23+
}
24+
}
25+
}
26+
],
27+
"buildPresets": [
28+
{
29+
"name": "arm-gcc-cortex-m4",
30+
"configurePreset": "arm-gcc-cortex-m4"
31+
}
32+
]
33+
}

MXChip/AZ3166/VS.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Using Visual Studio with the MXChip AZ3166 IoT DevKit
2+
3+
This guide describes how to use Visual Studio to build, flash, and debug with the **MXChip AZ3166 IoT DevKit**.
4+
5+
This is a companion to the [Quickstart Guide](https://docs.microsoft.com/en-us/azure/iot-develop/quickstart-devkit-mxchip-az3166). Please ensure you have completed the following steps of the Quickstart Guide before continuing.
6+
7+
1. [Clone the repo for the quickstart](https://docs.microsoft.com/en-us/azure/iot-develop/quickstart-devkit-mxchip-az3166#clone-the-repo-for-the-quickstart).
8+
9+
1. [Create the cloud components](https://docs.microsoft.com/en-us/azure/iot-develop/quickstart-devkit-mxchip-az3166#create-the-cloud-components).
10+
11+
1. [Configure Wi-Fi and Azure IoT connection settings](https://docs.microsoft.com/en-us/azure/iot-develop/quickstart-devkit-mxchip-az3166#add-configuration).
12+
13+
_*Note: It is not necessary to install the tools described in the quickstart guide. Tool installation will be covered in the next section below.*_
14+
15+
## Configure Your Development Environment with vcpkg `ce`
16+
17+
This section shows how to configure your development environment with the new vcpkg `ce` tool: `ce`, short for "configure environment", bootstraps project dependencies from a manifest file, `environment.yaml`. 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, `ce` acquires them and installs them to a common location. The `ce` tool runs in user mode without elevation.
18+
19+
> `ce` is in early preview prior to being integrated as a part of `vcpkg`. To report problems or provide feedback, please open issues at https://github.com/microsoft/vcpkg-ce.
20+
21+
### Windows 10
22+
23+
1. Download and install [Visual Studio](https://visualstudio.microsoft.com/downloads/).
24+
25+
1. Download and install the [ST-LINK Drivers](https://www.st.com/en/development-tools/stsw-link009.html). Restart your computer after installation is complete.
26+
27+
1. Open an Administrator PowerShell terminal and enable execution of PowerShell scripts.
28+
29+
```PowerShell
30+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
31+
```
32+
33+
1. Open a new PowerShell terminal and navigate to the following path in the repo:
34+
35+
> *getting-started\MXChip\AZ3166*
36+
37+
1. Install `ce`.
38+
39+
```PowerShell
40+
iex (iwr -useb aka.ms/install-ce.ps1)
41+
```
42+
43+
1. Review the end-user license agreement at https://aka.ms/vcpkg-ce-eula.txt. Run the following command to accept.
44+
45+
```PowerShell
46+
ce --accept-eula
47+
```
48+
49+
1. Download, install, and activate developer tools.
50+
51+
```PowerShell
52+
ce activate
53+
```
54+
55+
1. Run the following code to confirm that CMake version 3.20 or later is installed.
56+
57+
```PowerShell
58+
cmake --version
59+
```
60+
61+
1. Use this terminal to complete the remaining tasks in this guide.
62+
63+
## Using Visual Studio
64+
65+
1. Connect the Micro USB cable from the DevKit to your computer. If it is already connected, disconnect and reconnect it.
66+
67+
1. Launch Visual Studio.
68+
69+
```Shell
70+
start devenv .
71+
```
72+
73+
1. Ensure that both the Configure Preset and the Build Preset are set to "arm-gcc-cortex-m4"
74+
75+
![configuration-choice](../../docs/media/vs-preset-configuration-m4.png)
76+
77+
1. Ensure that the "Launch" target is selected as the Debug Target.
78+
79+
![debug-target-choice](../../docs/media/vs-debug-target-az3166.png)
80+
81+
1. Press `F5` to start debugging the application.
82+
83+
> Visual Studio will build and flash the application to the device, then pause the debugger at the application entry point.
84+
85+
1. Press `F5` to resume execution. The debugger is now running and connected the device.
86+
87+
## Restoring Your Development Environment
88+
89+
`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:
90+
91+
1. Open a new terminal.
92+
93+
1. Re-activate `ce`.
94+
95+
```Shell
96+
. ~/.ce/ce activate
97+
```
98+
99+
1. Launch Visual Studio.
100+
101+
```Shell
102+
start devenv .
103+
```

MXChip/AZ3166/vscode.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,15 @@ This section shows how to configure your development environment with the new vc
136136
137137
> Completing this step will install the following extensions: [C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) and [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools).
138138
139-
1. If prompted for a CMake kit, select "ARM GCC Cortex".
139+
1. If prompted for a Configure Preset, select "arm-gcc-cortex-m4".
140140
141-
![cmake-kit](../../docs/media/vscode-az3166-cmake-kit.png)
141+
![configure-preset](../../docs/media/vscode-az3166-configure-preset.png)
142+
143+
1. If on the right side of the Status Bar, No Build Preset is selected:
144+
145+
![build-preset](../../docs/media/vscode-build-preset.png)
146+
147+
Click it and choose the "arm-gcc-cortex-m4" Build Preset.
142148
143149
1. Navigate to the Run and Debug view (`Ctrl-Shift-D`) and select the Launch configuration.
144150

NXP/MIMXRT1060-EVK/.vs/launch.vs.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"version": "0.2.1",
3+
"configurations": [
4+
{
5+
"project": "CMakeLists.txt",
6+
"projectTarget": "mimxrt1060_azure_iot.elf (app\\mimxrt1060_azure_iot.elf)",
7+
"name": "Launch",
8+
"type": "cppdbg",
9+
"request": "launch",
10+
"cwd": "${workspaceRoot}",
11+
"program": "${debugInfo.fullTargetPath}",
12+
"MIMode": "gdb",
13+
"miDebuggerPath": "arm-none-eabi-gdb",
14+
"miDebuggerServerAddress": "localhost:3333",
15+
"debugServerPath": "JLinkGDBServerCL",
16+
"debugServerArgs": "-if swd -speed 4000 -endian little -port 3333 -device MIMXRT1062xxx6A",
17+
"serverStarted": "Connected to target",
18+
"filterStdout": true,
19+
"stopAtConnect": true,
20+
// There is no need for hardware breakpoint limits with J-Link probes because they support unlimited flash breakpoints.
21+
// However, if desired, uncomment below to force use of hardware breakpoints only:
22+
// "hardwareBreakpoints": {
23+
// "require": true,
24+
// "limit": 8
25+
// },
26+
"postRemoteConnectCommands": [
27+
{
28+
"text": "-target-download",
29+
"ignoreFailures": false
30+
},
31+
{
32+
"text": "-interpreter-exec console \"monitor reset halt\"",
33+
"ignoreFailures": false
34+
}
35+
]
36+
}
37+
]
38+
}

NXP/MIMXRT1060-EVK/.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"debugServerArgs": "-if swd -speed 4000 -endian little -port 3333 -device MIMXRT1062xxx6A -x ${workspaceFolder}/.vscode/reset.gdb",
4141
"serverStarted": "Connected to target",
4242
"filterStdout": true,
43-
"stopAtEntry": true,
43+
"stopAtConnect": true,
4444
// There is no need for hardware breakpoint limits with J-Link probes because they support unlimited flash breakpoints.
4545
// However, if desired, uncomment below to force use of hardware breakpoints only:
4646
// "hardwareBreakpoints": {

NXP/MIMXRT1060-EVK/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ endif()
2121
include(${GSG_BASE_DIR}/cmake/utilities.cmake)
2222

2323
# Define the Project
24-
project(mimxrt1060_azure_iot C ASM)
24+
# CXX enables IntelliSense only. Sources are still compiled as C.
25+
project(mimxrt1060_azure_iot C CXX ASM)
2526

2627
add_subdirectory(${SHARED_SRC_DIR} shared_src)
2728
add_subdirectory(lib)

NXP/MIMXRT1060-EVK/CMakePresets.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": 2,
3+
"configurePresets": [
4+
{
5+
"name": "arm-gcc-cortex-m7",
6+
"generator": "Ninja",
7+
"binaryDir": "${sourceDir}/build",
8+
"cacheVariables": {
9+
"CMAKE_BUILD_TYPE": "Debug",
10+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install",
11+
"CMAKE_TOOLCHAIN_FILE": {
12+
"type": "FILEPATH",
13+
"value": "${sourceDir}/../../cmake/arm-gcc-cortex-m7.cmake"
14+
}
15+
},
16+
"architecture": {
17+
"value": "unspecified",
18+
"strategy": "external"
19+
},
20+
"vendor": {
21+
"microsoft.com/VisualStudioSettings/CMake/1.0": {
22+
"intelliSenseMode": "linux-gcc-arm"
23+
}
24+
}
25+
}
26+
],
27+
"buildPresets": [
28+
{
29+
"name": "arm-gcc-cortex-m7",
30+
"configurePreset": "arm-gcc-cortex-m7"
31+
}
32+
]
33+
}

0 commit comments

Comments
 (0)