Skip to content

Instantly share code, notes, and snippets.

@galch
Last active April 19, 2024 13:09
Show Gist options
  • Save galch/a95f6ff626c163e3ea5fdfda7973dea1 to your computer and use it in GitHub Desktop.
Save galch/a95f6ff626c163e3ea5fdfda7973dea1 to your computer and use it in GitHub Desktop.
Visual Studio Code STM32

Requirements

Installation

  • Install Visual Studio Code and install the two addons.
  • Install the Toolchain to C:\Program Files (x86)\GNU Tools ARM Embedded\7 2017-q4-major.
  • Extract Windows Build Tools and OpenOCD to C:\Program Files\GNU MCU Eclipse and ensure that C:\Program Files\GNU MCU Eclipse\Build Tools\2.10-20180103-1919\bin is in your path.
  • Place the c_ccp_properties.json, launch.json and tasks.json-files in the .vscode-folder and edit your global settings accordingly to settings.json.
  • Start Debuging.

Files

c_ccp_properties.json

This file is used for code completion. It's basically an image of your -I and -isystem. Ensure that the includes from the ARM Toolchain are listed here. -D are also listed here in order syntax highlight if-defs. If you installed your ARM Toolchain in another path, you need to adapt the includePath.

launch.json

This file defines, how the debugger is launched. If you change the executable name, adapt the configuration accordingly.

settings.json

This file contains settings that should be added to your global settings (CTRL + ,). The paths to the ARM Toolchain and to OpenOCD are defined here.

tasks.json

This file is used to launch the different makefile-targets through Tasks. This requires that make is in your path.

{
"configurations": [
{
"name": "STM32 Debug",
"includePath": [
"${workspaceRoot}/config",
"${workspaceRoot}/libs",
"${workspaceRoot}/libs/BMX050/inc",
"${workspaceRoot}/libs/fusion/freescale",
"${workspaceRoot}/libs/protocol-c",
"${workspaceRoot}/libs/protocol-c/lib",
"${workspaceRoot}/libs/STM32F4/CMSIS/Device/ST/STM32F4xx/Include",
"${workspaceRoot}/libs/STM32F4/CMSIS/Include",
"${workspaceRoot}/libs/STM32F4/STM32_USB_Device_Library/Class/CDC/Inc",
"${workspaceRoot}/libs/STM32F4/STM32_USB_Device_Library/Core/Inc",
"${workspaceRoot}/libs/STM32F4/STM32F4xx_HAL_Driver/Inc",
"${workspaceRoot}/libs/STM32F4/STM32F4xx_HAL_Driver/Inc/Legacy",
"${workspaceRoot}/libs/system/include",
"${workspaceRoot}/libs/system/include/cmsis",
"${workspaceRoot}/libs/system/include/diag",
"${workspaceRoot}/libs/ub_lib",
"${workspaceRoot}/src",
"${workspaceRoot}/src/app",
"${workspaceRoot}/src/baseObjects",
"${workspaceRoot}/src/FreeRTOS",
"${workspaceRoot}/src/FreeRTOS/CMSIS_RTOS",
"${workspaceRoot}/src/FreeRTOS/include",
"${workspaceRoot}/src/FreeRTOS/portable/GCC/ARM_CM4F",
"${workspaceRoot}/src/fusion/inc",
"${workspaceRoot}/src/hardware",
"${workspaceRoot}/src/hardware/app",
"${workspaceRoot}/src/hardware/app/modules",
"${workspaceRoot}/src/hardware/drivers",
"${workspaceRoot}/src/hardware/drivers/usb",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/arm-none-eabi/include/c++/7.2.1",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/arm-none-eabi/include/c++/7.2.1/arm-none-eabi",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/arm-none-eabi/include/c++/7.2.1/backward",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include-fixed",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/arm-none-eabi/include"
],
"defines": [
"DEBUG",
"DEFAULT_STACK_SIZE=2048",
"HSE_VALUE=8000000",
"OS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS",
"PB_MSGID",
"STM32F411xE",
"USE_DEVICE_MODE",
"USE_FULL_ASSERT",
"USE_HAL_DRIVER",
"USE_USB_OTG_FS"
],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/"
],
"limitSymbolsToIncludedHeaders": false,
"databaseFilename": ""
}
},
{
"name": "STM32 Release",
"includePath": [
"${workspaceRoot}/config",
"${workspaceRoot}/libs",
"${workspaceRoot}/libs/BMX050/inc",
"${workspaceRoot}/libs/fusion/freescale",
"${workspaceRoot}/libs/protocol-c",
"${workspaceRoot}/libs/protocol-c/lib",
"${workspaceRoot}/libs/STM32F4/CMSIS/Device/ST/STM32F4xx/Include",
"${workspaceRoot}/libs/STM32F4/CMSIS/Include",
"${workspaceRoot}/libs/STM32F4/STM32_USB_Device_Library/Class/CDC/Inc",
"${workspaceRoot}/libs/STM32F4/STM32_USB_Device_Library/Core/Inc",
"${workspaceRoot}/libs/STM32F4/STM32F4xx_HAL_Driver/Inc",
"${workspaceRoot}/libs/STM32F4/STM32F4xx_HAL_Driver/Inc/Legacy",
"${workspaceRoot}/libs/system/include",
"${workspaceRoot}/libs/system/include/cmsis",
"${workspaceRoot}/libs/system/include/diag",
"${workspaceRoot}/libs/ub_lib",
"${workspaceRoot}/src",
"${workspaceRoot}/src/app",
"${workspaceRoot}/src/baseObjects",
"${workspaceRoot}/src/FreeRTOS",
"${workspaceRoot}/src/FreeRTOS/CMSIS_RTOS",
"${workspaceRoot}/src/FreeRTOS/include",
"${workspaceRoot}/src/FreeRTOS/portable/GCC/ARM_CM4F",
"${workspaceRoot}/src/fusion/inc",
"${workspaceRoot}/src/hardware",
"${workspaceRoot}/src/hardware/app",
"${workspaceRoot}/src/hardware/app/modules",
"${workspaceRoot}/src/hardware/drivers",
"${workspaceRoot}/src/hardware/drivers/usb",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/arm-none-eabi/include/c++/7.2.1",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/arm-none-eabi/include/c++/7.2.1/arm-none-eabi",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/arm-none-eabi/include/c++/7.2.1/backward",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include-fixed",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/arm-none-eabi/include"
],
"defines": [
"DEFAULT_STACK_SIZE=2048",
"HSE_VALUE=8000000",
"NDEBUG",
"OS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS",
"PB_MSGID",
"RELEASE_BUILD",
"STM32F411xE",
"USE_DEVICE_MODE",
"USE_HAL_DRIVER",
"USE_USB_OTG_FS"
],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:/Program Files (x86)/GNU Tools ARM Embedded/7 2017-q4-major/"
],
"limitSymbolsToIncludedHeaders": false,
"databaseFilename": ""
}
}
],
"version": 3
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"cwd": "${workspaceRoot}",
"executable": "./bin/debug/Intranav.elf",
"name": "Debug",
"device": "STM32F411CE",
"configFiles": [
"/board/stm32f4discovery.cfg"
]
}
]
}
{
"cortex-debug.armToolchainPath": "C:\\Program Files (x86)\\GNU Tools ARM Embedded\\7 2017-q4-major\\bin",
"cortex-debug.openocdPath": "C:\\Program Files\\GNU MCU Eclipse\\OpenOCD\\0.10.0-7-20180123-1217\\bin\\openocd.exe"
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Debug",
"type": "shell",
"command": "make -j4 all CPPFLAGS=\"-DSTM32F411xE\"",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Release",
"type": "shell",
"command": "make -j4 release CPPFLAGS=\"-DSTM32F411xE\""
},
{
"label": "Clean",
"type": "shell",
"command": "make clean"
},
{
"label": "Debug Asset Tag",
"type": "shell",
"command": "make -j4 all CPPFLAGS=\"-DSTM32F411xE\" HW_MODEL=ASSET_TAG"
},
{
"label": "Release Asset Tag",
"type": "shell",
"command": "make -j4 release CPPFLAGS=\"-DSTM32F411xE\" HW_MODEL=ASSET_TAG"
},
{
"label": "Debug Vehicle Tag",
"type": "shell",
"command": "make -j4 all CPPFLAGS=\"-DSTM32F411xE\" HW_MODEL=VEHICLE_TAG"
},
{
"label": "Release Vehicle Tag",
"type": "shell",
"command": "make -j4 release CPPFLAGS=\"-DSTM32F411xE\" HW_MODEL=VEHICLE_TAG"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment