Enabling pr_debug to analyze device-tree/driver binding

Hello,

I would like to investigate why my i2c driver is not probed although my decompiled device-tree looks okay.

I will start to analyze driver_probe_device in kernel-5.10/drivers/base/dd.c. The kernel utilizes pr_debug prints, but it is not printed out to the console. I enabled three things:
1- CONFIG_DYNAMIC_DEBUG=y in defconfig.
2- Edit the mminit_loglevel=4 to 8 in my extlinux.conf file.
3- -DDEBUG option in make command.

The first and second one didn`t affect anything during boot. The -DDEBUG option caused the following issue although it exists:
kernel/fork.c:98:10: fatal error: linux/tegra_profiler.h: No such file or directory

Is there any hint of how I can analyze it better and enable pr_debug?

Thanks!

Hi fat,

Are you using the devkit or custom board for AGX Orin?
What’s your Jetpack version in use?

Do you connect any I2C device on your board?
Please share the full dmesg for further check.

Is there tegra_profiler.h in your source?

Have you just tried using pr_err or pr_warn to print debug messages?

Hi @KevinFFF,

Thank you for your prompt response.

Are you using the devkit or custom board for AGX Orin?
What’s your Jetpack version in use?

I am using devkit for ORIN AGX with Jetson Linux 35.3.1 and JetPack 5.1.1.

Do you connect any I2C device on your board?

Yes. I have an I2C device with 0x27 address connected to MIPI Camera Board. I can detect already the device with the following command in user space:
i2cdetect -y -r 2.

Is there tegra_profiler.h in your source?

Yes it is in the original position:
Jetson_Linux_R35.3.1\Linux_for_Tegra\sources\kernel\nvidia\include\linux\tegra_profiler.h
But when I added -DDEBUG to may make command it gives error. Otherwise no issue.
This is how I added DEBUG flag:
O_OPT+=(EXTRA_CFLAGS="-DDEBUG")

Have you just tried using pr_err or pr_warn to print debug messages?

They work. I replaced pr_debug with pr_crit to see the outputs in kernel-5.10/drivers/base/dd.c. Please see the attached log.

Besides, I am adding related part of my dummy final device-tree decompiled below. I added my mydevice to i2c@3180000 which is i2c2.

i2c@3180000 {
	#address-cells = <0x1>;
	#size-cells = <0x0>;
	iommus = <0x2 0x4>;
	dma-coherent;
	compatible = "nvidia,tegra234-i2c";
	reg = <0x0 0x3180000 0x0 0x100>;
	...

	tca6408@21 {
		...
	};

	ov5693_c@36 {
		...
	};

	mydevice@0x27 {
		#address-cells = <0x1>;
		#size-cells = <0x0>;
		compatible = "mybrand,mytestdevice";
		reg = <0x27>;
		phandle = <0x38b>;
	};
};

Here is the associated device driver:

static int mydevice_probe(struct i2c_client *client)
{
	struct device *dev = &client->dev;
	struct mydevice_priv *priv;
	int ret;

	printk(KERN_INFO "mydevice_probe: %i\n", __LINE__);
	
	...
}

static const struct of_device_id mydevice_of_table[] = {
	{ .compatible = "mybrand,mytestdevice" },
	{ },
};
MODULE_DEVICE_TABLE(of, mydevice_of_table);

static struct i2c_driver mydevice_i2c_driver = {
	.driver	= {
		.name = "mydevice",
		.of_match_table	= of_match_ptr(mydevice_of_table),
	},
	.probe_new = mydevice_probe,
	.remove = mydevice_remove,
};

module_i2c_driver(mydevice_i2c_driver);

Please find attached the kernel log.
kernel_output.txt (134.4 KB)

Thanks in advance.

It seems you are porting the MIPI Camera for AGX Orin.
Have you requested the porting guide and related driver from your vendor?

I don’t see your debug messages in the kernel_output.txt you shared.
Have you checked if your driver is probed correctly?

My drivers are ready and validated on ORIN NANO. The device tree and drivers successfully working with ORIN Nano. I am actually trying to adapt the existing device-tree to ORIN AGX.

The original issue here is my driver is not getting probed. This is what I am currently investigating.

In ORIN Nano there was i2c-mux. But it seems like there is no i2c-mux in ORIN AGX. Therefore I placed my device directly into the i2c@3180000 assuming this is the i2c bus that exists on the MIPI Camera Connector.

Any debugging tips would be appreciated.

Thanks in advance.

Which I2C interface are you using to connect the MIPI camera?
Is the following one?

Please share both of your device tree for Orin Nano(working) and Orin AGX(not work now).

Hi Kevin,

It is correct. Here is the schematic that validates this.

Here is the screenshot of i2cdetect that shows my device @27 is available in i2cdetect with id #2.

Hope the this is something expected.

Hi Kevin,

I isolated the problem from Nano. Now, I can not get my dummy i2c_driver probed in AGX Orin. I have i2c slave exist in address 0x27.

Please find the logs (with initcall_debug and ignore_loglevel kernel params) and device tree attached regarding mydevice driver.
mydevice.txt (1.7 KB)
kernel_output2.log (134.6 KB)
tegra234-p3701-0000-p3737-0000-mydevice.dtb.log (559.1 KB)

Thanks in advance.

[   43.419923] i2c i2c-2: Failed to register i2c client mydevice at 0x27 (-16)
[   43.427964] i2c i2c-2: of_i2c: Failure registering /i2c@3180000/mydevice@27
[   43.435974] i2c i2c-2: Failed to create I2C device for /i2c@3180000/mydevice@27

From your dmesg, it seem your device can’t be registered successfully.
The current results seems worse than before.

What do you mean here?

Could you share the dmesg with your driver working on Orin Nano?

[ 43.419923] i2c i2c-2: Failed to register i2c client mydevice at 0x27 (-16)

As you pointed out kernel gives errno (-16) which is Device or resource busy. Although there is no other driver on that bus for i2c address 0x27, I can`t understand why it gives such an error.

I isolated the problem from Nano.
What do you mean here?

I mean I created a ballpark/dummy scenario to trigger probe with mydevice driver on ORIN AGX. The problem is not related to the device tree and driver implemented for ORIN NANO anymore. I believe once we identify the reason for the errno (-16) we will resolve the issue.

What would be your recommendation?
Thanks in advance.

Do you mean the probe process for Orin Nano and Orin AGX are different?

Do you load the driver manually?
It seems the log shared from you is not complete from boot up. (it is starting from second 41.x)
Could you share the full dmesg for further check?
(maybe it has been probed at boot up!?)

Hi Kevin,

Thank you for your help.

I don`t mean the probe process for Orin Nano and Orin AGX are different. I just created a dummy i2c driver and I am currently investigating why it is not getting probed with ORIN AGX although the i2c-hardware @0x27 is connected.

Please see the full kernel output attached collected through the serial console.

I see that it is being initialized:

[ 29.568097] calling mydevice_init+0x0/0x3c @ 1
[ 29.573642] mydevice_init: 55
[ 29.577587] initcall mydevice_init+0x0/0x3c returned 0 after 3852 usecs

But I also see that it is gets failed somehow:

[ 43.375200] bus: ‘platform’: really_probe: probing driver tegra-i2c with device 3180000.c
[ 43.388829] i2c i2c-2: Failed to register i2c client mydevice at 0x27 (-16)
[ 43.396869] i2c i2c-2: of_i2c: Failure registering /i2c@3180000/mydevice@27
[ 43.404887] i2c i2c-2: Failed to create I2C device for /i2c@3180000/mydevice@27
[ 43.413274] driver: ‘tegra-i2c’: driver_bound: bound to device ‘3180000.i2c’

kernel_output3.log (378.3 KB)

Thanks in advance.

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

Could you just verify the exact the same as you’ve done and probed successfully on the Orin Nano for your Orin AGX?

Please share sudo dmesg instead of serial console to get complete messages.
It seems it has been init in sec 29.

Could you also share the dmesg from Orin Nano for comparison?