Debug STM32 with VScode

Development environment specific, Arduino, Eclipse, VS2013,Em::Blocks etc
iamseer
Posts: 11
Joined: Sat Mar 11, 2017 7:06 am

Debug STM32 with VScode

Post by iamseer » Wed Jul 19, 2017 7:55 pm

Hi all, I used to debug STM32duino with Keil, with has code limit. I tried VScode and made it work with ST-link.

This tutorial shows how to debug STM32 with VScode

Follow instructions on https://github.com/rogerclarkmelbourne/Arduino_STM32
And make sure it works in Arduino IDE. Also make sure the folder is called “Arduino_STM32”, not “Arduino_STM32-master”
1_installSTM32.png
1_installSTM32.png (150.59 KiB) Viewed 1526 times
In Arduino’s board manager, install “Arduino SAM Boards (32-bits ARM Cortex-m3)”, in order to get a compiled version of openOCD
2_installCortexM0.png
2_installCortexM0.png (87.22 KiB) Viewed 1526 times
Now openOCD should appear in “Arduino15” folder. The location of that folder is different in Mac, Windows or Linux. In Mac, it is located in ~/Library

Open “packages” in “Arduino15”, create a folder called “Arduino_STM32”. Look for openOCD and copy it to “Arduino_STM32” within “packages”.
3_copy_openOCD.png
3_copy_openOCD.png (172.44 KiB) Viewed 1526 times

iamseer
Posts: 11
Joined: Sat Mar 11, 2017 7:06 am

Re: Debug STM32 with VScode

Post by iamseer » Wed Jul 19, 2017 7:57 pm

Download a copy of openOCD for its script files.
4_download_openOCD.png
4_download_openOCD.png (188.25 KiB) Viewed 1525 times

Copy scripts files into “scripts” folder in “packages”. Follow this structure.
5_copy_script.png
5_copy_script.png (71 KiB) Viewed 1525 times
Install VScode and Arduino extension
6_installExtension.png
6_installExtension.png (210.11 KiB) Viewed 1525 times

Debugging STM32 require some edit in “misc/usbmapping.json”. I did a PR and get merged into master branch. However you may not get it automatically until next release. If not, find your local file and replace it with the newest one on https://github.com/Microsoft/vscode-ard ... pping.json

iamseer
Posts: 11
Joined: Sat Mar 11, 2017 7:06 am

Re: Debug STM32 with VScode

Post by iamseer » Wed Jul 19, 2017 7:58 pm

Happy debugging!
7_debug.jpg
7_debug.jpg (144.74 KiB) Viewed 1525 times

universam10
Posts: 19
Joined: Sun Jan 03, 2016 8:35 am
Location: Germany

Re: Debug STM32 with VScode

Post by universam10 » Thu Jul 20, 2017 3:35 pm

Awesome :D

But I got a few questions:

#4 there are no scripts files in the Arduino/OpenOCD repository!?

#5 How did you get the Board available, although I have installed in Arduino the STM boards, I dont see the available in the VScode Arduino extension!>

Thank you!

iamseer
Posts: 11
Joined: Sat Mar 11, 2017 7:06 am

Re: Debug STM32 with VScode

Post by iamseer » Thu Jul 20, 2017 4:21 pm

#4
There are
https://github.com/arduino/OpenOCD/tree/master/tcl

#5
Make sure you put STM32duino in Documents instead of the Arduino itself. Otherwise VScode won't look for it.

scoace
Posts: 6
Joined: Sat Jan 23, 2016 6:50 am

Re: Debug STM32 with VScode

Post by scoace » Thu Jul 20, 2017 8:17 pm

Anyone succeeded with Linux ? I suppose problems with openocd and scripts directory.

User avatar
zoomx
Posts: 541
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Debug STM32 with VScode

Post by zoomx » Fri Jul 21, 2017 5:57 am

iamseer wrote:
Thu Jul 20, 2017 4:21 pm
#5
Make sure you put STM32duino in Documents instead of the Arduino itself. Otherwise VScode won't look for it.
I use the portable version od the official Arduino IDE. VScode was able to find all the boards installed in the portable/sketchbook/hardware folder.

There are two Arduino plugins, I used the Microsoft plugin like iamseer.

Remember that VScode is not VSstudio.

universam10
Posts: 19
Joined: Sun Jan 03, 2016 8:35 am
Location: Germany

Re: Debug STM32 with VScode

Post by universam10 » Fri Jul 21, 2017 7:08 am

iamseer wrote:
Thu Jul 20, 2017 4:21 pm
#4
There are
https://github.com/arduino/OpenOCD/tree/master/tcl
Actually, I found they are already available from step #2 under
\packages\arduino\tools\openocd\0.9.0-arduino6-static\share\openocd\scripts\
iamseer wrote:
Thu Jul 20, 2017 4:21 pm
#5
Make sure you put STM32duino in Documents instead of the Arduino itself. Otherwise VScode won't look for it.
Perfect, that was the key! :D
I had for other reasons the installation of Arduino_STM32 in the Arduino Program Files folder, so I had to move.

Awesome, thank you so much :!:

User avatar
zoomx
Posts: 541
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Debug STM32 with VScode

Post by zoomx » Fri Jul 21, 2017 10:50 am

You must use the folder "hardware" that is inside the folder where all sketches are.

universam10
Posts: 19
Joined: Sun Jan 03, 2016 8:35 am
Location: Germany

Re: Debug STM32 with VScode

Post by universam10 » Fri Jul 21, 2017 11:56 am

Not necessarily, there are reasons why it is better to put it in "..\arduino-1.6.x\hardware\Arduino_STM32", obviously not in this case.

Post Reply