Difference between revisions of "OmniVision OV5647 Linux driver for Jetson TX2 (Auvidea J120)"

From RidgeRun Developer Connection
Jump to: navigation, search
m
m
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
<seo title="OmniVision OV5647 Driver | Linux driver for Jetson TX2 | RidgeRun" titlemode="replace" metakeywords="GStreamer, Linux SDK, Linux BSP,  Embedded Linux, Device Drivers, Nvidia, Xilinx, TI, NXP, Freescale, Embedded Linux driver development, Linux Software development, Embedded Linux SDK, Embedded Linux Application development, GStreamer Multimedia Framework, OV5647, OmniVision OV5647, OV5647 Linux driver, Jetson TX1 OV5647 driver, Jetson TX2 OV5647 Linux driver, OV5647 Linux driver for TX2, Auvidea J120, Auvidea J120 carrier board, J120 carrier board." metadescription="Read about the OmniVision OV5647 Linux driver for Jetson TX2 with Auvidea J120 carrier board and building the driver from RidgeRun."></seo>
 +
 
<table>
 
<table>
 
<tr>
 
<tr>
 
<td><div class="clear; float:right">__TOC__</div></td>
 
<td><div class="clear; float:right">__TOC__</div></td>
 
<td>
 
<td>
<html>
+
{{Shopping cart mpo for V4L2 camera drivers}}
<div id='product-component-997671fc296'></div>
+
<td>
    <script type="text/javascript">
+
{{NVIDIA Preferred Partner logo}}
    /*<![CDATA[*/
+
<td>
 
+
<td>
    (function () {
+
{{GStreamer debug}}
      var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
+
<td>
      if (window.ShopifyBuy) {
+
<center>
        if (window.ShopifyBuy.UI) {
+
{{ContactUs Button}}
          ShopifyBuyInit();
+
</center>
        } else {
+
</tr>
          loadScript();
+
</table>
        }
 
      } else {
 
        loadScript();
 
      }
 
 
 
      function loadScript() {
 
        var script = document.createElement('script');
 
        script.async = true;
 
        script.src = scriptURL;
 
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
 
        script.onload = ShopifyBuyInit;
 
      }
 
 
 
      function ShopifyBuyInit() {
 
        var client = ShopifyBuy.buildClient({
 
          domain: 'ridgerun1.myshopify.com',
 
          storefrontAccessToken: 'b0ca98633a82de5d2f63cd51f5af30ac',
 
        });
 
 
 
        ShopifyBuy.UI.onReady(client).then(function (ui) {
 
          ui.createComponent('product', {
 
            id: [1684647772231],
 
            node: document.getElementById('product-component-997671fc296'),
 
            moneyFormat: '%24%7B%7Bamount%7D%7D',
 
            options: {
 
  "product": {
 
    "variantId": "all",
 
    "width": "240px",
 
    "contents": {
 
      "imgWithCarousel": false,
 
      "variantTitle": false,
 
      "description": false,
 
      "buttonWithQuantity": false,
 
      "quantity": false
 
    },
 
    "text": {
 
      "button": "BUY NOW"
 
    },
 
    "styles": {
 
      "product": {
 
        "@media (min-width: 601px)": {
 
          "max-width": "100%",
 
          "margin-left": "0",
 
          "margin-bottom": "50px"
 
        }
 
      },
 
      "button": {
 
        "background-color": "#007493",
 
        "font-size": "18px",
 
        "padding-top": "17px",
 
        "padding-bottom": "17px",
 
        ":hover": {
 
          "background-color": "#006884"
 
        },
 
        ":focus": {
 
          "background-color": "#006884"
 
        }
 
      },
 
      "quantityInput": {
 
        "font-size": "18px",
 
        "padding-top": "17px",
 
        "padding-bottom": "17px"
 
      },
 
      "compareAt": {
 
        "font-size": "12px"
 
      }
 
    }
 
  },
 
  "cart": {
 
    "contents": {
 
      "button": true
 
    },
 
    "styles": {
 
      "button": {
 
        "background-color": "#007493",
 
        "font-size": "18px",
 
        "padding-top": "17px",
 
        "padding-bottom": "17px",
 
        ":hover": {
 
          "background-color": "#006884"
 
        },
 
        ":focus": {
 
          "background-color": "#006884"
 
        }
 
      },
 
      "footer": {
 
        "background-color": "#ffffff"
 
      }
 
    }
 
  },
 
  "modalProduct": {
 
    "contents": {
 
      "img": false,
 
      "imgWithCarousel": true,
 
      "variantTitle": false,
 
      "buttonWithQuantity": true,
 
      "button": false,
 
      "quantity": false
 
    },
 
    "styles": {
 
      "product": {
 
        "@media (min-width: 601px)": {
 
          "max-width": "100%",
 
          "margin-left": "0px",
 
          "margin-bottom": "0px"
 
        }
 
      },
 
      "button": {
 
        "background-color": "#007493",
 
        "font-size": "18px",
 
        "padding-top": "17px",
 
        "padding-bottom": "17px",
 
        ":hover": {
 
          "background-color": "#006884"
 
        },
 
        ":focus": {
 
          "background-color": "#006884"
 
        }
 
      },
 
      "quantityInput": {
 
        "font-size": "18px",
 
        "padding-top": "17px",
 
        "padding-bottom": "17px"
 
      }
 
    }
 
  },
 
  "toggle": {
 
    "styles": {
 
      "toggle": {
 
        "background-color": "#007493",
 
        ":hover": {
 
          "background-color": "#006884"
 
        },
 
        ":focus": {
 
          "background-color": "#006884"
 
        }
 
      },
 
      "count": {
 
        "font-size": "18px"
 
      }
 
    }
 
  },
 
  "productSet": {
 
    "styles": {
 
      "products": {
 
        "@media (min-width: 601px)": {
 
          "margin-left": "-20px"
 
        }
 
      }
 
    }
 
  }
 
}
 
          });
 
        });
 
      }
 
    })();
 
    /*]]>*/
 
    </script>
 
</html>
 
</td>
 
<td><center>
 
{{Debug Symbol}} Problems running the pipelines shown on this page?<br>Please see our [[GStreamer Debugging]] guide for help.
 
<br>
 
 
<br>
 
<br>
<div style='text-align: center;'>[[File:RR Contact Us.png|200px|link=http://www.ridgerun.com/contact]]</div>
 
</center></td></tr></table>
 
  
==OV5647 Features==
+
==Omnivision OV5647 image sensor features==
  
 
The Omnivision OV5647 is a CMOS image sensor with the following features:
 
The Omnivision OV5647 is a CMOS image sensor with the following features:
Line 204: Line 41:
  
 
== Driver OV5647 Features ==
 
== Driver OV5647 Features ==
Current version of the driver only supports the following transfer rates:
+
The current version of the driver only supports the following transfer rates:
 
* 1920x1080: 30 fps
 
* 1920x1080: 30 fps
 
* 1280x720: 30 fps
 
* 1280x720: 30 fps
Line 210: Line 47:
 
===Driver V4l2 controls===
 
===Driver V4l2 controls===
 
====Test pattern====
 
====Test pattern====
Configure test pattern.
+
Configure the test pattern.
  
 
Values:
 
Values:
Line 244: Line 81:
 
====Gain Control====
 
====Gain Control====
  
Configure red, green, blue value
+
Configure the red, green, blue value
  
 
Range 0 - 4095
 
Range 0 - 4095
Line 257: Line 94:
 
More can be added if required by the customer.
 
More can be added if required by the customer.
  
==Auvidea J120 Features==
+
==Auvidea J120 carrier board features==
 
The J120 carrier board turns the Jetson TX2 compute module into a super-mini-computer for desktop usage and for integration into UAVs and drones.
 
The J120 carrier board turns the Jetson TX2 compute module into a super-mini-computer for desktop usage and for integration into UAVs and drones.
  
 
*It is very compact.  
 
*It is very compact.  
 
*It has the same height as the TX1 (50 mm) and extends to one side to make space for standard connectors for Gigabit Ethernet, two USB 3 type A and mini HDMI.  
 
*It has the same height as the TX1 (50 mm) and extends to one side to make space for standard connectors for Gigabit Ethernet, two USB 3 type A and mini HDMI.  
*It features one M.2 type M slot for ultra fast SSDs (2280 form factor) which is connected via 4 PCIe lanes to achieve a read and write performance up to 2500 Mbyte/s.
+
*It features one M.2 type M slot for ultra-fast SSDs (2280 form factor) which is connected via 4 PCIe lanes to achieve a read and write performance up to 2500 Mbyte/s.
 
*One 4 lane CSI-2 (22 pin FPC 0.5mm pitch) – may connect to B102 module (up to 1080p60 input)
 
*One 4 lane CSI-2 (22 pin FPC 0.5mm pitch) – may connect to B102 module (up to 1080p60 input)
 
*Integrated 9 axis IMU (MPU-9250)
 
*Integrated 9 axis IMU (MPU-9250)
 
*10 pin connector for I2C and 2 channel SPI
 
*10 pin connector for I2C and 2 channel SPI
 
*I2S digital audio (6 pins)
 
*I2S digital audio (6 pins)
*6 pin connector for external reset, power, force recovery and sleep switches
+
*6 pin connector for external reset, power, force recovery, and sleep switches
*3 switches: reset, power and force recovery
+
*3 switches: reset, power, and force recovery
 
*JTAG pads (1.25mm pitch)
 
*JTAG pads (1.25mm pitch)
  
Line 279: Line 116:
 
==Enabling the driver==
 
==Enabling the driver==
  
Follow these instructions to build and install the kernel Image and device tree.
+
Follow these instructions to build and install the kernel image and device tree.
  
 
====1. Install  dependencies====
 
====1. Install  dependencies====
Line 293: Line 130:
 
NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain for L4T 32.1
 
NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain for L4T 32.1
  
Download the pre-built toolchain binaries from: [http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz]
+
Download the pre-built toolchain binaries from [http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz]
  
 
<source lang="bash">
 
<source lang="bash">
Line 319: Line 156:
 
====4. Apply driver patches====
 
====4. Apply driver patches====
  
Ridgerun provides the required patches (usually by email) to update the kernel source and add support for the ov5647 camera driver.
+
RidgeRun provides the required patches (usually by email) to update the kernel source and add support for the ov5647 camera driver.
 
Once the patches file was received, apply them by running the following commands:
 
Once the patches file was received, apply them by running the following commands:
  
Line 345: Line 182:
  
 
====6. Flash Jetson TX2 ====
 
====6. Flash Jetson TX2 ====
This guide assumes that the user already have JetPack 4.2 installed. This link contains details about how to install JetPack 4.2: https://docs.nvidia.com/sdk-manager/download-run-sdkm/index.html
+
This guide assumes that the user already has JetPack 4.2 installed. This link contains details about how to install JetPack 4.2: https://docs.nvidia.com/sdk-manager/download-run-sdkm/index.html
  
 
JETPACK_4_2 contains the directory where JetPack 4.2 was installed. For example.
 
JETPACK_4_2 contains the directory where JetPack 4.2 was installed. For example.
Line 366: Line 203:
 
</source>
 
</source>
  
==Using the driver==
+
==Using the driver ([https://www.ridgerun.com/gstreamer GStreamer] examples)==
  
 
*Capture at 1080p@30fps
 
*Capture at 1080p@30fps
Line 382: Line 219:
 
{{ContactUs}}
 
{{ContactUs}}
  
[[Category:Jetson]][[Category:Jetson V4L2 Drivers]]
+
[[Category:Jetson]][[Category:Jetson V4L2 Drivers]][[Category:OmniVision]]

Latest revision as of 14:20, 17 March 2023

Nvidia-preferred-partner-badge-rgb-for-screen.png

Error something wrong.jpg Problems running the pipelines shown on this page?
Please see our GStreamer Debugging guide for help.

RR Contact Us.png


Omnivision OV5647 image sensor features

The Omnivision OV5647 is a CMOS image sensor with the following features:

  • Automatic image control functions:
    • Automatic exposure control (AEC)
    • Automatic white balance (AWB)
    • Automatic band filter (ABF)
    • Automatic 50/60 Hz luminance detection
    • Automatic black level calibration (ABLC)
  • Image quality controls: lens correction, defective pixel canceling
  • CSI2 serial data output (MIPI interface 2 lanes)
  • Support for output formats: 8-/10-bit raw RGB data
  • Maximum image transfer rate:
    • QSXGA "Mpixel" (2592 x 1944): 15 fps
    • 1080p: 30 fps
    • 960p: 45 fps
    • 720p: 60 fps
    • VGA (640 x 480): 90 fps
    • QVGA (320 x 240): 120 fps

Driver OV5647 Features

The current version of the driver only supports the following transfer rates:

  • 1920x1080: 30 fps
  • 1280x720: 30 fps

Driver V4l2 controls

Test pattern

Configure the test pattern.

Values:

  • 0: Normal capture (Disable test pattern)
  • 1: Color bar type 1
  • 2: Color bar type 2
  • 3: Random data
  • 4: Square

Example:

v4l2-ctl --set-ctrl=test_pattern=1

Mode Control

Configure Total Vertical Size (VTS), Auto Gain Control (AGC), Auto Exposure Control (AEC).

Value

  • Bit 1: controls AEC, 0: Auto, 1: Manual
  • Bit 2: controls AGC, 0: Auto, 1: Manual
  • Bit 3: controls VTS, 0: Auto, 1: Manual

Example:

# VTS:Auto, AGC:Auto, AEC:Auto
v4l2-ctl --set-ctrl=mode_ctrl=0
# VTS:Auto, AGC:Manual, AEC:Auto
v4l2-ctl --set-ctrl=mode_ctrl=2
# VTS:Auto, AGC:Auto, AEC:Manual
ov5647_set_mode_ctrl: val: 1

Gain Control

Configure the red, green, blue value

Range 0 - 4095

Example:

v4l2-ctl --set-ctrl=gain_red=500
v4l2-ctl --set-ctrl=gain_green=1000
v4l2-ctl --set-ctrl=gain_blue=1500

More can be added if required by the customer.

Auvidea J120 carrier board features

The J120 carrier board turns the Jetson TX2 compute module into a super-mini-computer for desktop usage and for integration into UAVs and drones.

  • It is very compact.
  • It has the same height as the TX1 (50 mm) and extends to one side to make space for standard connectors for Gigabit Ethernet, two USB 3 type A and mini HDMI.
  • It features one M.2 type M slot for ultra-fast SSDs (2280 form factor) which is connected via 4 PCIe lanes to achieve a read and write performance up to 2500 Mbyte/s.
  • One 4 lane CSI-2 (22 pin FPC 0.5mm pitch) – may connect to B102 module (up to 1080p60 input)
  • Integrated 9 axis IMU (MPU-9250)
  • 10 pin connector for I2C and 2 channel SPI
  • I2S digital audio (6 pins)
  • 6 pin connector for external reset, power, force recovery, and sleep switches
  • 3 switches: reset, power, and force recovery
  • JTAG pads (1.25mm pitch)

Hardware requirements

As the J120 features a 4 lane CSI-2 (22 pin FPC 0.5mm pitch), a 22 to 15 pin adapter must be used to connect the ov5647 camera to the board. The CMCDA V1.1 adapter could be used, but it is important to note the difference between the display and camera versions of the adapter, as they have different pinouts. The required model is the camera version (left one on the following image).

CMCDA v1.1.jpg

Enabling the driver

Follow these instructions to build and install the kernel image and device tree.

1. Install dependencies

The first step is to install some important dependencies, make sure you have installed this before compile the kernel sources.

$ sudo apt install build-essential bc bzip2 xz-utils git-core vim-common

2. Download and install the Toolchain

NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain for L4T 32.1

Download the pre-built toolchain binaries from http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

$ mkdir $HOME/l4t-gcc
$ cd $HOME/l4t-gcc
$ wget http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

Execute the following command to extract the toolchain:

tar -xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

3. Download the kernel sources

Download the kernel source files and then manually extract them.

$ wget https://developer.download.nvidia.com/embedded/L4T/r32_Release_v1.0/jax-tx2/BSP/JAX-TX2-public_sources.tbz2
$ tar -xvf JAX-TX2-public_sources.tbz2
$ cd public_sources/
$ JETSON_TX2_KERNEL_SOURCE=$(pwd)
$ tar -xvf kernel_src.tbz2

4. Apply driver patches

RidgeRun provides the required patches (usually by email) to update the kernel source and add support for the ov5647 camera driver. Once the patches file was received, apply them by running the following commands:

$ mv 4.2_j120_ov5647_v0.1.0.tar.gz $JETSON_TX2_KERNEL_SOURCE
$ cd $JETSON_TX2_KERNEL_SOURCE
$ tar -xvf 4.2_j120_ov5647_v0.1.0.tar.gz
$ quilt push

5. Compile kernel and device tree

Follow the steps:

$ cd $JETSON_TX2_KERNEL_SOURCE
$ CROSS_COMPILE=$HOME/l4t-gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
$ KERNEL_OUT=$JETSON_TX2_KERNEL_SOURCE/build
$ KERNEL_MODULES_OUT=$JETSON_TX2_KERNEL_SOURCE/modules
$ make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT tegra_defconfig

$ make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j6 Image    # Compile kernel image
$ make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j6 dtbs     # Compile device tree
$ make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j6 modules  # Compile modules
$ make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT modules_install INSTALL_MOD_PATH=$KERNEL_MODULES_OUT

6. Flash Jetson TX2

This guide assumes that the user already has JetPack 4.2 installed. This link contains details about how to install JetPack 4.2: https://docs.nvidia.com/sdk-manager/download-run-sdkm/index.html

JETPACK_4_2 contains the directory where JetPack 4.2 was installed. For example.

export JETPACK_4_2=$HOME/JetPack-L4T-4.2

Make sure the Jetson TX2 is in recovery mode.

$ cd ${JETPACK_4_2}/JetPack_4.2_Linux_P3310/Linux_for_Tegra
# Copy kernel generated
$ cp $JETSON_TX2_KERNEL_SOURCE/build/arch/arm64/boot/Image kernel/
# Copy device tree generated
$ cp $JETSON_TX2_KERNEL_SOURCE/build/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb kernel/dtb/
# Copy new modules
$ sudo cp -a $JETSON_TX2_KERNEL_SOURCE/modules/lib rootfs/
# Flash memory 
$ sudo ./flash.sh jetson-tx2 mmcblk0p1

Using the driver (GStreamer examples)

  • Capture at 1080p@30fps
DISPLAY=:0 gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1' ! nvvidconv ! queue ! ximagesink
  • Capture at 720p@30fps
DISPLAY=:0 gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)NV12, framerate=(fraction)30/1' ! nvvidconv ! queue ! ximagesink


RidgeRun Resources

Quick Start Client Engagement Process RidgeRun Blog Homepage
Technical and Sales Support RidgeRun Online Store RidgeRun Videos Contact Us

OOjs UI icon message-progressive.svg Contact Us

Visit our Main Website for the RidgeRun Products and Online Store. RidgeRun Engineering informations are available in RidgeRun Professional Services, RidgeRun Subscription Model and Client Engagement Process wiki pages. Please email to support@ridgerun.com for technical questions and contactus@ridgerun.com for other queries. Contact details for sponsoring the RidgeRun GStreamer projects are available in Sponsor Projects page. Ridgerun-logo.svg
RR Contact Us.png