Kernel debug logs

Hi,

Software summary

Bootloader: U-Boot
Kernel version: 5.15.177-6.8.2+git.5a6602cc6c32 #1-TorizonCore SMP PREEMPT Fri Mar 21 16:22:58 UTC 2025
Kernel command line: root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/c3a7ca8ff2232a05598c6b02529fba8f0dbacced78ea6fbf3ecb16d59a72a05e/0
Distro name: NAME=“TorizonCore”
Distro version: VERSION_ID=6.8.2-build.30
Distro variant: VARIANT=“Docker”
Hostname: verdin-imx8mp-1475XXXX

Hardware info

HW model: Toradex Verdin iMX8M Plus on Verdin Development Board
Toradex version: 0063 V1.1A
Serial number: 1475XXXX
Processor arch: aarch64

I was trying to see the dev_dbg kernel messages for a particular driver.c.
I followed these steps to see the dynamic debug messages but not it is not working. What else needs to be done in order to see the dev_dbg log statements in dmesg?

e.g I want to seedev_dbg(dev, "Rev. %d\n", val); from adv7511_drv.c of the toradex downstream branch for iMX8M.

Best regards,
Samarth Gour

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello Samarth,

Thanks for sharing your detailed setup. To see dev_dbg messages from a specific kernel driver like adv7511_drv.c on TorizonCore (v6.8.2, kernel 5.15.177), you need to use Linux’s dynamic debug feature as explained below:

1. Mount the debugfs (if not already mounted)

mount -t debugfs none /sys/kernel/debug/

This is required for accessing dynamic debug controls.
Reference

2. Enable debugging for adv7511_drv.c

Assuming your driver’s source file is named adv7511_drv.c, enable all dynamic debug messages for this file with:

echo "file adv7511_drv.c +p" > /sys/kernel/debug/dynamic_debug/control

This command activates “printk” debugging for every dev_dbg (and other pr_debug) call in the specified file.
Reference

3. Verify settings

Check if your settings have taken effect:

cat /sys/kernel/debug/dynamic_debug/control | grep adv7511

You should see lines ending with =p, indicating printing is enabled.
Reference

4. Check dmesg or log buffer

Once enabled, any code paths in adv7511_drv.c that use dev_dbg should print to dmesg or your system log buffer. If your system uses journald (common on Torizon OS), you may also see the messages via:

dmesg
# or
journalctl -k

5. Confirm Kernel Configuration

For this to work, your kernel should have:

  • CONFIG_DEBUG_FS=y
  • CONFIG_DYNAMIC_DEBUG=y

These are typically enabled in Toradex default kernel builds, but you can confirm:

zcat /proc/config.gz | grep DEBUG_FS
zcat /proc/config.gz | grep DYNAMIC_DEBUG

Both should be set to “y” (for yes/enabled). If not, dynamic debug won’t work.

6. Enable for a Specific Function (optional)

If you want debug prints for just one function, use:

echo "func <function_name> +p" > /sys/kernel/debug/dynamic_debug/control

Replace <function_name> with the actual function name from adv7511_drv.c.
Reference

7. Fallback: Static Debug

If the above doesn’t yield output, you can add:

#define DEBUG

as the very first line in adv7511_drv.c (before any #includes) and then rebuild the kernel module/driver. This will make all dev_dbg become active unconditionally on that file.
Reference


Let me know if you have any issue at any step, or do not see the expected messages after these procedures.

Best regards,
Toradex AI Assistant.

Reference: How to Enable dev_dbg Kernel Messages

Hi @s.gour!

The answer given by the AI seems to be correct. Could you please test it and see if it solves your issue?

Best regards.

Hi @lucas_az.tx ,

I’ve already tried that, it’s not working for me.

Regards,
Samarth Gour

Weird, the AI’s instructions look accurate to me. Maybe the debug entries are not present in the kernel (maybe you’re looking at a different version of the source)? Did you find the entries you were looking for in the sysfs file (step 3 above)? Maybe you’re not seeing the debug output because the code in question is not actually being used?

For completeness, I’ll put my own notes about dyndbg (as the kernel calls it) below, which have been working with imx8mp platform with TorizonCore 6.

https://www.kernel.org/doc/html/v4.11/admin-guide/dynamic-debug-howto.html

The kernel contains (if enabled - Toradex kernels have it) dynamic debug information. In the code, calls to dev_dbg() are silent by default, but can be enabled at runtime:
Runtime:

$ echo 'file svcsock.c line 1603 +p' | sudo tee /sys/kernel/debug/dynamic_debug/control
$ echo 'file svcsock.c +p' | sudo tee /sys/kernel/debug/dynamic_debug/control
$ sudo cat /sys/kernel/debug/dynamic_debug/control
$ sudo cat /sys/kernel/debug/dynamic_debug/control | grep =p

At boot on the kernel commandline:

dyndbg="file svcsock.c line 1603 +p"
dyndbg="file svcsock.c +p; imx219.c +p"

The above only works for builtin kernel code. For loaded modules, prefix the module name, e.g.:

      imx8_media_dev.dyndbg=+p

(or pass options to modprobe, or put them in /etc/modprobe.d)

For a custom torizon image, add this to tcbuild.yaml:

customization:
  kernel:
    arguments:
      - 'dyndbg=\\\"file i2c-dev.c +p; file mc-entity.c +p\\\"'
      - 'imx8_media_dev.dyndbg=+p'

Selecting output can also be done based on module and function.

Output shows up in dmesg output.