A report on kernel and dtb customization for IMX219 camera

With the latest r32.4.3 release, we found our previous version of DTB and kernel for imx219 sensor based Raspberry Pi cameras no longer working. After a few good days of scrambling, we finally got our tx2 kit + camera boar to function with imx219.

Our camera carrier board is designed to support both imx219 and ov5647 RPi cameras, up to 6 cameras simultaneously. Overall, we follow the approach of unregistering the plugin manager, and adding the new imx219 device to the main device tree dtsi file.

The main change in the DTS code is instead of csi-port, the dtsi now use port-index.

Another thing we bumped into is the errors cause by LC898212 after we unregistered the plugin manager. By try-and-error, we found that removing the reference to LC898212 in the Makefile is the most effective way to handle the problem. No need to remove the related dts files, just comment out the line
#dtb-$(CONFIG_ARCH_TEGRA_18x_SOC) += tegra186-quill-p3310-1000-a00-00-lc898212.dtb in Makefile.

The next task is the kernel driver for imx219. Actually it turns out we may pretty much reuse the official imx219.c with some minor touch up. The biggest challenge is to find how to compile it. Or in a simple question, where to put imx219.c and where to find the related headers.

By default, imx219.c is in tx2_32.4_3/kernel/nvidia/drivers/media/i2c.

However, that’s not where the make would see when building the kernel. If we follow the official guideline, the compilation should be performed under kernel/kernel-4.9/, not kernel/nvidia.

While doing the study, we found that the kernel and dtb can be compile using the script nvbuild.sh, which is under the extracted source top directory.

nvbuild.sh would take the imx219.c under kernel/nvidia/drivers/media/i2c

Since nvbuild.sh is not described in the official NVIDIA Jetson Linux Developer Guide, we didn’t do a thorough verification on the process. But we can say that it works.

The second method is to closely follow the steps as described in the Guide. However, you have to copy the imx219.c and related headers from various places. Make sure they are all placed in corresponding directories under kernel/kernel-4.9/include and kernel/kernel-4.9/drivers.

With the steps above, we can pretty much reuse the scripts we had before to build the kernel and dtb.

Recap the three main issues resolved:

  1. csi-port vs port-index
  2. LC898212 removal
  3. Placement of imx219.c and headers.

Afterward, flash the Image and dtb using a terminal command:
sudo ./flash.sh jetson-tx2-devkit mmcblk0p1

BTW, we couldn’t figure out how to use SDKM to flash the customized kernel and dtb. Until a solution is present, I’d say don’t use SDKM to flash it for that purpose.

We continued the setup on tx2 after flash., including the connetion to the network gateway. Enter “ifconfig” to get the network IP address of tx2.

Now we can use SDK Manager to install the Jetson Components.
Use the ip address, go back to the host PC and run SDK Manager STEP03 (tune off the Jetson OS, turn on the Jetson SDK COmponents).

That should give you a working TX2 with customized IMX219 kernel and device tree.

  1. The change to port-index is the code migrate, I think the programing guide should have it. I think when you migrate to a new version it’s better reference to the reference dts as template to reporting the driver again.

  2. Thanks for your finding. Due to internal test we can’t comment it out by default. But we may share this information somewhere like elinux.org wiki page.

  3. The default release kernel source code already have this file? And the document tell the directory of reference driver like imx185.


Hi, thanks for sharing your findings they are very helpful for the community.

I just wanted to ask where exactly is the nvbuild.sh file since I can’t find it anyware in the top directory. Is there something I am missing? Otherwise it would be quite troublesome to copy each needed header and driver to customize the kernel.


There might be more than one place nvbuild.sh is available, but if you go to the URL for your particular release (see “head -n 1 /etc/nv_tegra_release” to find a Jetson’s currently installed L4T version), then there is a source download URL, and this is part of one of the sub packages. A listing of L4T releases:

If for example you are using R32.4.4, then go there and look for:
SOURCES->L4T Driver Package (BSP) Sources
(for your particular hardware)

This would unpack many other packages, and the package “kernel_src.tbz2” would have the kernel source, including both in-tree and out-of-tree, plus the nvbuild.sh script.

1 Like