VSCode stm32cube framework intellisense failure

VSCode 1.20.0-insider

Following STM32Cube HAL and Nucleo-F401RE: debugging and unit testing — PlatformIO latest documentation

After I copy/paste the main.* content, change the stm32f4xx_hal include to the f1 version, I press CTRL- at one of the #define statements which results in a bunch of things happening…

  1. “ERROR Cannot find the arduino installation path. Please specify the “arduino.path” in the User Settings. Requires a restart after change.”
  2. Windows for Default/User/Workspace Settings is brought up
    3a) OUTPUT window is focused and “Arduino” is selected in the dropbox.
    3b) “[Starting] Update package index files…
    [Error] Exit with code=undefined” (and my harddrive is still thrashing as I type this. It takes minutes before it settles down).
  3. Intellisense comes up with very little (including NONE of the references for those #define statements).

If “framework = stm32cube”, why is arduino showing up anywhere?

My only guess to what’s happening is bug-related. (drive still thrashing as I re-read)

Playing with stm32cube-hal-blink which at least builds.
I guess intellisense doesn’t work with define references.

But for some reason the project that was created by platformio and the sample code used doesn’t build:

Unable to open ‘stm32f1xx.h’: File not found (file:///home/user/Documents/Visual Studio Code/project1/home/user/.platformio/packages/framework-stm32cube/f1/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h).

Note how the paths for the project and include file path are concatenated.
The errors just rush in after that.

I ran a diff on the c_cpp_properties.json and the only notable differences were the device that I guess I needed to add “STM32F103xE” vs “STM32F072xB” and “F0”.
The search paths were also different obviously, but still comparable (doesn’t explain that error message).

I added “build_flags = -v” to platform.ini and the first error is

/home/user/.platformio/packages/framework-stm32cube/f1/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h:159:3: error: #error “Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)”

Fine. I add “STM32F103xE” to the “defines” in “c_cpp_properties.json” and the same error comes up when building.
I did a search in the terminal for “STM32F103xE” and NOTHING came up.

So then I set “build_flags = -v -DSTM32F103xE” in “platformio.ini” and the build finally progresses.

I’m flummoxed as to why the definition in c_cpp_properties.json isn’t being included. I searched the terminal output for “USE_HAL_DRIVER” and that showed in all instances.
But for some bizarre reason, STM32F103xE isn’t included in the build unless I add it to the “build_flags” in platform.ini.

What a mess.

OH! This is a new one on me…
After I closed VSCode then re-opened my project, I found my added STM32F103xE define entry was no longer there.

I tested it several times and could visually SEE the entry get removed every time.


Except I guess formulahendry forked it because that setting isn’t available.


Welp, looks like it’s intended to work that way and “build_flags” is what’s needed for any additions. Who knew… (that guy)

  1. Please uninstall Microsoft’s Arduino extension which raises errors.
  2. Use this option to control build flags Redirecting...