Published on

Developing OV5647 camera sensor Linux device driver for Jetson Nano [Part 1]

Authors

So having researched a bit on the Raspberry Pi v1 camera module hardware internals earlier, it was time for me to get started with writing the missing Linux kernel device driver for the OV5647 camera sensor. The first step in this was to write a skeleton driver that could register itself as an I2C slave device with the I2C controller of the Jetson Nano platform. To do that, I had to create a new set of Device Tree files specific to the OV5647 camera sensor hardware.

Having gone through the OV5647 datasheet and other resources on the internet, I figured out the right slave address for this camera sensor to enable both read and write access was 0x36. With this address value and other OV5647 sensor specific details that I could obtain from the datasheet, I was able to create correct Device tree (dts) file that could work with Nvidia's Linux4Tegra (L4T) kernel source tree.

With the device tree now in place, I managed to create the required skeleton driver that registered itself to the I2C bus driver and to Nvidia's Tegracam SW layer successfully with all the required callback functions in place.

With everything in place, I could build the driver as a Linux Kernel Module and load it dynamically on bootup. I could see that my driver's probe function got called after the driver matched with appropriate device tree entry.

So with these functions in place, I could now run readily available i2c tools present in the Linux distributions to interact with my camera sensor device.

The first thing I did was to run the i2cdetect tool that verified that a device was indeed registered at the I2C address 0x36 as shown in the screenshot below:

i2cdetect tool detecting OV5647 at I2C address 0x36

It works!

So now that we have our required skeleton driver with working I2C interface to talk to our OV5647 sensor, it is time to start initializing the OV5647 sensor and get it working. My current idea is to get the driver working with V4L2 interface first. To do so, I need to be able to get my device appear under /dev as a video interface (such as /dev/video0). This will be my next goal as I continue to develop this Linux driver for OV5647.