Debugging feature

No, Black Magic Probe works without OpenOCD, it has built-in debug server on a dongle. I gave a hint with OpenOCD because it supports multiple adapters. You can use any adapters that are compatible with GDB server software or handle it internally on a chip.

Nucleo has on-board ST-Link, as result, you can use it for debug. No need to buy additional dongle/adapter.

Could you provide a link? Maybe we can add support for it?

It was for another hardware.
At my beginning with miocrocontrollers I bought a AVRISP mkII for debuging (Shame on me).

I get the same issue when I am trying with my black magic probe. Occasionally I get the debug window but no variables are shown. I ll post the screenshots when I get home from work.

Okay.
A little progress.

Here are my findings. My BMP wasnt able to upload the bluepill board no matter what I did, forget debugging.
All I got was an error “SWDP_Scan Failed!”

On going through this post

http://www.stm32duino.com/viewtopic.php?t=1614

I realised, that the arduino port for the STM32, by default, disables the SWD functionality for the sake of GPIO functionality. So no matter what debugging tool you use SWD debugging and or uploading is not possible.

The fix is given in the replies below. Either place the bluepill in Serial bootloader mode, reset and it uploads fine via BMP or fix the build flags in the platformio.ini file.

Adding this,

build_flags = -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1

to the platformio.ini file will allow you to override the stm32 arduino build and enable the SWD pin functionality.

SWD debugging using any compatible adapter works afterwards.
I was able to debug as shown, but soon ran into the problem as explained here.

https://community.platformio.org/t/platformio-debugging/1704/3

I too get the same errors sometimes when I try to debug, further while the variables are shown in the watch window, any incrementing of the variables in code does not reflect in the watch window.

I ll keep digging and see what else I can do to fix the debugging issue. I suspect it has nothing to do with the platformio but more to do with gdb. A quick google search reports that these issues are common even in eclipse (on X86 platforms, I did not check if any results contained references to any embedded platforms)

Maybe another day or so and I should have an answer for the debugging issues too.

Hope this helps someone reduce their frustration. :slight_smile:

(Please excuse any grammatical errors, Its almost 3 AM here and I spent the last 5-6 hours trying to understand and resolve this issue. Highly tired and sleep deprived)

Okay then, new day refreshed and clear mind.
Compiling the code with these flags

build_flags = -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB

and using the USB connection of the bluepill board as a USB Serial passthrough is working just fine.
I am able to debug using the platformio debug tools.

I faced the problem earlier because I was using the native Serial port and a FT232 board and debugging. For some reason it was finicky and unreliable. The Serial_USB flags works just fine and I am able to debug now.
:slight_smile:

Thanks a lot @ivankravets and the platformio team for the addition.

I suggest anyone who is working with the STM32 processors and arduino framework to replicate the build_flags steps and then check if debugging is working.

1 Like

As @ivankravets suggested i bought a nucleo stm32f103 board.
Initial setup including debugging with platformio is really plug-and-play!
It works out of the box.
Unfortunately i have a similar problem as described here:

None of the variables are shown in the variables window.
Is there any possibility to enter custom gdb commands?

Are you using mbed framework or arduino??

tried with mbed framework.

Gimme some time. I have tried and got results with arduino. I ll try with the mbed framework and report back.

Thank you!

PS:
I’m totally new to stm32 and bought the nucleo, another blue pill and a st-link.
at the moment i have only the blue pill and the nucleo (second blue-pill and st-link is on the way).

Really appreciate your feedback! Thanks a lot!!! I understand all issues what you have reported above. We have an internal discussion within our team what to do with debug front-end. Currently, we use Atom’s gdb GUI and it’s made for desktop debugging, not embedded, as result, functionality is very limited.

If debug is really important for our community, we will refactor it. Currently, that isn’t an alpha or beta, it’s just a prototype/experiment. Need to receive first feedback what do you think about this approach.

If you like generic idea and our debug workflow, please vote here and we will make it better.

GDB does not provide MI-command to fetch GLOBAL variables. Only local/in-scope variables could be fetched automatically. Current GUI doesn’t provide functionality to add manually variable to watch list. That is why we think on a new front-end for debug.

Will it be much work to provide a gdb-command-line interface?
That would be a huge advantage.

Okay then!!
Tried with the mbed blinky and upload_tool=bmp and atom throws an error that bmp is an unrecognised tool.
:neutral_face:
I am unable to start debugging at all with the BMP and mbed code. It compiles fine and uploads fine using BMP. But no for debugging.

@Robert_Walli I am assuming that you tried debugging with the St-link bundled with the nucleo boards.

In such a case, I think the issue lies with the mbed compilation. Since neither of the debuggers BMP and St-Link are able to debug. Can you post the code that you are trying to debug. Also, is there a chance you have inadvertently declared one of the SWD pins as GPIO or some other functionality??

@ivankravets I am assuming you are using Mbed-cli and arm-none-eabi-gcc for the code compilation. Maybe there is a flag there that is playing havoc.

These posts

https://developer.mbed.org/questions/3996/Nucleo-F401RE-SWD-ERROR-problem/

https://developer.mbed.org/questions/3908/Cannot-loaddebug-NUCLEO-401RE-with-uVisi/

https://developer.mbed.org/questions/973/SWD-error/

seems to indicate that even the mbed and/or st-link is disabling the SWD functionality, or at the very least is inconsistent. I ll need to familiriaze myself with the mbed compilation process and start troubleshooting it.

Yes, and debugging is working!
Only the gui output is very limited.
I tried to debug the mbed-blink-example and i have no output in the main function.
BUT: when I “step into” functions I can examine the variables.

Here - as an example - the “wait-function”:

(sorry for the image, but otherwise the s=0.30000012 is not visible)

Nice!! :slight_smile:

Now we know st-link works with the mbed.
Try incrementing a counter in the main loop for each iteration of the blink_led and see if that shows up in the watch window.

:slight_smile:

That’s the the reason of my posting and the first thing i tried out:
If you define the loop counter globally or within the main function, it’s not visible in the debug window.
I have even tried to increment the counter in a sub function but it’s not visible.

A gdb-commandline would be great.

hmm…
thats funny… I faced the same issue but my brain did not register the fact till you pointed it out.
I ll try manually debugging the same code using command line gdb from the terminal and report back.

can you give me a small hint how to start gdb within platformio?

Well, the brute force way is to simply toggle the terminal by pressing

CTL + ~

which will start a terminal in the current project base folder. Then you can manually invoke the gdb binary from the .platformio folder.

On Mac it is under /Users/(Username)/.platformio/packages/toolchain-gccarmnoneeabi/bin.

It will start the gdb session and you can debug away happily. but it is not elegant and is kinda a hack. :slight_smile: