Debug STM32 with VScode

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

Re: Debug STM32 with VScode

Post by caniggia » Tue Jul 25, 2017 9:25 am

HI @iamseer

It works on windows too.

thnx
caniggia

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

Re: Debug STM32 with VScode

Post by scoace » Fri Jul 28, 2017 7:49 am

After some days of investigation. It works on linux too. Adapt the usbmappings.json and that is my launch.json for the debugger:

Code: Select all

{
    "version": "0.2.0",
    "configurations": [
    
        {
            "name": "Arduino",
            "type": "arduino",
            "request": "launch",
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "MIMode": "gdb",
            "targetArchitecture": "arm",
            "miDebuggerPath": "/usr/bin/arm-none-eabi-gdb",
            "debugServerPath": "/usr/bin/openocd",
            "debugServerArgs": "-f interface/stlink-v2.cfg -f target/stm32f1x.cfg",
            "customLaunchSetupCommands": [
                {
                    "text": "target remote localhost:3333"
                },
                {
                    "text": "file ${file}"
                },
                {
                    "text": "load"
                },
                {
                    "text": "monitor reset halt"
                },
                {
                    "text": "monitor reset init"
                }
            ],
            "stopAtEntry": true,
            "serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
            "launchCompleteCommand": "exec-continue",
            "filterStderr": true,
            "args": []
        }
    ]
}
:D Happy debugging
Last edited by scoace on Fri Jul 28, 2017 10:05 am, edited 1 time in total.

zmemw16
Posts: 1449
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Debug STM32 with VScode

Post by zmemw16 » Fri Jul 28, 2017 9:53 am

details, details and more detail please, pretty please :D
stephen

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

Re: Debug STM32 with VScode

Post by scoace » Fri Jul 28, 2017 10:16 am

Image

and that is how it looks like :D
Attachments
Bildschirmfoto vom 2017-07-28 11-58-12.png
Bildschirmfoto vom 2017-07-28 11-58-12.png (232.92 KiB) Viewed 338 times

User avatar
RogerClark
Posts: 7177
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Debug STM32 with VScode

Post by RogerClark » Tue Aug 01, 2017 8:07 am

I installed VS Code then installed the Arduino plugin..

But it keeps telling me I need to select a Board, but there isnt an option to do this

Did you somehow get it to run the settings.json file ??

Currently the auto complete and contextual help do not work at all for Arduino i.e it doesnt know what Serial is or delay() is etc etc

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

Re: Debug STM32 with VScode

Post by caniggia » Tue Aug 01, 2017 10:37 am

@RogerClark

Press F1 (or Ctrl+Shift+p),
and type "arduino" and you will get all arduino plugin commands.

caniggia

User avatar
RogerClark
Posts: 7177
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Debug STM32 with VScode

Post by RogerClark » Tue Aug 01, 2017 11:48 am

caniggia wrote:
Tue Aug 01, 2017 10:37 am
@RogerClark

Press F1 (or Ctrl+Shift+p),
and type "arduino" and you will get all arduino plugin commands.

caniggia
Thanks

I managed to at least select an AVR board.

But the context sensitive completion seems to be odd.

If I start typing

Serial.

The first suggested completion is .addr

Which AFIK is not part of the API
https://www.arduino.cc/en/Reference/Serial

However it does work for delay() and millis() etc

I guess they need to do more work on this...

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

Re: Debug STM32 with VScode

Post by caniggia » Tue Aug 01, 2017 12:35 pm

VScode Blink project for bluepill.
Set for ST-Link upload.
To change upload method:
Press F1 nad type "Arduin: Board Config"
For Verify/Compile press CTRL+ALT+R
For Upload press CTRL+ALT+U

caniggia
Attachments
Blink.zip
(1.91 KiB) Downloaded 18 times

stuartw
Posts: 36
Joined: Mon Jun 01, 2015 8:57 am

Re: Debug STM32 with VScode

Post by stuartw » Fri Aug 11, 2017 10:14 am

Well, intriguing as this looks, I have been wrestling it for several days..

Windows 7 (yes yes, I shall burn myself at the stake later..), VS Code, Arduino pluging, etc, etc.
I can get it to accept the board, build, upload (although it would be nicer if you didnt have to use the arduino specific vrtify/upload commands).
I would prefer it if I could see compiler output, however it is probably hidden somewhere.
Serial monitor works, blink blink blink..

However, any attempt at debug (STLink to blue pill) results in 'Unable to start debugging. No process is associated with this object.'
And thats when several days of tearing my hair out started..

Now, when I initialise the project, I get a launch.json file with not much in the way of links to things, ie:
"targetArchitecture": "arm",
"miDebuggerPath": "",
"debugServerPath": "",
"debugServerArgs": "",
"customLaunchSetupCommands": [
{
"text": "target remote localhost:3333"
},
etc..
The error implies I need links in there, and I have followed the instructions at the start of the thread as best I have been able, but it just seems to have it in for me.

Any thoughts?

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

Re: Debug STM32 with VScode

Post by caniggia » Fri Aug 18, 2017 11:02 am

Hi @stuartw

Make sure the folder in "..\Documents\Arduino\hardware\" is called “Arduino_STM32”, not “Arduino_STM32-master”.

* For OpenOCD you need:
Add 2 folders(Arduino_STM32 & scripts) from attached zip to "C:\Users\<username>\AppData\Local\Arduino15\packages\".
Zip is too long to attach it here, so i put up link to dropbox:
https://www.dropbox.com/s/oce9danpebl25 ... d.zip?dl=0
If you don't trust this link/files, you can find all this files in:
"C:\Users\<username>\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino6-static"

You don't need to change anything in launch.json.

Next step is not needed anymore with extension v0.2.5
* For ST-link Debugging to work with selected generic board:
You also need(for current version of extension v0.2.4) to replace "usbmapping.json" with file in attached zip in:
"C:\Users\<username>\.vscode\extensions\vsciot-vscode.vscode-arduino-0.2.4\misc\"


BR
caniggia
Attachments
usbmapping.zip
(988 Bytes) Downloaded 12 times
Last edited by caniggia on Fri Aug 25, 2017 8:22 am, edited 2 times in total.

Post Reply