Adding TX2 dev board camera to device tree

I am trying to get the tx2 dev board camera to work. I have looked in this forum on how to do this and looked in the nvidia linux jetson developer guide but the guide is pretty confusing for someone without a deep linux background. I have the TX2 connected to an elroy board and I connected the ov5693 dev kit camera directly to the elroy.
Here’s what I did:
Running gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! xvimagesink

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:557 No cameras available
Got EOS from element "pipeline0".
Execution ended after 0:00:00.145354857
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
(Argus) Error EndOfFile: Unexpected error in reading socket (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 266)
(Argus) Error EndOfFile: Receive worker failure, notifying 1 waiting threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 340)
(Argus) Error InvalidState: Argus client is exiting with 1 outstanding client threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 357)
(Argus) Error EndOfFile: Receiving thread terminated with error (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadWrapper(), line 368)
(Argus) Error EndOfFile: Client thread received an error from socket (in src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 145)
(Argus) Error EndOfFile:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 87)

I checked for the driver using dmesg | grep ov5693 and I got nothing.

Then I installed the linux sources from:
https://developer.nvidia.com/embedded/L4T/r32_Release_v4.4/r32_Release_v4.4-GMC3/Sources/T186/public_sources.tbz2

tar -xjf public_sources.tbz2
cd Linux_for_Tegra/source/public
tar –xjf kernel_src.tbz2
sudo apt install build-essential bc
TEGRA_KERNEL_OUT=/home/me/kernel_out

Then I create the .config file:

cd <kernel_source>
where kernel_source is ~/Downloads/Linux_for_Tegra/source/public/kernel_src/kernel/kernel-4.9

mkdir -p $TEGRA_KERNEL_OUT
make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig

then I don’t wanna build the whole kernel. I just wanna build the driver as an external module. I go to:
/kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig

and I look for CONFIG_VIDEO_OV5693=m and it is there with a bunch of other configs. So I change nothing and close the file. I probably didn’t need this step anyway.

Then:
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j2 modules_prepare

Now I go to where the driver file for the sensor is located at:
~/Downloads/Linux_for_Tegra/source/public/kernel_src/kernel/nvidia/drivers/media/i2c/ov5693.c

and I execute:
make ARCH=arm64 –C $TEGRA_KERNEL_OUT M=$(pwd)

and I get:
make: *** No rule to make target '–C'. Stop.

This is the makefile in the same directory:

subdir-ccflags-y += -Werror

ccflags-y += -I$(srctree)/drivers/media/platform/tegra
ccflags-y += -I$(srctree)/drivers/video/tegra/camera

obj-$(CONFIG_VIDEO_IMX185) += imx185.o
obj-$(CONFIG_VIDEO_IMX185) += imx185_v1.o
obj-$(CONFIG_VIDEO_IMX477) += imx477.o
obj-$(CONFIG_VIDEO_IMX219) += imx219.o
obj-$(CONFIG_VIDEO_IMX268) += imx268.o
obj-$(CONFIG_VIDEO_IMX274) += imx274.o
obj-$(CONFIG_VIDEO_IMX318) += imx318.o
obj-$(CONFIG_VIDEO_LC898212) += lc898212.o
obj-$(CONFIG_VIDEO_OV5693) += ov5693.o
obj-$(CONFIG_VIDEO_OV9281) += ov9281.o
obj-$(CONFIG_VIDEO_OV10823) += ov10823.o
obj-$(CONFIG_VIDEO_OV23850) += ov23850.o
obj-$(CONFIG_I2C_IOEXPANDER_PCA9570) += pca9570.o
obj-$(CONFIG_VIDEO_TC358840) += tc358840.o
obj-$(CONFIG_I2C_IOEXPANDER_SER_MAX9295) += max9295.o
obj-$(CONFIG_I2C_IOEXPANDER_DESER_MAX9296) += max9296.o
obj-$(CONFIG_VIDEO_IMX390) += imx390.o

so I try the Kbuildmethod from https://stackoverflow.com/a/65979628

I created a file named Kbuild in the same directory as ov5693.c with the following line:
obj-m += ov5693.o

then:
sudo make -C /lib/modules/(uname -r)/build M=(pwd)

I used sudo because I got permission denied somewhere.

Anyway it builds a bunch of files in that directory: here’s the output of ls:
built-in.o imx390.c ov23850.c
imx185.c imx390_mode_tbls.h ov23850_mode_tbls.h
imx185_mode_tbls.h imx477.c ov5693.c
imx185_v1.c imx477_mode_tbls.h ov5693.ko
imx185_v1_mode_tbls.h Kbuild ov5693.mod.c
imx214.c Kconfig ov5693_mode_tbls.h
imx219.c lc898212.c ov5693.mod.o
imx219_mode_tbls.h Makefile ov5693.o
imx268.c max9295.c ov9281.c
imx268_mode_tbls.h max9296.c ov9281_mode_tbls.h
imx274.c modules.order pca9570.c
imx274_mode_tbls.h Module.symvers tc358840.c
imx318.c ov10823.c tc358840_regs.h
imx318_mode_tbls.h ov10823_mode_tbls.h

so I get the ov5693.ko file.

then in the same directory I execute:
sudo insmod ov5693.ko

then dmesg | grep ov5693 returns nothing.
I run the command again and I get:
insmod: ERROR: could not insert module ov5693.ko: File exists

then I tried:
gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! xvimagesink

and I got the same error message from above.
Please help :(

Thanks

Check this to remove the plugin manager to using e3326 sensor board.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/camera_sensor_prog.html#wwpID0E0XF0HA

I found top>/hardware/nvidia/platform/t19x/galen/kernel-dts/tegra194-p2888-0001-p2822-0000.dts instead of dtsi. I edited it and here’s how it looks like now:

#include "common/tegra194-p2888-0001-p2822-0000-common.dtsi"
#include "common/tegra194-camera-e3326-a00.dtsi"

I placed tegra194-camera-e3326-a00.dtsi in the common folder.

Then I reboot, then sudo insmod ov5694.ko and when I look at dmesg | grep ov5693 I see [ 111.852354] ov5693: loading out-of-tree module taints kernel.

Then I run
gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! xvimagesink

but still get the same error

Confirm the dts from below command as expect.

sudo dtc -I fs -O dts -o extracted_proc.dts /proc/device-tree

I looked in the exctracted_proc file and I did not see any ov5693. Do I still need to add it to the device tree even though I’m loading the driver as an external module? If so, how do I do that?

Try to decompile the dtb file build from your system to confirm it.

okay I went to /boot and found tegra194-p2888-0001-p2822-0000.dtb and then inside /boot I run this command:
dtc -I dtb -O dts -f tegra194-p2888-0001-p2822-0000.dtb -o tegra194-p2888-0001-p2822-0000.dts

Then I inspected the file and found many occurrences of ov5693 all of which have status=“disabled” so I changed the first one under i2c@3180000 like that:

ov5693_c@36 {
			compatible = "nvidia,ov5693";
			reg = <0x36>;
			devnode = "video0";
			physical_w = "3.674";
			physical_h = "2.738";
			avdd-reg = "vana";
			iovdd-reg = "vif";
			vertical-flip = "true";
			clocks = <0x4 0x24 0x4 0x66>;
			clock-names = "extperiph1", "pllp_grtba";
			mclk = "extperiph1";
			clock-frequency = <0x16e3600>;
			reset-gpios = <0x13 0x3b 0x0>;
			pwdn-gpios = <0x13 0x3e 0x0>;
			vana-supply = <0x2c>;
			vif-supply = <0x2d>;
			status = "okay";
			linux,phandle = <0x104>;
			phandle = <0x104>;

I set the status to okay, saved the dts file, and recompiled using:
dtc -I dts -O dtb -f tegra194-p2888-0001-p2822-0000.dts -o tegra194-p2888-0001-p2822-0000.dtb

reboot, and then tried to insert the module again and run gstreamer but I’m still getting the same issue :(

Is there another thing I need to edit inside the dts file?

Did you modify the /boot/extlinux/extlinux.conf to add below to apply the dtb?

FDT /boot/tegra194-p2888-0001-p2822-0000.dtb

I just added FDT /boot/tegra194-p2888-0001-p2822-0000.dtb to the extlinux.conf and now I can’t boot. It is just stuck at the nvidia logo…

That could be your dtb have problem. Try if can login by ssh to replace the dtb by original one or reflash the image.