Kernel Debug examples
This chapter covers the basics of Linux Kernel projects including creating and debugging a static Kernel.
Components Prerequisites
To build, run and debug Linux static kernel, please make sure that all below components are installed. Please refer to Component management for more information about installing component.
- xplor-studio-kernel-debug-plugin: Kernel XploR Studio Plugin using for kernel debugging
- rv-linux-rootfs-debug: RISC-V RootFS for running/debugging Kernel and Embedded Linux applications
- rv-qemu-linux64/rv-qemu-win64: QEMU for running and debugging RISC-V applications (Baremetal, Embedded, Embedded Linux)
All above components are compulsory for debugging static kernel. Depending on variation of toolchain, XploR Studio has 4 different Linux toolchain components:
- rv32imac-xplor-linux-linux64/rv32imac-xplor-linux-win64: RISC-V Embedded Linux toolchain 32-bit (no Float)
- rv32gc-xplor-linux-linux64/rv32gc-xplor-linux-win64: RISC-V Embedded Linux toolchain 32-bit (Double)
- rv64imac-xplor-linux-linux64/rv64imac-xplor-linux-win64: RISC-V Embedded Linux toolchain 64-bit (no Float)
- rv64gc-xplor-linux-linux64/rv64gc-xplor-linux-win64: RISC-V Embedded Linux toolchain 64-bit (Double)
Each toolchain can be downloaded separately.
Working flow
Create a new project
Select File > New > C/C++ Project, choose Linux Kernel Project and Next.
Enter the Project name and select Embedded Linux XploR Toolchain for RISC-V in the Toolchains box, then click Next.
Select Kernel Source Path then click Finish.
Update build settings
With build settings, users can switch from 32 bits to 64 bits as well as different floating point ABI options (except Single Precision). The kernels are specified via those options.
Please refer to the below table to select the correct options for each target.
Platform | Core | Architecture | Floating Point |
---|---|---|---|
QEMU | RISC-V emulator | RV32 | None |
QEMU | RISC-V emulator | RV32 | RVFD |
QEMU | RISC-V emulator | RV64 | None |
QEMU | RISC-V emulator | RV64 | RVFD |
Build project
Warning: The Static Kernel project does not need to be built because the XploR Studio uses a pre-build kernel image for debugging.
Running the kernel with QEMU emulator
Note: XploR Studio does not support to the run Static Kernel project!
Debugging the kernel with QEMU emulator
Note: Before debugging the kernel, the users should select the architecture and floating point options. By default, the combine (RV64, None) is selected. Please refer to Section 2: Update build settings
There are two ways to debug the kernel:
- On the Project explorer, right-click on the project name and select Debug as > RISC-V Kernel application with QEMU.
- Create the new RISC-V Kernel Debugging configurations: Right-click on the project name then select Debug As > Debug Configurations.
Double-click on RISC-V Kernel Debugging, then click Debug to start the Kernel debugging session.
When starting kernel debugging, the kernel is suspended in the start_kernel function and the terminal/console pauses at kernel booting.
To debug an embedded Linux applications, the kernel should be booted completely.
Notes
To switch arch between 32-bit and 64-bit, users should remove the old Debug Kernel Configuration and create a new one to change the kernel (vmlinux).
Or users can replace vmlinux manually at: ~/.xplor/components/rv-linux-rootfs-debug/rv***_debugkernel/vmlinux
Sometimes unable to debug Kernel for the first time with information such as follows:
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.