How do I write an external kernel module for a custom-made CSI-2 imaging device on TX2?

Hi all! I have been developing software on TX2 for 1 year. So far so good. Recently we custom-made an imaging device. Now we encounter difficulties on using it on TX2. Hope someone here can kindly give me some directions…

Our imaging device can be powered on or reset through GPIO, and controllable through I2C. It can output data through CSI-2. It is connected to the CSI-2 port of the Jetson TX2 Connect Tech Spacely carrier board. The CSI-2 port includes the GPIO, I2C and CSI-2 data output. The OS is L4T 28.2.1, installed by JetPack 3.2.1.

Now what we need are:

[b]

  1. Software function(s) to control the power and reset GPIO.
  2. Software function(s) to send an I2C command, which can be either read or write. The register addresses and values are not fixed yet so we don't want them to be hard-coded. We want to send the I2C commands one by one during run-time.
  3. Software function(s) to read data from CSI-2 port.

[/b]
After a few days of research for solution I find there is no easy way because the GPIO, I2C and CSI-2 are not exposed to the user space. It seems that I must write a kernel module. Please correct me if I am wrong.

I have gone through the official guide “NVIDIA Tegra Linux Driver Package Development Guide” → section “Sensor Driver Programming Guide”. It is not simple for me. The guide advised to write a driver and device tree config within the kernel source and re-build the whole kernel. It seems too complicated and risky. I would very much prefer writing an external kernel module and insert it to the kernel run-time (using “insmod” or “modprobe”). Is it possible? If there is any sample project or guideline please kindly let me know.

Thanks a lot!

[url]https://devtalk.nvidia.com/default/topic/1016796/jetson-tx2/porting-ar0135-ds90ub964-driver-to-jetson-tx2-chansel-fault-/2[/url]

please pay attention to the #20 .

The man says “It turns out that even if all the configs and drivers are correct, the system doesn’t mount video0 until the driver is compiled into the kernel itself.”

hello Wenling,

FYI,
you may refer to Preparing to Build External Kernel Modules chapter for customize external kernel modules.
thanks

Is there anyone successfully to “insmod” a sensor driver and can get the “video0”?

Were you able to use insmod?