platform-ststm32
platform-ststm32 copied to clipboard
BUG: Debug process using "PIO Debug (skip Pre-Debug)" does not work as expected
Problem:
Using "PIO Debug (skip Pre-Debug)" in VSCODE does build sources again, instead of just launch debug. Same happened when using "PIO Debug" : sources are built twice (one time during pre-debug, the other one during debug).
Expected behaviour:
Does not build or check sources files when "PIO Debug (skip Pre-Debug)" is selected, as the documentation indicate.
Step to reproduce:
-
Create a simple PIO ini file like this one:
[env:nucleo_f429zi] platform = ststm32 board = nucleo_f429zi framework = mbed build_type = debug -
Build one time though VSCode.
-
Go to "Run" on the left, choose "PIO Debug (skip Pre-Debug)" in the list, and click on the run button. Building should start again.
If you run again "PIO Debug (skip Pre-Debug)", then it is fine. But if you choose "PIO Debug" next time, all sources are built twice again.
Infos:
Original discussion here.
Adding build_type = debug to force debug mode when building does not help.
This problem does not seem to appear with other IDE, like CLION.
OS: Windows 10 VSCode: 1.52.1 PIO IDE Extension: 2.2.1
It seems that part of the problem could be due to multiple installation of PIO core (the built-in one of VSCode, and a global one installed on the OS e.g. via pip command).
But, while using "PIO Debug (skip Pre-Debug)", VSCode still want to build something (so if the program was edited, it will be built again)
In this case, maybe "pre-debug" is not useful anymore ? Or maybe separate the "pre-debug" just to build the program in debug mode, without trying to launch full debug ? And then have a global option called "PIO Debug" which will check source files, build if needed, and launch debug ?
I don't have a second PlO core. Disabling Builtin Python doesn't make a difference.
I fixed it for my project by editing launch.json file. The projectEnvName by default was pointing to release environment name and so the terminal was building debug env and Debug Console was building release env.
I removed fields "projectEnvName" and "executable". Now the Debug env is built once.
So I think the launch.json template seems to be the issue because the problem was with the automatically generated launch.json.
Edit: Nevermind. I cannot make it work anymore - code is built twice no matter what.
After the https://github.com/platformio/platformio-core/issues/4597 was fixed, now the remaining problem is letter drives on Windows when calculating a checksum.
They are upper-case when running in the terminal and lower-case in debug console.
Terminal:
- Checksum after version data: 0f436509ab5bd52c0ae2b582dad27602dc8c71e1
- JSON data:
b'[["platformio", [["src_dir", "C:\\\\Users\\\\dzidm\\\\Repos\\\\MKS-SERVO42B\\\\firmware\\\\src"], ["include_dir", "C:\\\\Users\\\\dzidm\\\\Repos\\\\MKS-SERVO42B\\\\firmware\\\\src\\\\BSP"], ..... - Checksum after JSON data: fae33213302e58f06acecf4878b0852887f2e409
Debug Console:
- Checksum after version data: 0f436509ab5bd52c0ae2b582dad27602dc8c71e1
- JSON data:
b'[["platformio", [["src_dir", "c:\\\\Users\\\\dzidm\\\\Repos\\\\MKS-SERVO42B\\\\firmware\\\\src"], ["include_dir", "c:\\\\Users\\\\dzidm\\\\Repos\\\\MKS-SERVO42B\\\\firmware\\\\src\\\\BSP"], .....LOWER-CASE DRIVE LETTERS - Checksum after JSON data: a3265617b703ab7b8618f1cb1eb4b1309fef17d0 - DIFFERENT
Platformio.ini:
[platformio]
src_dir = src
include_dir = src/BSP
default_envs = ServoCAN
....
Ah this should belong to PlO core issues.
The thing just fixed itself. Not sure how because I did a few things.
But it was probably related to the old version of requests and the warning:
Error: C:\Users\dzidm\.platformio\.cache\tmp\.piocore-installer-gq1ve1tz\tmpt930oxpw\pioinstaller.zip\requests\__init__.py:102: RequestsDependencyWarning: urllib3 (1.26.9) or chardet (5.1.0)/charset_normalizer (2.0.12) doesn't match a supported version!
C:\Users\dzidm\.platformio\.cache\tmp\.piocore-installer-gq1ve1tz\tmpt930oxpw\pioinstaller.zip\requests\__init__.py:102:
Strange, I don;t remember the warning until today installed debugpy.
One may have to go to C:\Users\dzidm\.platformio\penv\Scripts\, then type .\activate then pip install --upgrade requests. Or just remove the whole penv and restart VScode. Idk.
Never mind, it didn't fix itself. I just forced the path using PLATFORMIO_SRC_DIR and then forgot I set it. So probably this is not related to charset_normalizer version warning, because I don't have the warning anymore and upgrading anything didn't requests, etc didn't help.
I created pio-core issue.