Enable logs in kernel driver

Hello,

I would like to work on customizing a screen driver. I have identified the driver file: /drivers/gpu/drm/panel/panel-sitronix-st7701.c. I want to enable logs in this file and view them.

I have tried many solutions found online, but none have been successful.

For example, I tried adding the linux/module.h and linux/kernel.h libraries to the panel-sitronix-st7701.c file, along with printk(KERN_INFO "some thing\n") logs in several places.
I enabled the following options:

  • CONFIG_PRINTK=y
  • CONFIG_DYNAMIC_DEBUG=y
  • CONFIG_DEBUG_KERNEL=y

I also enabled the logs using the following command:

echo "module panel-sitronix-st7701 +p" > /sys/kernel/debug/dynamic_debug/control  

However, I don’t see anything new in dmesg.

Could you please guide me on how to enable logs in the driver and view them?

Best regards,

Arthur

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.

Hello @aforey,

The recommendations from the @ToradexAI are good, but I would also recommend that you take a look at the following resources that should help you debug this issue:

As the log level for your messages is just KERN_INFO, it is possible that the messages are being hidden, so the printk documentation is especially relevant here.

Best Regards,
Bruno

Hello @aforey,

Could you send me your image so I can check if there was a misconfiguration that may lead to the driver not being loaded?

If possible, please upload it to share.toradex.com and send an email with the link to support.eu@toradex.com.

Best Regards,
Bruno