Debug with printk
Use theprintk 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:
Debug the kernel modules
To debug the kernel modules, do the following inside kas shell:- Clone the kernel code using the
devtool modify linux-qcomcommand. - Kernel module signing is disabled by default. To manually disable kernel module signing configuration,
CONFIG_MODULE_SIGuse themenuconfigcommands. For more information aboutmenuconfigcommands, see Configure the kernel.
This is a one-time step.
- Make changes in kernel or modules.
- Re-build kernel modules using
bitbake esp-qcom-imagecommand. - See install and boot the kernel to flash the updated kernel images and reboot.
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:
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_FSset (enabled by default). - If not, you can enable it in your kernel configuration using
menuconfig. - Mount debugfs if it’s not mounted by default.

