Where is the driver source of Raspberry Pi Camera V2 on Jetson Nano

Hello,
currently i am studying csi camera.

I bought Raspberry Pi Camera V2(imx219) and using the default sd image :nv-jetson-nano-sd-card-image-r32.3.1

I can preview the camera. thanks for nvia’s good effort.

I want study the driver. But i find no .ko when i lsmod ,no relative .ko i think

terry@terry-desktop:~/jetsonnano/buildKernelAndModules$ lsmod
Module Size Used by
bnep 16562 2
fuse 103841 2
zram 26166 4
overlay 48691 0
spidev 13282 0
nvgpu 1575721 37
bluedroid_pm 13912 0
ip_tables 19441 0
x_tables 28951 1 ip_tables

i can see /dev/video0 and i can open it via gst-launch-1.0
I guess it is builded in the kernel.

Do annyone know where the source code is?

My first step is studing the driver, and try to to make Raspberry Pi Camera work according the dirver.

long time ago, i maintain commany usb camera driver.But it is 10 years ago…
Now i try to keep up the lost 10 decade @@…

Thanks in advance.

Terry

It’s build in module you can download the source by below doc. And can check the sensor programing guide in next chapter.

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

1 Like

Hello ShaneCCC,

A.

It’s build in module

Can you tell me which one? as i said, i can only see 9 mod in jetson nano.
i can build kernel now. so i just want to know where the rpi camera driver is.

B.

you can download the source by below doc

Currently i use the way in GitHub - JetsonHacksNano/buildKernelAndModules: Build the Linux Kernel and Modules on board the NVIDIA Jetson Nano Developer Kit
build it on board and it works for me.

And Thanks for your link. thanks.
I tried this link few days ago in NVidia’s guild. but I got confusing when I do the steps.

To sync the kernel sources
•Get the kernel source by running the source_sync.sh script:
$ ./source_sync.sh i do not know where i can find it.

And I tried again today, with your suggestion, download the source from Jetson Linux R32.6.1 Release Page | NVIDIA Developer
I download the L4T Driver Package (BSP) Sources .
I found source_sync.sh there!. I will tried later.

Thank in advance

Terry

Build in module means build in Image can’t see it by lsmod

Dear all,
I guess i found the entry.
kernel/nvidia/drivers/media/platform/tegra/camera/tegracam_core.c

i change the
int tegracam_device_register(struct tegracam_device *tc_dev)
{

dev_info(dev, “Terry:add tegracam sensor driver:%s_v%d.%d.%d\n”,
tc_dev->name, TEGRACAM_MAJOR_VERSION,
TEGRACAM_MINOR_VERSION, TEGRACAM_PATCH_VERSION);


}

after i rebuild the kernel. i found it changed in the dmesg

terry@terry-desktop:~$ dmesg | grep imx219
[ 1.205264] imx219 6-0010: Terry:add tegracam sensor driver:imx219_v2.0.6
[ 1.394481] vi 54080000.vi: subdev imx219 6-0010 bound

At least it is a good start!

FYI

Thanks

Terry

Just some added information you might find useful…

When booting there is an “integrated” (main) kernel image. Literally, the file name, when using a file, is usually “Image”. In fact, if you are building kernels from kernel source, and have configured correctly, then the command to build that image is:
make Image

Modules are also part of the kernel, but they can load or unload. There are a lot of drivers and features directly integrated with the Image file, and not in the form of external modules. lsmod is strictly for currently loaded dynamic modules, and not for the static integrated drivers. Both still exist, it is just a matter of knowing how to look for the feature.

When you compile or work on a kernel you will very likely be interested in starting with a configuration which matches your running system’s kernel. With one exception, if you were to copy “/proc/config.gz” somewhere and then gunzip it, then you could examine that plain text file and see the symbolic name of every single feature (or driver) which that kernel had configured at the time of its build.

The one part which is not an exact match is that you’d need to manually set up the “CONFIG_LOCALVERSION”. There is more than one way to do that. The reason why it is important is that it is related to where your base kernel Image file will look to find modules. If set wrong, then modules will not be found.

If you type the command “uname -r”, then you will see a base kernel version, and then a suffix which is what the CONFIG_LOCALVERSION was at the time of compile. Usually this would be a suffix of “-tegra”:
CONFIG_LOCALVERSION="-tegra"

If you know the symbol name for the driver you are working with, then you can verify if it is in integrated versus module format through that gunzip’d “/proc/config.gz`”. Note that integrated features cannot be unloaded the way a module can. Also, not all features can be in the format of a module (almost every non-invasive driver can be a module).

1 Like

Hello linuxdev,

Thanks for your advice,
i find the /proc/config.gz is the same as
/usr/src/kernel/kernel-4.9/.config

terry@terry-desktop:~/temp$ ls
terry@terry-desktop:~/temp$ cp /proc/config.gz
terry@terry-desktop:~/temp$ gunzip config.gz
terry@terry-desktop:~/temp$ ls -al /usr/src/kernel/kernel-4.9/.config
-rw-r–r-- 1 root root 165670 Sep 15 05:42 /usr/src/kernel/kernel-4.9/.config
terry@terry-desktop:~/temp$ ls -al config
-r–r–r-- 1 terry terry 165670 Sep 17 04:18 config
terry@terry-desktop:~/temp$ diff /usr/src/kernel/kernel-4.9/.config config
terry@terry-desktop:~/temp$

I will spend time on tracing the nvidia csi camera driver
which is in

/usr/src/kernel/nvidia/drivers/media/platform/tegra/camera/

for anyone who need it.

And thanks for Nvidia’s good effort!

i plain use trace-cmd/BPF/ftrace/ to do it.(The new stuff!)

10 years i only know printk and grep. haha. The old age tool.(Still Be useful today :p)

Currectly i spend time on Kaiwan N Billimoria’s book:
kernel internals, writing kernel modules, and kernel synchronization
i read the 10 chapters already. His book is good.

The 2 books also is on the list:

Kaiwan N Billimoria-Linux Kernel Programming Part 2 - Char Device Drivers and Kernel Synchronization: Create user-kernel interfaces, work with peripheral I/O, and handle
and
John Madieu - Mastering Linux Device Driver Development_ Write custom device drivers to support computer peripherals in Linux operating systems

10 years ago, i was company’s linux usb camera driver rd.
In fact, i just adust the open source of Laurent Pinchart’s uvc driver…
Thanks to him. He is a great Enginer.I learn a lot of usb and uvc from his drivers.
also the great book : Linux Device Drivers, Third Edition by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman.
Learn a lot from it.

I never have a chance to really understand kernel internals.
Recently my companny need mipi camera driver. I try to learn mipi sepc/linux mipi driver/kernel 5.x those days.

The kernel i knew is 2.6.xx. 10 years ago.I need to catch up what’s going on the decay :p.

And this time, i have time to do it(I wish :p). At the linux world, i saw many good RD. They codes is very good and clean. Sometimes mind-blowing xd.
I am just a guest to Linux world. But the Linux kernel engineer, I always admire their priceless work at kernel codes, which is free and open, and good for mankind.

Terry

1 Like

This is almost as it should be, but your new kernel Image will fail to find modules. You’d need this edit if you want to use existing modules:
CONFIG_LOCALVERSION="-tegra"
…if modules were found, then I assume that either this was set, or modules were also installed at their new location. I mention this because it is the most overlooked cause of failure among the average forum post on modules not being found. I have no doubt someone else will run into this, do everything else correctly, but still have a missing module unless they notice this subtle config item.