PranabNandy/BeagleBone-Black-Platform-Bring-Up

Debugging with printk

PranabNandy opened this issue · 0 comments

• When using printk , the message will go into the kernel ring buffer
simply we call “Kernel log,” and we can print and control the kernel
ring buffer using the command dmesg.
printk(KERN_WARNING “Hello this is kernel code running \n”);

• So if you want to check the latest 5 kernel messages, just run

dmesg | tail -5
dmesg | head -20

• The printk does not support floating-point formats (%e, %f, %g )

printk(KERN_ALERT “Hello this action should be taken immediately \n“);
printk(KERN_INFO “Hello this is jut for your information\n”);

• The kernel message log level will be compared with the current console log level. If the kernel message log level
is lower than the current console log level, then the message will be directly printed on the current console.

• By default console log level will have the value of config item: CONFIG_CONSOLE_LOGLEVEL_DEFAULT
Its default value is set to 7. You can change it via kernel menuconfig or running commands.

• To know the current log level status just run
cat /proc/sys/kerne/printk

current console log level kernel message log level Header Header
7 4 1 5

• At run time you can change the log level values using the below command
echo 6 > /proc/sys/kernel/printk