Difference between revisions of "Toshiba TC358840 Linux driver for Jetson TX1 and TX2"

From RidgeRun Developer Connection
Jump to: navigation, search
(TC358840 features)
(Enable driver)
Line 24: Line 24:
 
In order to purchase the source code please send an email to '''inquiries@ridgerun.com''' or You can submit your Inquiry at our  [http://www.ridgerun.com/contact Contact Us Page]
 
In order to purchase the source code please send an email to '''inquiries@ridgerun.com''' or You can submit your Inquiry at our  [http://www.ridgerun.com/contact Contact Us Page]
  
= Enable driver =
+
= Build driver =
The driver was developed for kernel 3.10.67 using NVIDIA kernel source l4t-r23.2.
+
Let's call $DEVDIR the path where you download the kernel.
  
'''1.''' Follow the instructions in [[Compiling_Tegra_X1_source_code#Downloading_the_code|Compiling_Tegra_X1_source_code (Downloading the code)]] to get the kernel source code.
+
'''1.''' In a browser, navigate to: https://developer.nvidia.com/embedded/downloads, Locate and download the L4T Sources (L4T Sources 24.2.1 2016/11/21). Also, you can use wget command:
  
'''2.''' Once you have the source code, apply the following two patches if you haven't yet, for fixing kernel errors during compilation.
+
wget http://developer2.download.nvidia.com/embedded/L4T/r24_Release_v2.1/BSP/sources_r24.2.1.tbz2
  
kernel_r7_asm.patch
+
'''2.''' Copy L4T kernel sources into DEVDIR.
 +
<pre>
 +
cp sources_r24.2.1.tbz2 $DEVDIR
 +
</pre>
  
logical_comparison.patch
+
'''3.''' Expand tarball file.
 +
<pre>
 +
tar -vxjf sources_r24.2.1.tbz2
 +
# Decompress kernel
 +
cd sources/
 +
sudo tar -xjf kernel_src.tbz2
 +
</pre>
  
'''3.''' Apply the driver patches:
+
'''4.''' Download tc358840-r24.2.1-j130.tar.gz file and apply the patches.
 +
<pre>
 +
cp tc358840-r24.2.1-j130.tar.gz $DEVDIR
 +
cd $DEVDIR
 +
tar -xzvf tc358840-r24.2.1-j130.tar.gz
 +
quilt push -a
 +
</pre>
  
add-tc358743-driver.patch
+
'''5.''' Compile the kernel. Specify the path to the toolchain and architecture: (see http://developer.ridgerun.com/wiki/index.php?title=Compiling_Tegra_X1_source_code#Toolchain)
 +
<pre>
 +
export CROSS_COMPILE=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
 +
export CROSS32CC=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
 +
export ARCH=arm64
 +
</pre>
  
add-tc358743-dtb.patch
+
'''6.''' Define and create destination directories.
 +
<pre>
 +
export TEGRA_KERNEL_OUT=/home/$USER/sources_tc358840/images
 +
export TEGRA_MODULES_OUT=/home/$USER/sources_tc358840/modules
 +
mkdir -p $TEGRA_KERNEL_OUT
 +
mkdir -p $TEGRA_MODULES_OUT
 +
</pre>
  
fix-continuos-clock-in-v4l2-driver.patch
+
'''7.''' Configure your kernel
 +
<pre>
 +
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT tegra21_defconfig
 +
</pre>
  
'''4.''' Follow the instructions in [[Compiling_Tegra_X1_source_code#Build_Kernel|Compiling_Tegra_X1_source_code (Build Kernel)]] for building the kernel, and then flash the image.
+
'''8.''' Enable driver
  
Make sure to enable tc358743 driver support and soc_camera support, and disable platform camera support.
 
 
<pre>
 
<pre>
make menuconfig
+
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT menuconfig
 
</pre>
 
</pre>
 +
 +
Select the driver. The menu option is located:
  
 
<pre>
 
<pre>
-> Device Drivers                                                                                                                      
+
-> Device Drivers
   -> Multimedia support                                                                                          
+
   -> Multimedia support (MEDIA_SUPPORT [=y])
     -> Sensors used on soc_camera driver
+
     -> Encoders, decoders, sensors and other helper chips
       -> <M>tc358743 support
+
       <*> Toshiba TC358840 decoder
 
</pre>
 
</pre>
  
 +
Save your new configuration.
 +
 +
'''9.''' Compile kernel, device tree and modules.  To speed up compilation on multiprocessor systems, use -j n, this option tells make to execute many recipes simultaneously.
 
<pre>
 
<pre>
-> Device Drivers                                                                                                                       
+
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT zImage
  -> Multimedia support
+
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT dtbs
    ->V4L platform devices
+
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT modules
        -> <*> SoC camera support
+
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$TEGRA_MODULES_OUT
            -> < > platform camera support
 
 
</pre>
 
</pre>
  

Revision as of 09:57, 11 July 2017

Template:Eval SDK Download, Demo Image download and Contact Us buttons

TC358840 features

Reference: Toshiba TC358840 bridge chip

TC358840XBG, Ultra HD to CSI-2, bridge converts high resolution (higher than 4 Gbps) HDMI® stream to MIPI® CSI-2 Tx video. It is a follow up device of TC358840XBG.

  • Tested resolutions are 1280x720, 1920x1080. The tested format is UYVY.
  • TC358840 supports Dual links CSI-2 (CSI0 and CSI1), each link supports 4 data lanes @ 1 Gbps/data for Video resolution up to 4K×2K / 30fps (under development)

Source code

In order to purchase the source code please send an email to inquiries@ridgerun.com or You can submit your Inquiry at our Contact Us Page

Build driver

Let's call $DEVDIR the path where you download the kernel.

1. In a browser, navigate to: https://developer.nvidia.com/embedded/downloads, Locate and download the L4T Sources (L4T Sources 24.2.1 2016/11/21). Also, you can use wget command:

wget http://developer2.download.nvidia.com/embedded/L4T/r24_Release_v2.1/BSP/sources_r24.2.1.tbz2

2. Copy L4T kernel sources into DEVDIR.

cp sources_r24.2.1.tbz2 $DEVDIR

3. Expand tarball file.

tar -vxjf sources_r24.2.1.tbz2
# Decompress kernel
cd sources/
sudo tar -xjf kernel_src.tbz2

4. Download tc358840-r24.2.1-j130.tar.gz file and apply the patches.

cp tc358840-r24.2.1-j130.tar.gz $DEVDIR
cd $DEVDIR
tar -xzvf tc358840-r24.2.1-j130.tar.gz
quilt push -a

5. Compile the kernel. Specify the path to the toolchain and architecture: (see http://developer.ridgerun.com/wiki/index.php?title=Compiling_Tegra_X1_source_code#Toolchain)

export CROSS_COMPILE=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export CROSS32CC=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
export ARCH=arm64

6. Define and create destination directories.

export TEGRA_KERNEL_OUT=/home/$USER/sources_tc358840/images
export TEGRA_MODULES_OUT=/home/$USER/sources_tc358840/modules
mkdir -p $TEGRA_KERNEL_OUT
mkdir -p $TEGRA_MODULES_OUT

7. Configure your kernel

make -C sources/kernel/ O=$TEGRA_KERNEL_OUT tegra21_defconfig

8. Enable driver

make -C sources/kernel/ O=$TEGRA_KERNEL_OUT menuconfig

Select the driver. The menu option is located:

-> Device Drivers
  -> Multimedia support (MEDIA_SUPPORT [=y])
    -> Encoders, decoders, sensors and other helper chips
       <*> Toshiba TC358840 decoder

Save your new configuration.

9. Compile kernel, device tree and modules. To speed up compilation on multiprocessor systems, use -j n, this option tells make to execute many recipes simultaneously.

make -C sources/kernel/ O=$TEGRA_KERNEL_OUT zImage
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT dtbs
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT modules
make -C sources/kernel/ O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$TEGRA_MODULES_OUT

Mount the kernel module

sudo rmmod nvhost_vi

sudo modprobe tc358743

sudo modprobe tegra_camera

Examples

Yavta

Yavta (Yet Another V4L2 Test Application) can be used for testing the driver, according to the input video resolution:

./yavta /dev/video0 -c1 -n1 -s640x480 -Ftest1.raw
./yavta /dev/video0 -c1 -n1 -s1280x720 -Ftest2.raw
./yavta /dev/video0 -c1 -n1 -s1920x1080 -Ftest3.raw

Also Raw pixels can be used for visualizing the captured frame.

GStreamer

To capture a video of 100 frames, and according to the input video resolution use:

gst-launch-1.0 v4l2src num-buffers=100 ! 'video/x-raw,width=640,height=480,format=UYVY,framerate=60/1'\
 ! filesink location=test4.raw
gst-launch-1.0 v4l2src num-buffers=100 ! 'video/x-raw,width=1280,height=720,format=UYVY,framerate=60/1'\
 ! filesink location=test5.raw
gst-launch-1.0 v4l2src num-buffers=100 ! 'video/x-raw,width=1920,height=1080,format=UYVY,framerate=60/1'\
 ! filesink location=test6.raw

Output video can be visualized using Vooya


Also, the following pipeline can be used to visualize the input video in the Tegra X1:

  • 1280x720@60fps
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=1280,height=720,framerate=(fraction)60/1' ! queue ! videoconvert ! nveglglessink
  • 1280x720@30fps
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=1280,height=720,framerate=(fraction)30/1' ! queue ! videoconvert ! nveglglessink
  • 1920x1080@60fps
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=1920,height=1080,framerate=(fraction)60/1' ! queue ! videoconvert ! nveglglessink
  • 1920x1080@30fps
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=1920,height=1080,framerate=(fraction)30/1' ! queue ! videoconvert ! nveglglessink

Articles related

Toshiba TC358743 Linux driver for iMX6