Skip to main content
Use the following methods to understand the high-level categorization of ways to debug the kernel, and report issues identified with the inherent debug features in the Qualcomm® Linux kernel. For more information about debug, see Qualcomm Linux Debug Guide.

Debug with printk

Use the printk technique to debug in the Linux kernel for printing messages and tracing. The wrappers around printk defined in include/linux/printk.h support adding a log level to your log statements. For example:
pr_emerg("At line %d: Func: %s\n", __LINE__, __func__);
pr_info("At line");

Debug the kernel modules

To debug the kernel modules, do the following inside kas shell:
  1. Clone the kernel code using the devtool modify linux-qcom command.
  2. Kernel module signing is disabled by default. To manually disable kernel module signing configuration, CONFIG_MODULE_SIG use the menuconfig commands. For more information about menuconfig commands, see Configure the kernel.
The following commands helps you to manually disable the kernel module signing configuration:
CONFIG_MODULE_SIG
CONFIG_MODULE_SIG_FORCE
This is a one-time step.
  1. Make changes in kernel or modules.
  2. Re-build kernel modules using bitbake esp-qcom-image command.
  3. See install and boot the kernel to flash the updated kernel images and reboot.
For more information, see Message logging with printk.

Debug with log levels

You can print messages using any other log levels defined in /linux/printk.h. The console logs are controlled using the log level used in printk and the log level chosen on the device. Choose the log level according to your use case. You may encounter numerous logs if a lower log level is chosen in a frequently called function. The following example shows the logs for kernel print levels:
pr_info("At func %s\n", __func__);
pr_notice("At func %s\n", __func__);
pr_warn("At func %s\n", __func__);
pr_err("At func %s\n", __func__);
pr_crit("At func %s\n", __func__);
pr_alert("At func %s\n", __func__);
pr_emerg("At func %s\n", __func__);

Enable and mount the debugfs file system

Debugfs is a file system that allows kernel developers to provide kernel information to the user space. Debugfs is used to access kernel data structures and variables, trace events, debug messages, and statistics.
  • Ensure that your kernel configuration has CONFIG_DEBUG_FS set (enabled by default).
  • If not, you can enable it in your kernel configuration using menuconfig.
  • Mount debugfs if it’s not mounted by default.
    mount -t debugfs none /sys/kernel/debug
    
For kprobes, ftrace, and MMIO trace events, see Kernel probes and tracing.