STM32, Visual Studio Code and STM32CubeMX - Page 1
Forum section: electronics / general

author: panoss
author_rank: Frequent Contributor
timestamp: May 20, 2019, 03:08:44 pm
content: I foundthisabout Visual Studio Code and STM32 and STM32CubeMX.1. Install GNU Arm Embedded toolchain and add its bin folder to your PATH environment variable.2. You will also need a make to execute your makefiles so download Make for Windows. Easiest way is to download the binaries and extract it somewhere on your system. Add it (C:\make-3.81-bin\bin) to your PATH as well.3. Create an STM32CubeMX project and select Makefile as Toolchain/IDE.4. At this point you will be able to build the generated project by simply using make in the project's root folder.5. If you open the project in VS Code you can build using its terminal or you can create a VS Code task to execute the make command. You can bind your task to a hotkey as well to spare some time.6. To debug, the easiest way is to install Cortex-Debug VS Code extension. Follow the instructions to configure your debug sessions.I have completed steps till number 3.I have created a project named 'test1' at C:\Users\Panto\Documents\STM32CubeProjects\test1.It contains the following folders and files:In the 4th step, what am I supposed to do?

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 20, 2019, 05:51:48 pm
content: Quote from: panoss on May 20, 2019, 03:08:44 pm4 and 5 are actually linked. Open integrated terminal (L Ctrl + `), type `make` and press Enter. To create a build task, you can - for example - press R Ctrl + R Shift + P, type "task", select "Configure default build task" and follow the steps. My tasks.json file is more-of-less something like this:Code:{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "Build","type": "shell","options": {"cwd": "output"},"command": "make -j","problemMatcher": {"owner": "cpp","fileLocation": ["relative","${workspaceFolder}/output"],"pattern": {"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|fatal error|error):\\s+(.*)$","file": 1,"line": 2,"column": 3,"severity": 4,"message": 5}},"presentation": {"clear": true},"group": {"kind": "build","isDefault": true}}]}You may need to delete `"cwd": "output"` and `fileLocation: ...` if you build in the same folder as the sources, or adjust accordingly if your build folder is not called "output". When you have it, just press L Ctrl + L Shift + B to execute this build task immediately.

author: lollandster
author_rank: Contributor
timestamp: May 20, 2019, 06:34:00 pm
content: Quote from: panoss on May 20, 2019, 03:08:44 pmLooks like you forgot to change the Toolchain/IDE to Makefile.Your folder structure should look more like this:

author: panoss
author_rank: Frequent Contributor
timestamp: May 20, 2019, 07:09:12 pm
content: Quote from: lollandster on May 20, 2019, 06:34:00 pmNo I didn't forget to do this.I will repeat the process beginning from step 3.

author: lucazader
author_rank: Regular Contributor
timestamp: May 20, 2019, 07:24:43 pm
content: @Freddievscode now has a built in problem matcher for gcc:Code:"problemMatcher": "$gcc",Do you use the regex style problem matcher for any specific reason, or has it just stuck around in your tasks like it did in mine untill i realised they now have a support for it?Back on topic:This is the workflow i use on a daily basis, both to test a project or do any POC work. But also we have based our main projects off this workflow, with quick and easy code regeneration if we want to update HAL version, or change a peripheral initialisation.It works really well.

author: panoss
author_rank: Frequent Contributor
timestamp: May 20, 2019, 07:37:53 pm
content: Ok, I created a new STM32CubeMX project, generated code, started Visual Studio Code, opened the project's folder, Terminal->New Terminal, entered 'make' and looks like it built it!Even though it found an error:Code:arm-none-eabi-objcopy: build/test2.hex 64-bit address 0x4b4fa308000000 out of range for Intel Hex filearm-none-eabi-objcopy:build/test2.hex: bad valuemake: *** [build/test2.hex] Error 1My folder's structure now is:So lollandster you were right, something wos wrong in my first project.I created and a task the way Freddie Chopin describes. I guess i'm ok now.Only remains step 6.

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 20, 2019, 08:49:50 pm
content: Quote from: lucazader on May 20, 2019, 07:24:43 pmThe latter. The $gcc matcher is relatively new addition I think. Tomorrow I'll try it "the new way" (;

author: lucazader
author_rank: Regular Contributor
timestamp: May 20, 2019, 09:01:28 pm
content: Panoss,I think (if i am not mistaken) that you are encountering an issue in the arm-none-eabi-objcopy binary that was delivered in the latest 8.2.1 release.Where they accidentally did some incorrect stuff assuming that the architecture was 64 bit or something (dont worry about the details though...)(https://bugs.launchpad.net/bugs/1810274)More details can be found in the bug report including a work around:Download the arm 2017-q4 release and then copy the arm-none-eabi-objcopy binary from that release into the new one.This bug only affects windows FYI.You can also not generate the hex file and that also works.

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 21, 2019, 05:49:40 am
content: Or instead of downgrading, you could actually UPGRADE [;https://www.eevblog.com/forum/microcontrollers/arm-none-eabi-gcc-(bleeding-edge-toolchain)-9-1-0/

author: panoss
author_rank: Frequent Contributor
timestamp: May 21, 2019, 02:31:43 pm
content: Quote from: lucazader on May 20, 2019, 09:01:28 pmYou are referring to the error that I mentioned, right?Quote from: Freddie Chopin on May 21, 2019, 05:49:40 amWait a minute. In order to install the one in your link, what should I uninstall?The 'GNU Arm Embedded toolchain' that I installed at step 1?This is from the Control Panel, Uninstall or change a program:

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 21, 2019, 03:37:38 pm
content: You don't actually need to uninstall anything and bleeding-edge-toolchain does not have an installer (; Just extract it anywhere you want and add it to system PATH variable _BEFORE_ the current toolchain. You can of course also remove the ARM version, but you will still need to add bleeding-edge-toolchain to PATH. Some info about that can be found here - just ignore any chapters that don't apply to your situation -http://distortos.org/documentation/arm-toolchain-windows/

author: panoss
author_rank: Frequent Contributor
timestamp: May 21, 2019, 05:08:29 pm
content: I downloaded bleeding-edge-toolchain-190503.tar.xz fromhere.It contains theses files:.gitignore.travis.ymlbuild-bleeding-edge-toolchain.shCHANGELOG.mdREADME.mdIs it ok?

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 21, 2019, 05:14:48 pm
content: Please read what is in the README.md file about windows version.https://github.com/FreddieChopin/bleeding-edge-toolchain#toolchain-for-windowshttp://www.freddiechopin.info/en/download/category/11-bleeding-edge-toolchain

author: panoss
author_rank: Frequent Contributor
timestamp: May 21, 2019, 07:16:34 pm
content: Ok, I installed it correctly now.Now, about the task.json file.In the file that VSCode created, it has:"command": "msbuild"While Chopin 's has:"command": "make -j"How shall I know which one is the correct one?

author: lucazader
author_rank: Regular Contributor
timestamp: May 21, 2019, 07:40:57 pm
content: the command "msbuild" is the command to build a microsoft application using their own msbuild platform.You are going to be using the make build platform here, so the command "make" is what you want.The "-jn" after make is telling make to run the build in parallel. Usually you set n to the number of processors in your system eg "make -j4" for a quad core.You can play around with this number to see how it works for you, i quite often run "-j16" on a quadcore with hyperthreading as I have found that results in the fastest compiles.

author: panoss
author_rank: Frequent Contributor
timestamp: May 21, 2019, 07:48:45 pm
content: For a beginning, I 'll use Chopin 's tasks.json as is.

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 21, 2019, 08:13:41 pm
content: You cannot use it as-is - it requires some minor modifications as I said earlier, which I cannot do for you, as I have no idea whether your project builds in-source or in a separate folder. The first one you can safely remove (this one was actually CMake-specific, no use in your case):"cwd": "output"And this one you can initially remove (it's probably only for the problem matcher):"fileLocation": ["relative","${workspaceFolder}/output"],After you have everything working try switching to the $gcc problem matcher as mentioned earlier by @lucazader - if the errors/warnings won't be correctly linked to source files, you will most likely need to reintroduce fileLocation with proper contents - hopefully you'll just need to set correct build folder (change "output" to whatever you have in your project or remove "/output" it in case of in-source builds).

author: panoss
author_rank: Frequent Contributor
timestamp: May 22, 2019, 09:32:50 am
content: This is my tasks.json (modified per your suggestions Chopin):Code:{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "Build","type": "shell","command": "make -j","problemMatcher": {"owner": "cpp","pattern": {"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|fatal error|error):\\s+(.*)$","file": 1,"line": 2,"column": 3,"severity": 4,"message": 5}},"presentation": {"clear": true},"group": {"kind": "build","isDefault": true}}]}I removed:Code:"options": {"cwd": "output"},and:Code:"fileLocation": ["relative","${workspaceFolder}/output"],Terminal->Run Build Task: seems to works ok, no errors. (for some unknown reason, Ctrl+Shift+B does not work)Quote from: Freddie Chopin on May 21, 2019, 08:13:41 pmYou mean I should add this:Code:"problemMatcher": "$gcc",somewhere in my tasks.json?

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 22, 2019, 10:39:29 am
content: Quote from: panoss on May 22, 2019, 09:32:50 amHmm... Maybe on your system the shortcut is different? When you display the command, it should show you what the key combination is. Take a look at my screenshot.QuoteDid not try that yet (; However the link to the docshttps://go.microsoft.com/fwlink/?LinkId=733558should probably contain some info about it, more you'll have to find yourself. Or maybe @lucazader could post his tasks.json file as a starter.

author: panoss
author_rank: Frequent Contributor
timestamp: May 22, 2019, 04:47:09 pm
content: I must enter thecompiler 's pathin the tasks.json file.I have put the 'GNU Tools ARM Embedded' folder at: C:\Program Files\GNU Tools ARM Embedded.In C:\Program Files\GNU Tools ARM Embedded\8 2018-q4-major\bin have these files:Which one is the compiler?

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 22, 2019, 06:59:44 pm
content: QuoteWhy would you need to do that? It usually doesn't work so well when you call compiler with full path, as then you'll also need to do the same for linker, assembler, archiver, debugger and various other support tools... Just add the .../bin folder to system's PATH variable and that's all you need.

author: panoss
author_rank: Frequent Contributor
timestamp: May 22, 2019, 07:28:22 pm
content: Because I get errors (I mention above that there was no error. It' s not true, I just had not seen them):This is the content of my system Path environment variable:Quote

author: lucazader
author_rank: Regular Contributor
timestamp: May 22, 2019, 07:41:08 pm
content: I am running on linux FYI so you wont be able to use this directly..But here is a lightly sanitised version of my tasks.json. (this is from a work project).Code:{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "build release","type": "shell","command": "make release -j16","problemMatcher":"$gcc","group":"build"},{"label": "build debug","type": "shell","command": "make debug -j16","problemMatcher":"$gcc","group":"build"},{"label": "compiledb","type": "shell","command": "compiledb make -j16","problemMatcher":"$gcc","group":"build"},{"label": "clean","type": "shell","command": "make clean","problemMatcher":"$gcc","group":"build"},{"label": "flash debug","dependsOn": "build debug","type": "shell","command": "STM32_Programmer.sh -c port=SWD -d ${workspaceRoot}/build/debug/bootloader.hex -rst","problemMatcher":"$gcc","group":"build"},{"label": "flash release","dependsOn": "build release","type": "shell","command": "STM32_Programmer.sh -c port=SWD -d ${workspaceRoot}/build/release/bootloader.hex -rst","problemMatcher":"$gcc","group":"build"},],}You will notice there is a task called compiledb in there. It should work on windows.Compiledb is a super useful tool you can run on a makefile build to generate a 'compile_commands.json' file. Its just a simple python script which effectively does a 'make --dry-run' to extract all the required commands to build.You can install it using 'pip install compiledb', assuming you have both python and pip already installed.Then you can point vscode to this generated file in the 'c_cpp_properties.json' file. Intellisense will then use this to find where header files/other source files are so you wont get any of those error lines.So much easier to set this up than trying to point vscode at your compilers bin directory, include directory and then list all the project include directories in the project setup.You wrote it once in the makefile, why write it elsewhereHope this helps.

author: panoss
author_rank: Frequent Contributor
timestamp: May 22, 2019, 07:46:56 pm
content: lucazader can I use this json file as is or should I modify it?(I must admit I start getting really dizzy, it's so f**ing complicated)

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 22, 2019, 07:52:03 pm
content: Yeah, just as @lucazader said, the errors you see (actually just "errors" from vscode, not compile errors) cannot be solved by any modification of the tasks.json file - you have to edit your c_cpp_properties.json to solve it. Either you have to list all the #includes _AND_ #defines of the compiler, or you can add there a `"compilerPath": "/home/freddie/arm-none-eabi-gcc-9.1.0-190503/bin/arm-none-eabi-g++ ..."` but with _ALL_ required flags (like -mthumb -mcpu=... -mfloat-abi=... and so on) or you could generate compile_commands.json and use that. I also use the last option - as I'm using CMake now, it has an option to generate this file for you. And I also use the middle option ("compilerPath"). This works pretty well most of the time.BTW - I'm also using Linux [;

author: lucazader
author_rank: Regular Contributor
timestamp: May 22, 2019, 08:02:07 pm
content: No you wont be able to use it without modification.As i said i am running on linux, so there are a few things that probably wont work.As a start you can try chagning the / in the file paths in my tasks.json to the windows style \ and see how that goes.

author: panoss
author_rank: Frequent Contributor
timestamp: May 23, 2019, 10:56:58 am
content: Quote from: lucazader on May 22, 2019, 07:41:08 pmI installed compiledb.How can I point vscode to this generated file('compile_commands.json')?AtLucazaders 's tasks.jsonI replaced the '/' with '\\':Code:{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "build release","type": "shell","command": "make release -j16","problemMatcher":"$gcc","group":"build"},{"label": "build debug","type": "shell","command": "make debug -j16","problemMatcher":"$gcc","group":"build"},{"label": "compiledb","type": "shell","command": "compiledb make -j16","problemMatcher":"$gcc","group":"build"},{"label": "clean","type": "shell","command": "make clean","problemMatcher":"$gcc","group":"build"},{"label": "flash debug","dependsOn": "build debug","type": "shell","command": "STM32_Programmer.sh -c port=SWD -d ${workspaceRoot}\\build\\debug\\bootloader.hex -rst","problemMatcher":"$gcc","group":"build"},{"label": "flash release","dependsOn": "build release","type": "shell","command": "STM32_Programmer.sh -c port=SWD -d ${workspaceRoot}\\build\\release\\bootloader.hex -rst","problemMatcher":"$gcc","group":"build"},],}I tried to build it (Terminal->Run Build Task->Build Release) and I got the following error:Quote

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 23, 2019, 11:18:04 am
content: The file presented by @lucazader requires such targets to be present in your Makefile. I guess in your case you should just remove all "debug" targets from tasks.json, and then replace "build relase" with "build all" (or just "build"). Try this:Code:{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "build","type": "shell","command": "make -j16","problemMatcher":"$gcc","group":"build"},{"label": "compiledb","type": "shell","command": "compiledb make -j16","problemMatcher":"$gcc","group":"build"},{"label": "clean","type": "shell","command": "make clean","problemMatcher":"$gcc","group":"build"}],}

author: panoss
author_rank: Frequent Contributor
timestamp: May 23, 2019, 11:58:19 am
content: Chopin your tasks.json does work, the error 'make: *** No rule to make target `release'' is gone...Butthe errors I mentioned before, remain.

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 23, 2019, 12:08:21 pm
content: As I said earlier -https://www.eevblog.com/forum/microcontrollers/stm32-visual-studio-code-stm32cubemx/msg2429562/#msg2429562- these errors cannot be solved by any modification in tasks.json, as they are not related to the build (task) itself. With compiledb in place you can probably generate compile_commands.json file, which can then be used in vscode - this would eliminate quite a lot of the errors you see. The rest can probably be solved with compilerPath.After the changes, you'll need to restart vscode.For a start, here's my .vscode/c_cpp_properties.json file:Code:{"configurations": [{"name": "Linux","compilerPath": "/home/freddie/arm-none-eabi-gcc-9.1.0-190503/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16","cStandard": "c11","cppStandard": "c++17","intelliSenseMode": "gcc-x64","compileCommands": "${workspaceFolder}/output/compile_commands.json"}],"version": 4}

author: panoss
author_rank: Frequent Contributor
timestamp: May 23, 2019, 02:19:11 pm
content: Yes, there is a file named 'c_cpp_properties.json' in my project 's .vscode directory with this content:QuoteI suppose I must add 'compilerPath', something like your: "compilerPath": "/home/freddie/arm-none-eabi-gcc-9.1.0-190503/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16",But which ofthese filesshould I choose?Maybe 'arm-none-eabi-g++.exe'?

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 23, 2019, 02:36:38 pm
content: You can really just delete everything that is in there and use my file with slight modifications to suit your system. Replace "Linux" with `"name": "Win32",`, use proper compiler path and flags which match your project, use valid path to generated compile_commands.json. As for the compiler, choose either arm-none-eabi-g++ for a c++ project or arm-none-eabi-gcc for a C project.

author: panoss
author_rank: Frequent Contributor
timestamp: May 23, 2019, 02:52:56 pm
content: 'compile_commands.json' is not generated.This is my tasks.json:Code:{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "build","type": "shell","command": "make -j16","problemMatcher":"$gcc","group":"build"},{"label": "compiledb","type": "shell","command": "compiledb make -j16","problemMatcher":"$gcc","group":"build"},{"label": "clean","type": "shell","command": "make clean","problemMatcher":"$gcc","group":"build"}],}This is my c_cpp_properties.json:Code:{"configurations": [{"name": "Win32","compilerPath": "\"C:\\Program Files\\GNU Tools ARM Embedded\\8 2018-q4-major\\bin\\arm-none-eabi-g++.exe\" -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16","cStandard": "c11","cppStandard": "c++17","intelliSenseMode": "msvc-x64","compileCommands": "${workspaceFolder}\\output\\compile_commands.json"}],"version": 4}

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 23, 2019, 03:01:57 pm
content: So to generate it, you need to run the `compiledb` target in vscode, or run `compiledb make -j16` manually.BTW - your intelliSenseMode is wrong, unless you really plan to use Microsoft's compiler to build your project (;

author: panoss
author_rank: Frequent Contributor
timestamp: May 23, 2019, 03:06:55 pm
content: In VS Code 's Terminal I entered `compiledb make -j16`run it and got these errors:Quote

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 23, 2019, 03:28:30 pm
content: Sorry, can't help you with this program, never used it. Maybe @lucazader will be able to provide some help here. Or maybe try `compiledb make all -j16`?

author: panoss
author_rank: Frequent Contributor
timestamp: May 23, 2019, 03:34:23 pm
content: I tried it, the result is the same...

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 23, 2019, 03:37:50 pm
content: On compiledb's website it says:Supports Python 2.x and 3.x (for now, tested only with 2.7 and 3.6 versions)https://github.com/nickdiego/compiledbYou seem to be using a very old 3.4. Try changing to the recommended release.

author: panoss
author_rank: Frequent Contributor
timestamp: May 23, 2019, 07:11:19 pm
content: You 're right, I uninstalled 3.4 and installed 3.6.0 and works! AND all errors are gone!!Only remains one warning:QuoteI must correct this:Code:"intelliSenseMode": "msvc-x64",I have 32 bit windows.I readhere:QuoteI tried 'clang-x64' and the warning is gone!

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 23, 2019, 07:17:50 pm
content: Set it either to clang-x64 or better to gcc-x64.

author: panoss
author_rank: Frequent Contributor
timestamp: May 23, 2019, 07:24:19 pm
content: Ok, now 'only'remains step 6...I will installCortex-DebugVS Code extension and will follow theinstructionsto configure my debug sessions.

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 23, 2019, 08:15:05 pm
content: So for a good start, here's my launch.json:Code:{// 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": [{"cwd": "${workspaceRoot}","executable": "./output/test/distortosTest.elf","name": "ST_NUCLEO-F401RE (with load)","request": "launch","type": "cortex-debug","servertype": "openocd","configFiles": ["board/st_nucleo_f4.cfg"],"svdFile": "/home/freddie/Elektronika/ARM/cmsis-svd-master/data/STMicro/STM32F401xE.svd","preLaunchTask": "Build","postLaunchCommands": ["thbreak main","continue"]},{"cwd": "${workspaceRoot}","executable": "./output/test/distortosTest.elf","name": "ST_NUCLEO-F401RE (without load)","request": "attach","type": "cortex-debug","servertype": "openocd","configFiles": ["board/st_nucleo_f4.cfg"],"svdFile": "/home/freddie/Elektronika/ARM/cmsis-svd-master/data/STMicro/STM32F401xE.svd","preAttachCommands": ["monitor reset halt","tbreak main","continue"]}]}

author: panoss
author_rank: Frequent Contributor
timestamp: May 24, 2019, 02:38:30 pm
content: I see you have an 'output' folder: "executable": "./output/test/distortosTest.elf",Should I create one manually? Should it be created somehow else, automatically?The MCU I' m using in this project is STM32F030F4P6.Should I find a file like 'STM32F030F4P*.svd'?(I searched in my hard disk and in the internet, I found nothing. But I found one named 'STM32F030.svd'here. How shall I know if this is the one?)This is my launch.json:Code:{// 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": [{"cwd": "${workspaceRoot}","executable": ".\\build\\test2.elf","name": "Debug STM32F030F4P6","device": "STM32F030F4","request": "launch","type": "cortex-debug","servertype": "openocd","svdFile": ".\\STM32F030.svd","preLaunchTask": "Build","postLaunchCommands": ["thbreak main","continue"]}]}I have removed "configFiles" and have added "device".

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 24, 2019, 03:44:27 pm
content: QuoteBoth wrong, as device is not needed for OpenOCD debug type and configFiles is essential.QuoteWhat debugger do you have? Is this some "typical" board (Nucleo, Discovery)?QuoteJust use the path as it is in your project - the path to the .elf file produced during the build.QuoteThis is optional, but you have found the right source - I just have this whole "cmsis-svd" cloned locally on my disk. This is needed only for viewing peripheral registers (like USART1->CR1), otherwise you don't needed it.

author: panoss
author_rank: Frequent Contributor
timestamp: May 24, 2019, 03:49:51 pm
content: For configFiles, shouldn't I have a .cfg file? I have not.As for debugger for this project I 'll be using ST-LINK/V2 (waiting to come).

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 24, 2019, 05:21:38 pm
content: In that case use:Code:"configFiles": ["board/st_nucleo_f0.cfg"],Trust me, it will work.

author: panoss
author_rank: Frequent Contributor
timestamp: May 24, 2019, 07:19:16 pm
content: When I click 'Debug' button:This means it can find tasks.json but not the task?

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 24, 2019, 08:26:09 pm
content: Modify this:Code:"preLaunchTask": "Build",Instead of "Build" enter the name of your task which builds the whole project (was it "build", with a lower-case "b"?).

author: panoss
author_rank: Frequent Contributor
timestamp: May 25, 2019, 06:51:30 am
content: It was "Build", I made it "build", the previous error disappeared BUT now I get another error:

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 25, 2019, 07:12:29 am
content: I guess you don't have OpenOCD in your system's PATH then. Try running it directly in the terminal to verify. Type "openocd" and press enter - it it starts then the problem is elsewhere, otherwise your system cannot find OpenOCD, so visual studio code cannot do it as well.If it works, try "openocd -f board/st_nucleo_f0.cfg" from the terminal too - you'll see what the error is. For this you obviously need to have your debugger and target chip connected to your PC.

author: panoss
author_rank: Frequent Contributor
timestamp: May 25, 2019, 07:23:59 am
content: Which is the OpenOCD 's directory?I found an openocd.js (probably this is not the executable, right?) at: C:\Users\Panto\.vscode\extensions\marus25.cortex-debug-0.2.6\out\srcI put it in the PATH variable, but I get the same error.(aslo in the same folder, among other files, there is one named 'gdb.js')

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 25, 2019, 07:31:59 am
content: Well, if you did not install/extract OpenOCD in your system, then you definitely don't have it. It doesn't come with vscode as well as it doesn't come with the toolchain. You can get OpenOCD for Windows from my personal webpage athttp://www.freddiechopin.info/pl/download/category/4-openocd. Just extract it anywhere you want and add .../bin or .../bin-x64 folder to your system's PATH variable (just as you did with the compiler executables).

author: panoss
author_rank: Frequent Contributor
timestamp: May 25, 2019, 07:43:50 am
content: I did as you said (I put the extracted folder in C:\Program Files), put it in the PATH, run it (debug).A message appeared asking me to give permission for OpenOCD.exe to run. This means it found the OpenOCD.exe.But then again the same error message!'Failed to launch OpenOCD GDB server. Timeout'!!(I see no GDB.exe or something similar in folder openocd-0.10.0)

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 25, 2019, 07:57:54 am
content: Try running this in your terminal to see the exact error message (or there's a tab somewhere in vscode which has the output of OpenOCD - go to Output tab [near Terminal, Problems and so on], from the combobox select Adapter Output). Do you have the debugger connected? Is it properly detected by your system? Did you install any drivers for it? Is it visible in Devices Manager? Did you give the permission for OpenOCD to run? Did you try running the session again?Why do you expect GDB to be part of OpenOCD when it is a part of the toolchain and already present in your system.Don't get me wrong, but it really appears that you are doing everything without any thinking at all... Using vscode for MCU development is definitely possible, but there are a couple of rough edges here and there - maybe not significantly more than in Eclipse, but Eclipse is well known and covered by million tutorials, while in vscode this is all new - so it is not something I would recommend for a total beginner.

author: panoss
author_rank: Frequent Contributor
timestamp: May 25, 2019, 08:16:15 am
content: Quote from: Freddie Chopin on May 25, 2019, 07:57:54 amThis is what I get:QuoteQuote from: Freddie Chopin on May 25, 2019, 07:57:54 amI have not the debugger yet, as I 've already mentioned I' m waiting for it to come.Quote from: Freddie Chopin on May 25, 2019, 07:57:54 amI don't get you wrong, don't worry. You are right.I should not have tried VS Code. I thought it was just another way, I did not expect it to be something so hard.I thought in 5 minutes I would have finished!So, please tell me what would you suggest for me to use?I would like to avoid something 'heavy' as my pc is not very 'strong'.So should I go for something like eclipse + some plugins?

author: Freddie Chopin
author_rank: Regular Contributor
timestamp: May 25, 2019, 08:23:25 am
content: QuoteThen what you see is perfectly fine and expected. OpenOCD will not start without the debugger and GDB will not start without OpenOCD. Until you get your debugger it will not work no matter what you try. Once you connect it, everything should be fine.QuoteIf you like vscode, you can leave it - at this stage you have everything set-up (at least it seems so) and working. If you want something which can be done in 5 minutes your only option is some vendor-supplied IDE like STM32CubeIDE or Atollic. Or you can go with Eclipse (which is heavy when compared to vscode), but this is not very different from vscode in the regard of potential problems - the only advantage is that there are much more resources about Eclipse than you can find about vscode.

author: panoss
author_rank: Frequent Contributor
timestamp: May 25, 2019, 08:26:35 am
content: Quote from: Freddie Chopin on May 25, 2019, 08:23:25 amThis is the main reason I chose VS Code, because it 's 'light'.