OmniVision Monochrome OV24A1B Linux driver for Jetson

From RidgeRun Developer Wiki




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


Driver List Information
Refer to the RidgeRun Linux Camera Drivers to meet all the list of Drivers available


OmniVision Monochrome OV24A1B Sensor features

Reference: OmniVision OV24A1B sensor

Supported resolutions and formats

Feature Value
Resolution 5664x4248
Frame rate (fps) 30
Pixel Format Y10 / Y16
Pixel depth 10-bit Grayscale / 16-bit Grayscale

Controls

Control Minimum Maximum Default
Gain (dB) 0 31 4
Exposure (ms) 0.061 33.225 33.058
Frame rate (fps) 3 30 30

Build and install the 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 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. Lets call it ov24a1b_driver.tar.

1. Download the toolchain.
NVIDIA recommends using the Linaro 7.3.1 2018.05 toolchain. Download the pre-built toolchain binaries as follows:

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 commands to extract the toolchain:

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


2. Download and install JetPack 4.4 following the instructions from JetPack 4.4 Installation Instructions

3. Download the L4T sources according to your platform from the Jetson Download Center.

and also Download The Xavier AGX sources for JetPack 4.4.

4. Create a folder named sources/ in the Linux_for_Tegra/ directory.

mkdir -p JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/


5. Uncompress the public_sources.tbz2 tarball.

tar -xvf public_sources.tbz2


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.

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/


7. Apply the patch present in the provided tarball file:

First untar the provided tarball:

tar -xvf ov24a1b_driver.tar

Move the uncompressed patches/ folder into your JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/ directory.

mv patches/ JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/

Apply the patch as follows:

cd JetPack_4.4_Linux_JETSON_AGX_XAVIER/Linux_for_Tegra/source/
quilt push


8. Build the new patched kernel:

Create the main directories:

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/

Set up some variables:

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

Configure and build the kernel:

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

Enable and compile the driver

1. Select in the menu (if not selected yet):

Device Drivers  --->
    <*> Multimedia support  --->
        NVIDIA overlay Encoders, decoders, sensors and other helper chips  --->
            <*> OV24A1B camera sensor support

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.

2.Compile kernel, device tree and modules:

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


3. Copy the generated kernel and dtb:

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

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:

Bus 001 Device 015: ID 0955:7020 NVidia Corp.

2. Flash the board with the following command:

sudo ./flash.sh -r -k kernel-dtb -d kernel/dtb/tegra194-p2888-0001-p2822-0000.dtb jetson-xavier mmcblk0p1

3. Copy the compiled kernel image and modules:

Kernel:

scp ./kernel/Image nvidia@<xavier-ip>:/tmp/

Modules:

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/

4. Update kernel image and modules inside the board and reboot from CLI:

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

Test your Kernel image

1. Check the kernel version. At this moment you can test the image created in order to see the new kernel is working correctly.
You should see a new kernel version with the correct date of compilation:

uname -a 
Linux nvidia 4.9.140 #199 SMP PREEMPT Tue Mar 16 16:25:38 CST 2021 aarch64 aarch64 aarch64 GNU/Linux


2. You can see whether the driver is probed by executing this line:

dmesg | grep ov24a1b

Expected output:

nvidia@nvidia:~$ dmesg | grep ov24a1b
[    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


3. Check the created video devices:

ls /dev/video*
/dev/video0

Examples

GStreamer pipelines

5664x4248@30fps

gst-launch-1.0 v4l2src ! video/x-raw,width=5664,height=4248,format=GRAY16_LE ! perf ! fakesink

v4l2-ctl capturing

v4l2-ctl -d /dev/video0 --set-fmt-video=width=5664,height=4248,pixelformat=Y16 --set-ctrl bypass_mode=0 --stream-mmap --stream-to=test_frames.raw --stream-count=3

Where test_frames.raw will contain 3 frames. You can visualize the frames by using a software such as Vooya.
E.g you can use the following format parameters to visualize the raw captured frames in Vooya:

Frame visualization on Vooya


For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.