Jump to content

OmniVision Monochrome OV24A1B Linux driver for Jetson: Difference between revisions

no edit summary
(Created page with "<seo title="OmniVision Monochrome OV24A1B | OV24A1B Linux Driver for Jetson" titlemode="replace" keywords="GStreamer, Embedded Linux, Device Drivers, NVIDIA, Xilinx, TI, NXP,...")
 
No edit summary
Line 276: Line 276:
! Feature !! Value
! Feature !! Value
|-
|-
| Resolution || 1280x720
| Resolution || 5664x4248
|-
|-
| Framerate(fps) || 30
| Framerate(fps) || 30
|-
|-
| Format || BGGR
| Format || GRAY16_LE
|-
|-
| Pixel depth || 10
| Pixel depth || 16
|}
|}


Line 289: Line 289:
* Gain
* Gain
* Exposure
* Exposure
* Frame rate


==Build kernel using Jetpack and OV24A1B driver==
==Build kernel using Jetpack and OV24A1B driver==
The following guide relies on the steps required to install the OV24A1B driver on JetPack 4.4 for the Jetson AGX Xavier platform.


=== Building kernel sources ===
=== Building kernel sources ===
Follow the instructions in [[NVIDIA_Jetson_Nano_-_Building_the_Kernel_from_Source | NVIDIA_Jetson_Nano - Building the Kernel from Source]] to build the kernel sources.
 
Once you have purchased the driver you will be provided with a tarball file containing the required patches to install the driver.<br>
Lets call it ''ov24a1b_driver.tar''.
 
'''1.''' Download the toolchain.<br><br>
 
NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain. Download the pre-built toolchain binaries as follows:
<syntaxhighlight lang=bash>
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
</syntaxhighlight>
 
Execute the following commands to extract the toolchain:
<syntaxhighlight lang=bash>
mkdir -p $HOME/l4t-gcc
cd $HOME/l4t-gcc
tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
</syntaxhighlight>
 
'''2.''' Download and install JetPack 4.4 following the instructions from [[https://developer.ridgerun.com/wiki/index.php?title=Raspberry_Pi_HQ_camera_IMX477_Linux_driver_for_Jetson#Download_the_JetPack_4.4|JetPack 4.4 Installation Instructions]]<br><br>
'''NOTE:''' Select your Jetson platform as the Target Hardware (e.g ''Jetson Xavier AGX'').
 
'''3.''' Download the L4T sources according to your platform from the [https://developer.nvidia.com/embedded/downloads Jetson Download Center].<br><br>
 
The Xavier AGX sources for JetPack 4.4 can be downloaded from [https://developer.nvidia.com/embedded/L4T/r32_Release_v4.3/sources/T186/public_sources.tbz2 here].
 
'''4.''' Create a folder named ''sources/'' in the ''Linux_for_Tegra/'' directory.
<syntaxhighlight>
mkdir -p JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/
</syntaxhighlight>
 
'''5.''' Uncompress the ''public_sources.tbz2'' tarball.
<syntaxhighlight>
tar -xvf public_sources.tbz2
</syntaxhighlight>
 
'''6.''' Uncompress the ''public_sources.tbz2/Linux_for_Tegra/source/public/kernel_src.tbz2'' content (kernel and hardware folders) in the ''JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/'' directory.
<syntaxhighlight>
cd Linux_for_Tegra/source/public/
tar -xvf kernel_src.tbz2
mv hardware/ kernel/ JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/
</syntaxhighlight>
 
'''7.''' Apply the patch present in the provided tarball file:
 
First untar the provided tarball:
<syntaxhighlight>
tar -xvf ov24a1b_driver.tar
</syntaxhighlight>
 
Move the uncompressed ''patches/'' folder into your ''JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/'' directory.
<syntaxhighlight>
mv patches/ JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/
</syntaxhighlight>
 
Apply the patch as follows:
<syntaxhighlight>
cd JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/
quilt push
</syntaxhighlight>
 
'''8.''' Build the new patched kernel:
 
Create the main directories:
<syntaxhighlight>
JETSON_KERNEL_SOURCE=JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/
cd $JETSON_KERNEL_SOURCE/../
mkdir -p modules/
mkdir -p packages/
mkdir -p dtb/
</syntaxhighlight>
 
Set up some variables:
<syntaxhighlight>
CROSS_COMPILE=$HOME/l4t-gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
KERNEL_OUT=$JETSON_KERNEL_SOURCE/../build
KERNEL_MODULES_OUT=$JETSON_KERNEL_SOURCE/../modules
</syntaxhighlight>
 
Configure and build the kernel:
<syntaxhighlight>
cd $JETSON_KERNEL_SOURCE
make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT tegra_defconfig
make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT menuconfig
</syntaxhighlight>


==== Enable driver ====
==== Enable driver ====
Once you are following the guide there is a step '''make menuconfig''', which allows you to enable the OV24A1B driver as built-in.


<syntaxhighlight lang=bash>
Select in the menu (if not selected yet):
make ARCH=arm64 O=$KERNEL_OUT menuconfig
<syntaxhighlight>
Device Drivers  --->
    <*> Multimedia support  --->
        NVIDIA overlay Encoders, decoders, sensors and other helper chips  --->
            <*> OV24A1B camera sensor support
</syntaxhighlight>
Go back by hitting the double ''Esc'' key until you get the message: ''"Do you want to save your new configuration?"'', select ''Yes'' and press Enter.
It allows you to enable the OV24A1B driver as built-in.<br><br>
 
Compile kernel, device tree and modules:
<syntaxhighlight>
make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j4 Image
make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j4 dtbs
make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j4 modules
make -C kernel/kernel-4.9/ ARCH=arm64 O=$KERNEL_OUT modules_install INSTALL_MOD_PATH=$KERNEL_MODULES_OUT
</syntaxhighlight>
 
Copy the generated kernel and dtb:
<syntaxhighlight>
cd $JETSON_KERNEL_SOURCE/../
cp build/arch/arm64/boot/dts/tegra194-p2888-0001-p2822-0000.dtb ./kernel/dtb
cp build/arch/arm64/boot/Image ./kernel
</syntaxhighlight>
 
==== Flash the Xavier AGX and install the OV24A1B driver ====
 
'''1.''' Put your Jetson developer kit into Force Recovery Mode (RCM):
 
'''i)''' Ensure that the developer kit is powered off.
'''ii)''' Press and hold down the Force Recovery button.
'''iii)''' Press, then release the Power button.
'''iv)''' Release the Recovery button.
     
You can confirm that your developer kit is in Force Recovery mode you can use lsusb and get the following line as part of the output:
<syntaxhighlight>
Bus 001 Device 015: ID 0955:7020 NVidia Corp.
</syntaxhighlight>
</syntaxhighlight>


Select the driver. The menu option is located:
'''2.''' Flash the board with the following command:
<syntaxhighlight>
sudo ./flash.sh -r -k kernel-dtb -d kernel/dtb/tegra194-p2888-0001-p2822-0000.dtb jetson-xavier mmcblk0p1
</syntaxhighlight>


<pre class="config">
'''3.''' Copy the compiled kernel image and modules:
-> Device Drivers
 
  -> Multimedia support (MEDIA_SUPPORT [=y])
Kernel:
    -> NVIDIA overlay Encoders, decoders, sensors and other helper chips
<syntaxhighlight>
      <*> OV24A1B camera sensor support
scp ./kernel/Image nvidia@<xavier-ip>:/tmp/
</pre>
</syntaxhighlight>
 
Modules:
<syntaxhighlight>
scp -r ./modules/lib/modules/4.9.140/kernel/ nvidia@<xavier-ip>:/tmp/
scp ./modules/lib/modules/4.9.140/modules.* nvidia@<xavier-ip>:/tmp/
</syntaxhighlight>
 
'''4.''' Update kernel image and modules inside the board and reboot from CLI:
<syntaxhighlight>
cd /tmp/
sudo rm -rf /lib/modules/4.9.140/kernel/*
sudo mv kernel/* /lib/modules/4.9.140/kernel/
sudo mv modules.* /lib/modules/4.9.140/
sudo mv Image /boot/
sudo reboot
</syntaxhighlight>


== Test your Kernel image using Jetpack root file system==
== Test your Kernel image using Jetpack root file system==


Check the kernel version. At this moment you can test the image created in order to see the new kernel is working correctly. You have to see a new kernel version with the correct date of compilation:
'''1.''' Check the kernel version. At this moment you can test the image created in order to see the new kernel is working correctly.<br>
 
You should see a new kernel version with the correct date of compilation:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
uname -a  
uname -a  
Linux nvidia 4.9.140 #6 SMP PREEMPT Tue May 7 16:25:38 CST 2019 aarch64 aarch64 aarch64 GNU/Linux
Linux nvidia 4.9.140 #199 SMP PREEMPT Tue Mar 16 16:25:38 CST 2021 aarch64 aarch64 aarch64 GNU/Linux
</syntaxhighlight>
</syntaxhighlight>


You can see that the driver is probed, execute the line:  dmesg | grep "ov24a1b"
 
'''2.''' You can see whether the driver is probed by executing this line:   
<syntaxhighlight lang=bash>
dmesg | grep "ov24a1b"
</syntaxhighlight>


Expected output:
Expected output:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
nvidia@nvidia:~$ dmesg | grep "ov24a1b"
nvidia@nvidia:~$ dmesg | grep ov24a1b
[    1.667200] ov24a1b 6-001a: detected ov24a1b sensor
[    1.926169] ov24a1b 30-0036: probing v4l2 sensor
[    1.927161] ov24a1b 30-0036: tegracam sensor driver:_v2.0.6
[    1.926169] tegra194-vi5 15c10000.vi: subdev ov24a1b 30-0036 bound
</syntaxhighlight>
</syntaxhighlight>


video devices created:
'''3.''' Check the created video devices:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
Line 339: Line 484:
===GStreamer pipelines ===
===GStreamer pipelines ===


====1280x720p@30fps====
====5664x4248@30fps====
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
gst-launch-1.0 nvarguscamerasrc sensor-id=1 ! "video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)NV12, framerate=(fraction)30/1" ! nvvidconv ! "video/x-raw, width=1280, height=720, format=(string)I420, framerate=30/1" ! xvimagesink -e
gst-launch-1.0 v4l2src ! video/x-raw,width=5664,height=4248,format=GRAY16_LE ! perf ! fakesink
</syntaxhighlight>
</syntaxhighlight>
{{ContactUs}}
{{ContactUs}}


[[Category:Jetson]][[Category:Jetson V4L2 Drivers]]
[[Category:Jetson]][[Category:Jetson V4L2 Drivers]]
932

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.