Enable logs in kernel driver

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello Arthur,

Thank you for reaching out with your question about enabling logs in your kernel driver. It sounds like you’re on the right track with using printk for logging. Here are some steps to help ensure your logging works as expected:

  1. Correct Use of printk:

    • Ensure your printk statements are correctly formatted, such as printk(KERN_INFO "Your message here\n");. The KERN_INFO level is suitable for informational messages.
  2. Dynamic Debug Configuration:

    • You’ve correctly enabled dynamic debug for your module. Make sure the command echo "module panel-sitronix-st7701 +p" > /sys/kernel/debug/dynamic_debug/control is executed after the module is loaded.
    • Verify that CONFIG_DYNAMIC_DEBUG=y is set in your kernel configuration.
  3. Kernel Boot Parameters:

    • Check that your kernel boot parameters do not suppress log levels. The loglevel parameter should be set to include KERN_INFO (e.g., loglevel=7).
  4. Review dmesg Settings:

    • Ensure dmesg is configured to display the log level you are using. You can adjust the dmesg log level with dmesg -n 7 to show all messages.
  5. Troubleshooting Tips:

    • If logs are still not visible, try using KERN_DEBUG instead of KERN_INFO for more verbosity.
    • Confirm that your changes to the driver file are compiled and loaded correctly. Adding a simple printk at the start of the driver’s initialization function can help verify that your changes are active.
    • Reboot the system after making changes to ensure all configurations are applied.

By following these steps, you should be able to see the logs from your driver in dmesg. If issues persist, double-check your kernel configuration and ensure the module is correctly loaded with the updated code.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

MCP3428 Kernel driver.