How to debug only with stlink on nuclreo board

Hello
I am using the slow nucleo f030r8.
I installed platformIO from vs code.
Your platformio.ini will look like this:

==========================================

[env:disco_f030r8]
platform = ststm32
board = disco_f030r8
framework = arduino

debug_tool = stlink
upload_protocol = stlink
upload_port = COM6
build_flags = -DCORE_DEBUG_LEVEL=1

build_type = debug

============================================

main.cpp looks like this:

============================================

#include <Arduino.h>

#define LD2 PA5

int temp = 0;

void setup() {
  pinMode(LD2, OUTPUT);
}

void loop() {
  int temp1 = 0;

  digitalWrite(LD2, HIGH);
  delay(400);
  digitalWrite(LD2, LOW);
  delay(400);
  temp++;
}

============================================

This is the last part of the message after starting debug.

============================================

Compiling .pio\build\disco_f030r8\FrameworkArduino\wiring_pulse.cpp.o
Compiling .pio\build\disco_f030r8\FrameworkArduino\wiring_shift.c.o
Compiling .pio\build\disco_f030r8\FrameworkArduino\wiring_time.c.o
Archiving .pio\build\disco_f030r8\libFrameworkArduino.a
Linking .pio\build\disco_f030r8\firmware.elf
Checking size .pio\build\disco_f030r8\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [= ] 11.0% (used 904 bytes from 8192 bytes)
Flash: [== ] 18.7% (used 12268 bytes from 65536 bytes)
Building .pio\build\disco_f030r8\firmware.bin
======================== [SUCCESS] Took 36.04 seconds =====================

Terminal will be reused by tasks, press any key to close it.

But I’m not debugging.
I think VARIABLES should appear.
But nothing appears.

And I removed cn2 from the nuclreo board and prepared it.
I would like to know if there is an additional way to enter debugging mode.
I need help.

It doesn’t look like debugging is starting. Also, you should remove the breakpoints from different files, maybe there’s too many of them.

What does it say in the “Debug Console” or “Output” tab of VSCode after you press Go → Start Debugging?

I have a Nucleo board, but it’s not the same as yours, mine’s a F103RB. However, I’ve never got around to playing with it in PlatformIO (or Arduino) so I created a new project and added most of your platformio.ini and your main.cpp.

When I enter debuging using F5, I get a breakpoint in main. I can set other breakpoints and step through/over various lines of code without problems. I can see variables but obviously only when they are in scope.

Looking at your screen shot, I’m not seeing a debug toolbar anywhere, which make @maxgerhardt’s observation that debugging hasn’t started very relevant. When debugging there’s a toolbar with a few buttons on it to step over, step into, continue and stop etc. Your screen isn’t showing that.

If you switch to the other tab in VSCode that’s showing the main.ccp 1 title in a reddish brown text colour (there’s a ‘1’ suffix and a path on the tab’s title too), can you debug there? When I’m debugging it’s that window that’s the active debug window and not the main.cpp tab.

Other ways to initiate debugging:

  • Press F5
  • Run->Start Debugging
  • CTRL+SHIFT+P → Platformio Start Debugging
  • Click Alien head (left toolbar) → Quick Access → Debug → Start Debugging

Each of those options starts a debugging session for me, and opens a new source window onto main.cpp initially, but as I step into various lines of code, it changes the windo to be the source file that the function I’m stepping through, is located in.

I think you are looking at your source code file and not the actual debugging session’s view of your source file. I think you have clicked off the debug tab onto your own file. I can reproduce your screen here just by doing that.

HTH

Cheers,
Norm.

Checking size .pio\build\disco_f030r8\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [== ] 15.0% (used 1232 bytes from 8192 bytes)
Flash: [=== ] 29.7% (used 19464 bytes from 65536 bytes)
========================= [SUCCESS] Took 4.80 seconds =========================
undefinedError: Traceback (most recent call last):
File “c:\users\ilk48.platformio\penv\lib\site-packages\platformio_main_.py”, line 109, in main
cli() # pylint: disable=no-value-for-parameter
File “c:\users\ilk48.platformio\penv\lib\site-packages\click\core.py”, line 829, in call
return self.main(*args, **kwargs)
File “c:\users\ilk48.platformio\penv\lib\site-packages\click\core.py”, line 782, in main
rv = self.invoke(ctx)
File “c:\users\ilk48.platformio\penv\lib\site-packages\platformio\commands_init_.py”, line 44, in invoke
return super(PlatformioCLI, self).invoke(ctx)
File “c:\users\ilk48.platformio\penv\lib\site-packages\click\core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “c:\users\ilk48.platformio\penv\lib\site-packages\click\core.py”, line 1066, in invoke

==============================================================

It will appear in the debug console as above.
It will appear in the debug console as above.
I ran this command: pip install -U platformio
But the problem is the same.

The OUTPUT console does not appear.

As you said, the toolbar is not visible.
However, the toolbar is visible while compiling and uploading, and disappears when finished.
It is downloaded, but it is suspected that communication for debugging is not possible.

I’m assuming that it isn’t visible in any VSCode tab? Even on the 4th tab in your screenshot above?

That 4th tab is the debugging tab on my setup with your code. main.cpp c:\...\arduino 1.

Just wondering.

Cheers,
Norm.