> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure debug methods

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<sup>®</sup> Linux kernel.

For more information about debug, see [Qualcomm Linux Debug Guide](https://dragonwingdocs.qualcomm.com/System/Debug-Subsystem/debug-overview).

## **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:

```text theme={null}
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:

> ```text theme={null}
> CONFIG_MODULE_SIG
> ```
>
> ```text theme={null}
> CONFIG_MODULE_SIG_FORCE
> ```

<Note>This is a one-time step.</Note>

3. Make changes in kernel or modules.
4. Re-build kernel modules using `bitbake esp-qcom-image` command.
5. See [install and boot the kernel](./install-and-boot-the-kernel) to flash the updated kernel images and reboot.

For more information, see [Message logging with printk](https://docs.kernel.org/core-api/printk-basics.html).

## **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:

```text theme={null}
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.
  ```text theme={null}
  mount -t debugfs none /sys/kernel/debug
  ```

For kprobes, ftrace, and MMIO trace events, see [Kernel probes and tracing](./kernel-probes-and-tracing).
