Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging with printk #3

Open
PranabNandy opened this issue Aug 30, 2023 · 0 comments
Open

Debugging with printk #3

PranabNandy opened this issue Aug 30, 2023 · 0 comments
Assignees
Labels
Concept It includes some Linux Kernel and rootfs concept Device Driver Development Character Device, Block Device and Network Device documentation Improvements or additions to documentation

Comments

@PranabNandy
Copy link
Owner

• 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

@PranabNandy PranabNandy added documentation Improvements or additions to documentation Concept It includes some Linux Kernel and rootfs concept Device Driver Development Character Device, Block Device and Network Device labels Aug 30, 2023
@PranabNandy PranabNandy self-assigned this Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Concept It includes some Linux Kernel and rootfs concept Device Driver Development Character Device, Block Device and Network Device documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant