Visual Studio Code Setup
This page includes some additional information for setting up Visual Studio Code. For the basic Setup, see the Quick Start page.
Configure Debugging
If you need debugging support, you will need to install the Cortex-Debug Extension from here:
-
Cortex Debug: https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug
-
Newer versions than 1.4.4 only support GDB v9 and higher. However, this project uses version 7. Thus, it is neccessary to roll back to version 1.4.4 of the plugin. One way to roll back is to open the extension’s page in VSCode, click the arrow next to Uninstall, click on Install Another Version… and select version 1.4.4.
You should then create the file <fruitymesh>/.vscode/launch.json
with the content below. This is the configuration for the Cortex-Debug Extension. Make sure to insert the correct paths for armToolchainPath and serverPath. Also, depending on the featureset you are debugging, you must change the executable path to the correct binary. The device should also be changed if debugging a different chipset. The SVD file is optionally used, if you want to see the registers of the chips peripherals. Make sure to point it to the correct chipset if you need it.
{
"version": "0.2.0",
"configurations": [
{
"type": "cortex-debug",
"name": "Debug BlueRange Mesh",
"cwd": "${workspaceRoot}",
"servertype": "jlink",
"request": "launch",
"demangle": true,
"device": "NRF52832_XXAA",
"executable": "./_build/vscode/github_dev_nrf52.out", //Path to the built BlueRange Mesh firmware
"armToolchainPath": "C:/<your_path>/gcc-arm-embedded-4.9-2015q3/bin/", //Path to the bin folder of your GCC ARM Embedded installation
"serverpath": "C:/<your_path>/SEGGER/JLink_V622g/JLinkGDBServerCL.exe", //Path to the SEGGER Debug Server (Installed with the nrf tools)
//"svdFile": "C:/<your_path>/fruitymesh/sdk/sdk15/modules/nrfx/mdk/nrf52840.svd" // Path to the Device Description file for viewing Peripheral Registers (Optional)
}
]
}
You can start debugging by clicking the play icon in the debug view as seen here:
When using the debugger, make sure to use the proper "Utility" target first for flashing as this will guarantee that the SoftDevice is also flashed. |
If you enter the wrong executable, you will get very strange results during debugging and the wrong binary might be flashed. |
For more information on debugging, see here.
Better Intellisense support
In order to get better Intellisense results (E.g. for conditional code compilation), it is important that Intellisense knows which build target is active. Sadly, there is an open issue with CMake. We have therefore provided a workaround:
-
Open the previously created
<fruitymesh>/.vscode/settings.json
and add theONLY_FEATURESET
settings with the name of the featureset/target that you want to work on:
"cmake.configureSettings":{
"GCC_PATH":"C:/mway/tools/gcc-arm-embedded-4.9-2015q3",
"BUILD_TYPE":"FIRMWARE",
"ONLY_FEATURESET":"your_featureset_name"
},
-
In the Cmake Panel, click on "Configure All Projects". This will configure your project with a single target.
-
Select the active build target in the status bar of VsCode (at the bottom) to the same target that you specified in the settings.
-
Press Ctrl+Shift+P to open the Command Palette and search for
Developer: Reload Window
and activate it.
After the window was reloaded, Intellisense should have properly detected that the compile_commands.json file was regenerated by CMake and does now only contain the correct compile commands for this target.
Outline
The outline is a very helpful view that we use a lot while developing BlueRange Mesh. We have tried to structure and group our code nicely which will also help you to find stuff quickly. For the best experience, sort the outline view by position.
Nice to have: File Icons
Press Ctrl + Shift + P to open the Command Palette and type "Icon" and choose "Preferences: File Icon Theme", then install the "VsCode Icons" theme to get some visually distinguishable icons in your project explorer.
Troubleshooting
Cannot create folder with leading .
Depending on the system you are running, it might not be possible to create a folder with a leading dot (.) in its name. You can open a commandline in that folder and use the "mkdir .yourfolder" command to create it. This is just a restriction of the file explorer that was removed in a later version.