Platformio builds mbed sources twice while debugging

Hi!
I’m trying to debug mbed application with Nucleo-F429Zi and platformio.
Rebuild of the project is painfully slow due the size of mbed framework.
So I decided to choose build_type = debug in platformio.ini.
After successfully build I tried to start debug.

The debug process started as usual build and finished in terminal.
But then pio started the same build task in DEBUG CONSOLE with full project rebuild!
And after this second build it started the debugging, but then if you want to build your project it start to rebuild again.

OS Windows 10, latest platformio, vscode and embed.

Even if I press Restart(Ctrl+Shift+F5) button in debug it starts to rebuild project, but failed to create elf file.

Hello @anikinmd

In VSCode, try to choose “PIO Debug (skip pre-debug)” in the list, instead of the default “PIO Debug”.

image

This should resolve your issue.

@copperbot-d thanks for the fast answer.
That is not helped.
With skipping pre-debug it is not starting the build process in the regular console but it still running full rebuild in the debug console.

Hmm, could you please send the content of your platformio.ini file ?

EDIT: indeed I can reproduce the same issue in VSCODE, even by using build_type = debug. This is weird, I don’t have this issue using CLION.

My platformio.ini:

[env:nucleo_f429zi]
platform = ststm32
board = nucleo_f429zi
framework = mbed
build_type = debug
board_build.f_cpu = 180000000L
build_unflags = -Os
build_flags = -O0

This seems to be a VSCode issue, because it should not be the expected behaviour judging by the documentation:

Maybe a bad configuration somewhere, gotta check issues if there is something related, if not then creating one.

EDIT: issue created

EDIT 16/08/2023:

Please be aware that this response is now deprecated, as PIO now support natively .mbedignore files. More info here.

If you are looking for a working .mbedignore for Mbed 6.17, try this one.

OLD RESPONSE

By the way, not related to this specific issue, but regarding MBED framework build time: you can reduce it, using a script originally made by @KKoovalsky which apply a .mbedignore file inside mbed-framework folder from a PIO project.

  • Download this fork.
  • Copy mbedignore_examples/PIO_MBED_6.6/.mbedignore file to the root of your PIO project.
  • Copy mbedignore.py script to the root of your PIO project.
  • Edit your platformio.ini and add this line:
extra_scripts = pre:mbedignore.py

That should reduce the build time. Check the README for more info. You may need to edit the .mbedignore file if you want to skip other components during the build.

Another option, if you don’t need MBED RTOS, you can just use MBED 6 bare metal profile, see this response.

3 Likes

@anikinmd do you have another PIO core installation in your system ? I just resolve the issue by deactivate Built-in PIOCore and Builtin Python in my VSCode PIO extension settings.

@copperbot-d thank you! That helped. I installed pio core with pip globally and turned off the Built-in core in VSCode extension settings.

1 Like

Needed to say that i installed the second pio core yesterday (I tryed to use CLion with pio instead of VSCode). The issue was found before I installed the second core.

Well, actually I first tried to deactivate my PIO core installation (remove python3.8 from my system path), to only have the built-in one of VSCode… and indeed I was still having this issue. So maybe there is a problem elsewhere.

It’s like VSCode always have two python environments when using PIO (even if I remove my global one), and got mad when switching between “pre-build” and “PIO debug”. Maybe it is related to this issue, it seems to appear mostly on Windows.

Deactivate built-in functionnality of the extension seems to work great, and force VSCode to look at the global python installation instead (with the PIO CORE). But new user who discovers PIO with VScode, and already have a python installation on their windows OS, could be facing the same issue.

I just created an account to say that THIS IS FIRE!
This script reduced my compiling time from 40 to 5 seconds
Im working on a big project, rebuilding every 3 minute and this is awesome!

1 Like