Clangd in Torizon Core Builder

Hello,

I’ve been trying to get good intellisense in VSCode for developing kernel modules.

I finally got there!

the Microsoft C/C++ extension wasn’t what I needed… clangd was.

To make it work, I had to:

  1. source tcb with a persistent folder, not a docker volume
  2. get the .config from my device and put it in the linux directory (maybe not needed?)
  3. run make with a compile_commands.json flag
  4. create some symlinks
  5. etc.

I’m not (yet) entirely sure the minimal steps to make it work.

My question: can this be done on the Toradex side to make things easier for all of us?

More info: I’m running VSCode in WSL. I installed clangd and the LLVM clangd extension. Once I got the configs right, I now get:

  1. No error squiggles (see #4)
  2. F12 support to jump to definitions from my .c files
  3. F12 to jump to includes
  4. Squiggles on my own errors!!!

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


Based on the available documentation, I can see you’re working on improving the development experience for kernel modules with TorizonCore Builder. While the current documentation doesn’t specifically address clangd integration, there are several relevant aspects to your workflow.

Current TorizonCore Builder Workflow

The standard process for building external kernel modules with TorizonCore Builder involves using the kernel build_module command(1). The documentation shows this basic workflow:

$ torizoncore-builder kernel build_module hello-mod

(1)

Addressing Your Development Environment Needs

Your approach of using persistent folders instead of Docker volumes aligns with some documented practices. The documentation mentions that TorizonCore Builder can work with local directories for various customizations(2).

For the .config file you mentioned, the kernel configuration process is documented in the BSP build instructions, where the kernel config can be obtained and applied(3):

$ cp kernel-config ~/linux && cd ~/linux 
$ mv kernel-config .config 
$ make olddefconfig

(3)

Potential Integration Opportunities

Your suggestion about improving IDE support is valuable. Currently, the documentation focuses on the build process itself rather than development environment integration. The compile_commands.json generation you mentioned is a standard approach for enabling better IDE support with clangd.

Recommendation

I’d suggest sharing your specific workflow and configuration details on the Toradex Community where other developers and Toradex engineers can evaluate the feasibility of integrating such improvements into the official toolchain. This would help determine if similar IDE integration features could be added to TorizonCore Builder or documented as best practices.

Your experience with clangd providing better IntelliSense than the Microsoft C/C++ extension for kernel module development could be valuable for other developers facing similar challenges.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.