Debug STM32 with VScode

Development environment specific, Arduino, Eclipse, VS2013,Em::Blocks etc
caniggia
Posts: 28
Joined: Tue Dec 06, 2016 2:38 pm

Re: Debug STM32 with VScode

Post by caniggia » Fri Aug 18, 2017 12:00 pm

@stuartw
I would prefer it if I could see compiler output, however it is probably hidden somewhere.
Add to "arduino.json" this line:
"output": "build",

and you will get all compiled files in subfolder named "build".


BR
caniggia

vitor_boss
Posts: 66
Joined: Wed Apr 19, 2017 9:50 am

Re: Debug STM32 with VScode

Post by vitor_boss » Thu Aug 24, 2017 12:49 am

Where that config could be found?

Code: Select all

            "miDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
            "debugServerPath": "/usr/bin/openocd",
            "debugServerArgs": "-f interface/stlink-v2.cfg -f target/stm32f1x.cfg",
EDIT:
Last opencd is here https://sourceforge.net/projects/openocd/?source=navbar
Last gdb is at http://ftp.gnu.org/gnu/gdb/

vitor_boss
Posts: 66
Joined: Wed Apr 19, 2017 9:50 am

Re: Debug STM32 with VScode

Post by vitor_boss » Thu Aug 24, 2017 2:16 pm

I have entered those values and don't work:

Code: Select all

            "miDebuggerPath": "D:/VScode/arm-none-eabi-gdb",
            "debugServerPath": "D:/VScode/openocd",
            "debugServerArgs": "-f interface/stlink-v2.cfg -f target/stm32f4x.cfg",
Any help are very welcome, I'm trying to debug the code for a week now

Edit: this is my device path "USB\VID_0483&PID_3748\6&1EC10D3F&0&1" I had updated it with last firmware

vitor_boss
Posts: 66
Joined: Wed Apr 19, 2017 9:50 am

Re: Debug STM32 with VScode

Post by vitor_boss » Sat Aug 26, 2017 6:17 pm

Guys, I really need help here, when I try to start debugger give error "Unable to start debugging. Nenhum processo associado a este objeto."

What I'm doing wrong?

STM32 ST-LINK works fine, but upload via st-link don't work
Attachments
2017-08-26.png
2017-08-26.png (43.37 KiB) Viewed 1227 times

vitor_boss
Posts: 66
Joined: Wed Apr 19, 2017 9:50 am

Re: Debug STM32 with VScode

Post by vitor_boss » Wed Aug 30, 2017 1:50 am

iamseer wrote:
Wed Jul 19, 2017 7:58 pm
Happy debugging!
7_debug.jpg
Maybe I missed something, I follow all the steps and cant get it running.
Could you help?

caniggia
Posts: 28
Joined: Tue Dec 06, 2016 2:38 pm

Re: Debug STM32 with VScode

Post by caniggia » Wed Aug 30, 2017 9:48 am

@vitor_boss

How i did it on Windows 10.
Tested with ST-Link & Bluepill.

1.) Download and install "Arduino":
https://www.arduino.cc/en/Main/Software

2.) In Arduino "Boards Manager" install "Arduino SAMD Boards", not "Ardiuno SAM Boards"!!!

3.) Download rogerclarkmelbourne's repo:
https://github.com/rogerclarkmelbourne/Arduino_STM32

Put folder from zip to:
C:\Users\<username>\Documents\Arduino\hardware

and rename it to "Arduino_STM32" !!!

4.) In Arduino Try to compile & upload blink example

5.) Download and install "Visual Studio Code"
https://code.visualstudio.com/download

6.) Download and instal "Visual Studio Code extension for Arduino" v0.2.5 !!!
https://marketplace.visualstudio.com/it ... de-arduino

It will also install "C/C++ for Visual Studio Code"

7.) You don't need to set/change anything in "launch.json"

8.) Set the project in VSCODE for blink example and try to compile(ctrl+alt+r), upload(ctrl+alt+u) and debug(F5).

BR
caniggia

vitor_boss
Posts: 66
Joined: Wed Apr 19, 2017 9:50 am

Re: Debug STM32 with VScode

Post by vitor_boss » Wed Aug 30, 2017 11:11 am

caniggia wrote:
Wed Aug 30, 2017 9:48 am
@vitor_boss

How i did it on Windows 10.
Tested with ST-Link & Bluepill.

1.) Download and install "Arduino":
https://www.arduino.cc/en/Main/Software

2.) In Arduino "Boards Manager" install "Arduino SAMD Boards", not "Ardiuno SAM Boards"!!!

3.) Download rogerclarkmelbourne's repo:
https://github.com/rogerclarkmelbourne/Arduino_STM32

Put folder from zip to:
C:\Users\<username>\Documents\Arduino\hardware

and rename it to "Arduino_STM32" !!!

4.) In Arduino Try to compile & upload blink example

5.) Download and install "Visual Studio Code"
https://code.visualstudio.com/download

6.) Download and instal "Visual Studio Code extension for Arduino" v0.2.5 !!!
https://marketplace.visualstudio.com/it ... de-arduino

It will also install "C/C++ for Visual Studio Code"

7.) You don't need to set/change anything in "launch.json"

8.) Set the project in VSCODE for blink example and try to compile(ctrl+alt+r), upload(ctrl+alt+u) and debug(F5).

BR
caniggia
Only work with F1? My board is F407VE. And how include another library like STM32GENERIC?

User avatar
And_Ru
Posts: 25
Joined: Thu Nov 10, 2016 1:16 pm
Location: Russia, Moscow

Re: Debug STM32 with VScode

Post by And_Ru » Sun Sep 03, 2017 10:14 pm

caniggia wrote:
Wed Aug 30, 2017 9:48 am
@vitor_boss
7.) You don't need to set/change anything in "launch.json"

8.) Set the project in VSCODE for blink example and try to compile(ctrl+alt+r), upload(ctrl+alt+u) and debug(F5).
I tried to do all this, but the program ask me to choose board and I cannot see genericSTM32 in the list. What should I choose?

caniggia
Posts: 28
Joined: Tue Dec 06, 2016 2:38 pm

Re: Debug STM32 with VScode

Post by caniggia » Mon Sep 04, 2017 7:04 am

@And_Ru

Press F1 and type "arduino" and you will get all the Arduino commands:
  • Arduino: Board Manager: Manage packages for boards. You can add 3rd party Arduino board by configuring Additional Board Manager URLs in board manager.
  • Arduino: Change Baud Rate: Change the baud rate of selected serial port.
  • Arduino: Change Board Type: Change board type or platform.
  • Arduino: Close Serial Monitor: Stop serial monitor and release the serial port.
  • Arduino: Examples: Show example list.
  • Arduino: Initialize: Scaffold a VS Code project with an Arduino sketch.
  • Arduino: Library Manager: Explore and manage libraries.
  • Arduino: Open Serial Monitor: Open serial monitor in the intergrated output window.
  • Arduino: Select Serial Port: Change the current serial port.
  • Arduino: Send Text to Serial Port: Send a line of text via the current serial port.
  • Arduino: Upload: Build sketch and upload to Arduino board.
  • Arduino: Verify: Build sketch.
Please, read this page "Visual Studio Code extension for Arduino":
https://marketplace.visualstudio.com/it ... de-arduino

BR
caniggia

otw
Posts: 2
Joined: Wed Dec 06, 2017 9:30 pm

Re: Debug STM32 with VScode

Post by otw » Wed Dec 06, 2017 10:35 pm

Hello,

Im trying to run STM32F4 Discovery board.
I came across a couple issues:
Regarding copying scripts and executing the instruction inside the termian, after doing so Im getting different result, much longer result.
Cant find "misc/usbmapping.json".

I tried to add following path: "-f interface/stlink-v2.cfg -f target/stm32f4x.cfg" into "debugServerArgs".
After hit debug I get an Error that "arm-none-eabi-gdb is not signed".

Im running Mac os high sierra

I appreciate every help,

Regards!

EDIT:

I finally managed to debug my project.
I installed openocd and gcc-arm-none-eabi using Homebrew.
Then I set up parameters inside launch.json file:

Code: Select all

            "miDebuggerPath": "/usr/local/Cellar/gcc-arm-none-eabi/20160928/bin/arm-none-eabi-gdb",
            "debugServerPath": "/usr/local/Cellar/open-ocd/0.10.0/bin/openocd",
            "debugServerArgs": "-f interface/stlink-v2.cfg -f target/stm32f4x.cfg",
Insure to type proper version/revision/date inside mentioned above paths.

Post Reply