2026-01-07 11:41 PM - edited 2026-01-07 11:57 PM
Using:
I created STM32N6 project that builds two targets: FSBL and Application. I follow the instructions here: https://community.st.com/t5/stm32-mcus/how-to-debug-the-stm32n6-using-vs-code/ta-p/833499
This is a single folder project, not multi-root. The problem is that when I navigate to source code which is not under FSBL or Appli then clangd does not know which complication database to use.
This disturbs during coding and during debugging when I step through grayed out code with false errors highlighted.
CMake (or some STM32 utility) generates .clang file into the root directory. It's stripped down version looks like this:
CompileFlags:
CompilationDatabase: FSBL/build
If:
PathMatch: FSBL/.*
---
CompileFlags:
CompilationDatabase: Appli/build
If:
PathMatch: Appli/.*But there is no path match for Drivers and Middlewares. If I open HAL GPIO driver, I can see in the STM32cube clangd log that it fails to find database for it:
I[09:13:32.166] Failed to find compilation database for c:\###\Drivers\STM32N6xx_HAL_Driver\Src\stm32n6xx_hal_gpio.c
I[09:13:32.166] ASTWorker building file c:\###\Drivers\STM32N6xx_HAL_Driver\Src\stm32n6xx_hal_gpio.c version 1 with command clangd fallbackWithout complication database the "stm32n6xx_hal.h" include file is not found, HAL_GPIO_MODULE_ENABLED is undefined and the whole file is grayed out.
For STM32_ExtMem_Manager middleware I have a workaround. I created this .clangd file under it:
CompileFlags:
CompilationDatabase: ../../../../FSBL/buildSince this middleware is compiled into FSBL only it's okay, but HAL is shared and it includes configuration file from either FSBL or Appli during compile time. clangd would need to know the context.... yet I have no idea how would it work because there is no "context" in vscode in single folder project. A workspace project with subfolders could give context but there's still a single copy of files generated by CubeMX and the whole build is using CMake files in root folder. I'm using Windows, so no (easy) symlink possible either, and it would be anyway be quite ugly solution.
Any ideas?
PS.
Technically, since most of the work is done in Application I can use the same workaround for HAL and let it find Application compilation database. Regardless of that, still waiting for a clean solution. Or making a bug report. By the way, there is a similar topic, but it's not quite same story because user created the shared code. My issue comes from the ST toolset and instructions... unless I did something wrong.