Skip to content

Visual Studio Code project template for Linux kernel source development and navigation.

License

Notifications You must be signed in to change notification settings

neilchennc/vscode-linux-kernel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Visual Studio Code project template for Linux kernel

Visual Studio Code project template for Linux kernel source development and navigation.

Preparation

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)

VSCode setup

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 32bit
    • arm64 for ARM 64bit
    • x86 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 32bit
    • arm64 for ARM 64bit
    • x86 for both x86 32bit and 64bit
  • Change <cross-compile> to your cross compile path, for examples:

    • aarch64-linux-gnu- for ARM 64bit
    • x86_64-linux-gnu- for x86 64bit
  • Change defconfig to your own kernel config

Open with Visual Stdio Code

code .

Appendix

kernel build

  • 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

VSCode

  • Ctrl+P: Search files by name
  • Ctrl+Shift+F: Search text in files
  • F1, type Restart IntelliSense For Active File (type Restart and it should autosuggest)

References

About

Visual Studio Code project template for Linux kernel source development and navigation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published