Porting media i2c sensors from JP 5.1.3 to JP 6.1 DT

Hi,
We have camera sensors drivers in JP 5.1.3
Now we want to move into JP 6.1
from the conf file the final dtb is:
tegra234-p3768-0000+p3767-0000-nv
problem is it doesn’t contain any cameras related nodes nor cam_i2cmux with i2c devices.

in JP 5.1.3 we modified the
tegra-camera-platform
cam_i2cmux
nvcsi@15a00000
tegra-capture-vi
nodes manually and then built the main dtb again.

How can we do that in JP 6.1?

Thanks

Hi @bsp_dev

I think you can take a look at this driver patch NVIDIA-Jetson-IMX708-RPIV3/patches_orin_nano/patches/6.0_orin_nano_imx708_v0.1.0.patch at main · RidgeRun/NVIDIA-Jetson-IMX708-RPIV3 · GitHub made by RidgeRun for the Orin Nano board. If you have any questions regarding the driver please contact us at support@ridgerun.com.

Regards!
Eduardo Salazar
Embedded SW Engineer at RidgeRun

Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com

1 Like

Thank you for your reply.
Let me rephrase my question:

I noticed that in JP6+ there is use of dt overlays instead of .dtsi in hardware/platform dir like in JP5+
I have several questions regarding this matter:

  1. After all the relevant .dtbo are built, where its defined which .dtbo is being loaded into the target’s final DT and which are not (being built but not included in the final target’s dt)?
  2. How can I build and examine the final dt (including all .dtbo) source on the host before moving the blobs into the target? I wish to verify its valid and contains my changes
  3. We use the Orin NX on a custom carrier board. Are there any .dts/.dtsi and any overlays that we can completely remove from the makefiles in source/hardware/nv/Makefile and source/hardware/nv/overlay/Makefile? We don’t want to built unnecessary .dtbos/dt nodes but don’t want to “break” something while removing them.

Thanks

  1. Enable the overlays by jetson-io or modify /boot/extlinux/extlinux.conf.
  2. Check this doc for customized kernel dtb Kernel — NVIDIA Jetson Linux Developer Guide 1 documentation
  3. For the sensor part suppose yes.

Can I just “hard coded” modify the dt like we did in jp5.1.3 instead of workinf with overlays?

I tried to do that like described here:
https://docs.nvidia.com/jetson/archives/r36.4/DeveloperGuide/SD/CameraDevelopment/SensorSoftwareDriverProgramming.html#using-the-main-platform-device-tree-file

but I still get the original “out of the box” default dt.

I modified the dt sources (and overlays sources), built the dtbs, got the message:

================================================================================
DTBs compiled successfully.

and then copied the built .dtbos into /boot and the kernel di into /boot/dtb in the target.

Suppose there’s no problem include your dts in main tree to build in the dtb.
For this you need to compile the whole dtb instead of dtbos to replace it.

I apologise,
I didn’t understand your answer.

For example , I have a camera sensors modules that came from a.dtbo and not from main.dtb
I try to modify the a.dts and build a new a.dtbo

I load it into the target’s /boot and the main dtb into /boot/dtb and I still see the camera sensors settings that came from a.dtbo. For some reason it ignores the .dtbo changes and it interferes with the main .dtb

Suppose document include your dtbo to main dtb and apply it to the system instead of using overlays.

  1. I added a new dt node in
    tegra234-p3768-0000+p3767-0000-nv.dts on my host.
  2. I built the DTBs.
  3. I can see this node on the target kernel_tegra234-p3768-0000+p3767-0000-nv.dtb
  4. The problem is that tegra234-p3768-0000+p3767-0000-dynamic.dtbo contains the same node and override my values.

I edited the tegra234-p3768-0000+p3767-0000-dynamic.dts on my host as well and built it but for some reason the target ignores my modifications and load the default version of tegra234-p3768-0000+p3767-0000-dynamic.dtbo

I need to “disable” the .dtbo somehow because its masking the kernel dtb nodes

Check the flash conf file to remove below context to try.

OVERLAY_DTB_FILE+="tegra234-p3768-0000+p3767-0000-dynamic.dtbo"

If I remove it, I need to flash again?

Yes, need to reflash whole system again.

Thanks

Hi @ShaneCCC ,

I’ve commented out the OVERLAY_DTB_FILE from the conf file on the host prior to flashing. Now I can see my modifications on the target dt. The problem is that I still can’t modify the kernel dt source on my host, build and transfer it to the target /boot/dtb path and see the changes. I have to flash the target in order for the changes to take effect.

You can use dtc to un-compile the dtb that build on your host to confirm the modification first.

Yes of course. I did it on both my host and the target /boot/dtb kernel dtb. both contain the changes, but even after target reset the dt generated from /proc/device-tree is different. Only after flashing its the same

How do you apply your dtb?
Did you modify the FDT in /boot/extlinux/extlinux.conf to point to your dtb?

Hi @ShaneCCC ,
I didn’t have an FDT entry in my extlinux.conf.
I added it and now it works.

Next thing I tried is to build my driver from JP5.1.3 for JP6.1
I did the followings:

  1. copy my driver sources into
    /nvidia-oot/drivers/media/i2c
  2. use the following makefile (replace the one inside /media/i2c):

#SPDX-License-Identifier: GPL-2.0-only
#Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
subdir-ccflags-y += -Werror

obj-m += my_driver.o

  1. build the driver with the makefile

cd $L4T_KERNEL_PATH
make ARCH=arm64 defconfig scripts
cd $L4T_OOT_MEDIA_I2C_DRIVER_SRC_PATH
make ARCH=arm64 -C $L4T_KERNEL_PATH M=$(pwd)

First I get the error:

fatal error: media/tegra_v4l2_camera.h: No such file or directory
17 | include <media/tegra_v4l2_camera.h>

This is not hapening with JP5.1.3. If I manually add the include into the makefile:
ccflags-y += -I/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/include

and build I get the error:

make: Entering directory ‘/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/kernel/kernel-jammy-src’
CC [M] /home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/my_driver.o
MODPOST /home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/Module.symvers
ERROR: modpost: “tegracam_v4l2subdev_register” [/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/my_driver.ko] undefined!
ERROR: modpost: “tegracam_set_privdata” [/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/my_driver.ko] undefined!
ERROR: modpost: “tegracam_device_register” [/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/my_driver.ko] undefined!
ERROR: modpost: “tegracam_device_unregister” [/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/my_driver.ko] undefined!
ERROR: modpost: “tegracam_v4l2subdev_unregister” [/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/my_driver.ko] undefined!
ERROR: modpost: “sensor_common_parse_num_modes” [/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/my_driver.ko] undefined!
make[1]: *** [scripts/Makefile.modpost:133: /home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/Module.symvers] Error 1
make[1]: *** Deleting file ‘/home/bsp/Desktop/JP6_b/Linux_for_Tegra/source/nvidia-oot/drivers/media/i2c/Module.symvers’
make: *** [Makefile:1830: modules] Error 2

I build the same way on JP5.1.3 and there are no errors

I think you can use any of reference sensor driver like nv_ov5693/nv_imx219/nv_imx477 as template to modify yours.

You mean to just change their code?

I have another problem.
I added both FDT and OVERLAYS to extlinux.conf
The problem is that the dt nodes from the “main” overlay (the one mentioned in $L4T/conf_file)) is overriding the dt nodes from kernel dtb. They are merged into one dt on the target but with mixed values.

I made changes to the overlay, rebuilt it and moved it into the target /boot but the target still loads the default one.
In this case I can’t really modify the target dt the way I want with all the tegra-capture-vi , nvcsi and cam_i2cmux settings the wy i want.

I need to be able:
1.Edit both kernel dtb and “main” overlay.dtbo on my host, build them and use in the target without flashing
2. I don’t want to cancel the “main” overlay.dtbo entirely since I need its content in my system.

I use Orin NX with custom carrier board and JP6.1

Have a reference to this topic.