Visual Studio Code project template for Linux kernel source development and navigation.
Download and install Visual Studio Code
Install C/C++ extension for Visual Studio Code (In VSCode, Ctrl+Shift+X, search "C/C++
")
Build your kernel first (important, it will generate some files that VSCode needed)
make <your-defconfig> # usually in the arch/<arch>/configs/ folder
make -j$(nproc)
Copy .vscode
to the linux kernel folder
Alternatively, you could use existing templates x86_64.vscode or arm64.vscode
Modify .vscode/c_cpp_properties.json
to make IntelliSense work
-
Change <arch> to target architecture, for examples:
arm
for ARM 32bitarm64
for ARM 64bitx86
for both x86 32bit and 64bit
-
Change <gcc-compile-path> to your gcc compile path, for examples:
/usr/bin/aarch64-linux-gnu-gcc
for ARM 64bit/usr/bin/x86_64-linux-gnu-gcc
for x86 64bit
-
Change <IntelliSenseMode> to the one of following:
linux-gcc-arm
linux-gcc-arm64
linux-gcc-x86
linux-gcc-x64
Modify .vscode/tasks.json
to make build tasks work (Optional)
-
Change <arch> to target architecture, for examples:
arm
for ARM 32bitarm64
for ARM 64bitx86
for both x86 32bit and 64bit
-
Change <cross-compile> to your cross compile path, for examples:
aarch64-linux-gnu-
for ARM 64bitx86_64-linux-gnu-
for x86 64bit
-
Change defconfig to your own kernel config
Open with Visual Stdio Code
code .
-
Show kernel build commands and defines
make V=1
-
Specific kernel build output directory
make O=<output-dir> [extra_args] ...
-
Change to kernel directory
make -C <kernel-src-dir> [extra_args] ...
-
For more info
make help
- Ctrl+P: Search files by name
- Ctrl+Shift+F: Search text in files
- F1, type
Restart IntelliSense For Active File
(typeRestart
and it should autosuggest)