Kernel Debug examples

Static Linux Kernel Project for XploR Studio

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.

example image

Enter the Project name and select Embedded Linux XploR Toolchain for RISC-V in the Toolchains box, then click Next.

example image

Select Kernel Source Path then click Finish.

example image

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.

example image

Please refer to the below table to select the correct options for each target.

PlatformCoreArchitectureFloating Point
QEMURISC-V emulatorRV32None
QEMURISC-V emulatorRV32RVFD
QEMURISC-V emulatorRV64None
QEMURISC-V emulatorRV64RVFD

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.

example image

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.

example image

  • Create the new RISC-V Kernel Debugging configurations: Right-click on the project name then select Debug As > Debug Configurations.

example image

Double-click on RISC-V Kernel Debugging, then click Debug to start the Kernel debugging session.

example image

When starting kernel debugging, the kernel is suspended in the start_kernel function and the terminal/console pauses at kernel booting.

example image

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:

example image