Toshiba TC358743 Linux driver for Jetson: Difference between revisions

From RidgeRun Developer Wiki
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<seo title="Toshiba TC358743 | TC358743 Linux Driver for Jetson TX1" titlemode="replace" keywords="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."  description="The Toshiba TC358743 Linux driver for Jetson TX1 is capable of handling video data up to 180P at 60fps. Learn about TC358743's features from RidgeRun today."></seo>
<table>
<table>
<tr>
<tr>
Line 10: Line 12:
{{Template:Eval SDK Download, Demo Image download and Contact Us buttons}}
{{Template:Eval SDK Download, Demo Image download and Contact Us buttons}}
</center></td></tr></table>
</center></td></tr></table>
<table>
<tr>
<td><div class="clear; float:right">__TOC__</div></td>
<td valign=top>
{{Debug Symbol}} Problems running the pipelines shown on this page?<br>Please see our [http://developer.ridgerun.com/wiki/index.php?title=GStreamer_Debugging GStreamer Debugging guide] for help.
</td>
</table>


= TC358743 features =  
= TC358743 features =  
Line 20: Line 30:
  * The TC358743 driver supports 2 and 4 lanes configuration for the given resolutions.
  * The TC358743 driver supports 2 and 4 lanes configuration for the given resolutions.


= Source code =
=Build Driver=
In order to purchase the source code please send an email to support@ridgerun.com or [http://www.ridgerun.com/#!contact/c3vn contact us]
 
==Build kernel using Jetpack 2.3.1==
 
'''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:


= Enable driver =
wget http://developer2.download.nvidia.com/embedded/L4T/r24_Release_v2.1/BSP/sources_r24.2.1.tbz2
The driver was developed for kernel 3.10.67 using NVIDIA kernel source l4t-r23.2.


'''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.
'''2.''' Copy L4T kernel sources into DEVDIR.
<pre>
cp sources_r24.2.1.tbz2 $DEVDIR
</pre>


'''2.''' Once you have the source code, apply the following two patches if you haven't yet, for fixing kernel errors during compilation.
'''3.''' Expand tarball file.
<pre>
tar -vxjf sources_r24.2.1.tbz2
# Decompress kernel
cd sources/
tar -xjf kernel_src.tbz2
cd ..
</pre>
 
'''4.''' Download tc358743-r24.2.1-j106.tar.gz file and apply the patches.
<pre>
tar -xzvf tc358743-r24.2.1-j106.tar.gz
quilt push -a
</pre>


kernel_r7_asm.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>


logical_comparison.patch
'''6.''' Define and create destination directories.
<pre>
export TEGRA_KERNEL_OUT=/home/$USER/JetPack-L4T-2.3.1/64_TX1/Linux_for_Tegra_64_tx1/sources_tc358743/images
export TEGRA_MODULES_OUT=/home/$USER/JetPack-L4T-2.3.1/64_TX1/Linux_for_Tegra_64_tx1/sources_tc358743/modules
mkdir -p $TEGRA_KERNEL_OUT
mkdir -p $TEGRA_MODULES_OUT
</pre>


'''3.''' Apply the driver patches:
'''7.''' Configure your kernel
<pre>
make -C kernel_source O=$TEGRA_KERNEL_OUT tegra21_defconfig
make -C kernel_source menuconfig
</pre>


add-tc358743-driver.patch
'''8.''' Configure your kernel
<pre>
make -C kernel_source O=$TEGRA_KERNEL_OUT tegra21_defconfig
</pre>


add-tc358743-dtb.patch
'''8.''' Enable driver


fix-continuos-clock-in-v4l2-driver.patch
<pre>
make -C kernel_source O=$TEGRA_KERNEL_OUT menuconfig
</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.
Select the driver. The menu option is located:


Make sure to enable tc358743 driver support and soc_camera support, and disable platform camera support.
<pre>
<pre>
make menuconfig
-> Device Drivers
  -> Multimedia support (MEDIA_SUPPORT [=y])
    -> Encoders, decoders, sensors and other helper chips
      <*> Toshiba TC358743 decoder
</pre>
</pre>


'''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 kernel_source O=$TEGRA_KERNEL_OUT zImage
  -> Multimedia support                                                                                         
make -C kernel_source O=$TEGRA_KERNEL_OUT dtbs
    -> Sensors used on soc_camera driver
make -C kernel_source O=$TEGRA_KERNEL_OUT modules
      -> <M>tc358743 support
make -C kernel_source O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$TEGRA_MODULES_OUT
</pre>
</pre>


== Test your Kernel image using Jetpack 2.3.1 root file system==
'''1.''' Go to Linux_for_Tegra_64_tx1 directory. Let's call $JETPACKDIR the path where you installed your development directory or Jetpack.
<pre>
<pre>
-> Device Drivers                                                                                                                       
cd $JETPACKDIR/64_TX1/Linux_for_Tegra_64_tx1/
  -> Multimedia support
    ->V4L platform devices
        -> <*> SoC camera support
            -> < > platform camera support
</pre>
</pre>


= Mount the kernel module =
'''2.''' Put the board into force USB Recovery Mode:
<pre>
<pre>
sudo rmmod nvhost_vi
1. Power down the device. If connected, remove the AC adapter from the device. The device must be
powered OFF, and not in a suspend or sleep state.
2. Connect the Micro-B plug on the USB cable to the Recovery (USB Micro-B) Port on the device and
the other end to an available USB port on the host PC.
3. Connect the power adapter to the device.
4. Press POWER button
5. Press and hold the RECOVERY FORCE (REC) button.
6. While pressing the RECOVERY FORCE button, press and release the RESET button.
7. Wait 2 seconds and release the RECOVERY FORCE button
</pre>


sudo modprobe tc358743
'''3.''' Use ./flash.sh in order to configure TX1 board, Also this script configures jetpack rootfs to be used as SD filesystem.
Execute the script as follows:


sudo modprobe tegra_camera
<pre>
sudo ./flash.sh jetson-tx1 mmcblk1p1
</pre>
</pre>


=Examples=
'''4.''' Create ext4 partition called "rootfs".
<pre>
sudo mkfs.ext4 /dev/mmcblk0p1 -L "rootfs"
</pre>


==Yavta==
'''5.''' Copy rootfs from jetpack 2.3.1
Yavta [https://github.com/fastr/yavta (Yet Another V4L2 Test Application)] can be used for testing the driver, according to the input video resolution:


<pre>
<pre>
./yavta /dev/video0 -c1 -n1 -s640x480 -Ftest1.raw
sudo cp -a $JETPACKDIR/64_TX1/Linux_for_Tegra_tx1/rootfs/* /media/$USER/rootfs/
</pre>
</pre>
'''6.''' Copy kernel image, device tree, and modules.


<pre>
<pre>
./yavta /dev/video0 -c1 -n1 -s1280x720 -Ftest2.raw
cd $TEGRA_KERNEL_OUT
sudo cp -a arch/arm64/boot/Image /media/$USER/rootfs/boot/Image
sudo cp -a arch/arm64/boot/dts/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb /media/$USER/rootfs/boot/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb
cd $TEGRA_MODULES_OUT
sudo cp -a lib/* /media/$USER/rootfs/lib/
</pre>
</pre>


'''7.''' Unmount the device and Put the SD into the TX1 board, and boot the board.
<pre>
<pre>
./yavta /dev/video0 -c1 -n1 -s1920x1080 -Ftest3.raw
umount /media/$USER/rootfs
</pre>
</pre>


Also [http://rawpixels.net/ Raw pixels] can be used for visualizing the captured frame.
'''8.''' Check 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:


==GStreamer==
To capture a video of 100 frames, and according to the input video resolution use:
<pre>
<pre>
gst-launch-1.0 v4l2src num-buffers=100 ! 'video/x-raw,width=640,height=480,format=UYVY,framerate=60/1'\
uname -a
! filesink location=test4.raw
Linux tegra-ubuntu 3.10.96+ #1 SMP PREEMPT Tue May 2 14:08:05 CST 2017 aarch64 aarch64 aarch64 GNU/Linux
</pre>
</pre>
==J106==
You can see that the driver is proved, execute the line:  dmesg | grep "(Tegra I2C adapter)"
Expected output:


<pre>
<pre>
gst-launch-1.0 v4l2src num-buffers=100 ! 'video/x-raw,width=1280,height=720,format=UYVY,framerate=60/1'\
ubuntu@tegra-ubuntu:~$ dmesg | grep "(Tegra I2C adapter)"
! filesink location=test5.raw
[    4.554634] tc358743 0-000f: tc358743 found @ 0xf (Tegra I2C adapter)
[    4.665076] tc358743 2-000f: tc358743 found @ 0xf (Tegra I2C adapter)
[    4.727283] tc358743 2-000d: tc358743 found @ 0xd (Tegra I2C adapter)
[    4.843073] tc358743 6-000f: tc358743 found @ 0xf (Tegra I2C adapter)
[    4.907802] tc358743 6-000d: tc358743 found @ 0xd (Tegra I2C adapter)
</pre>
</pre>
'''Note'''In this case, I have connected 5 devices in J106 ports. The output varies slightly when 6 devices are connected.
I have 5 video devices created:


<pre>
<pre>
gst-launch-1.0 v4l2src num-buffers=100 ! 'video/x-raw,width=1920,height=1080,format=UYVY,framerate=60/1'\
ls /dev/video*
  ! filesink location=test6.raw
/dev/video0  /dev/video2  /dev/video3  /dev/video4 /dev/video5
</pre>
</pre>


Output video can be visualized using [http://www.offminor.de/downloads.html Vooya]
=Examples=


==Yavta==
Yavta [https://github.com/fastr/yavta (Yet Another V4L2 Test Application)] can be used for testing the driver, according to the input video resolution:


Also, the following pipeline can be used to visualize the input video in the Tegra X1:
*640x480@60fps
<pre>
<pre>
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=640,height=480,framerate=(fraction)60/1' ! queue ! videoconvert ! nveglglessink
./yavta /dev/video0 -c1 -n1 -s640x480 -Ftest1.raw
</pre>
</pre>


*720x480@60fps
<pre>
<pre>
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=720,height=480,framerate=(fraction)60/1' ! queue ! videoconvert ! nveglglessink
./yavta /dev/video0 -c1 -n1 -s1280x720 -Ftest2.raw
</pre>
</pre>


*1280x720@60fps
<pre>
<pre>
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=1280,height=720,framerate=(fraction)60/1' ! queue ! videoconvert ! nveglglessink
./yavta /dev/video0 -c1 -n1 -s1920x1080 -Ftest3.raw
</pre>
</pre>


*1280x720@30fps
Also [http://rawpixels.net/ Raw pixels] can be used for visualizing the captured frame.
 
==GStreamer==
===720p@60 autovideosink===
<pre>
<pre>
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=1280,height=720,framerate=(fraction)30/1' ! queue ! videoconvert ! nveglglessink
gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,format=I420,width=1280,height=720' ! \
perf ! nvvidconv ! autovideosink sync=false
</pre>
</pre>


*1920x1080@60fps
===720p@30 autovideosink===
<pre>
<pre>
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=1920,height=1080,framerate=(fraction)60/1' ! queue ! videoconvert ! nveglglessink
gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,format=I420,width=1280,height=720' ! perf ! nvvidconv ! autovideosink sync=false
</pre>
</pre>


*1920x1080@30fps
===1080p@30-h264===
 
<pre>
<pre>
gst-launch-1.0 v4l2src ! 'video/x-raw,format=UYVY,width=1920,height=1080,framerate=(fraction)30/1' ! queue ! videoconvert ! nveglglessink
gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,format=I420,width=1920,height=1080' ! \
perf print-arm-load=yes ! \
nvvidconv ! \
omxh264enc bitrate=8000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! \
filesink location=test.h264 -e
</pre>
</pre>


Line 146: Line 235:
[[Toshiba TC358743 Linux driver for iMX6]]
[[Toshiba TC358743 Linux driver for iMX6]]


[[Category:TegraX1]][[Category:BoardDocumentation]]
= Contact Us =
 
If you are interested in purchasing the driver, or would like more information please send an email to '''support@ridgerun.com''' or post your inquiry at our [http://www.ridgerun.com/contact/ '''Contact Us link''']
 
[[Category:Jetson]][[Category:BoardDocumentation]]

Revision as of 16:15, 25 December 2017


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

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

TC358743 features

Reference: Toshiba TC358743 bridge chip

The Toshiba TC358743 is an HDMI 1.4 to MIPI CSI-2 1.01 bridge chip capable of handling video data up to 1080P at 60 fps.

* Tested resolutions are 640x480, 720x480, 1280x720, 1920x1080. Tested format is UYVY.
* The TC358743 driver supports 2 and 4 lanes configuration for the given resolutions.

Build Driver

Build kernel using Jetpack 2.3.1

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/
tar -xjf kernel_src.tbz2
cd ..

4. Download tc358743-r24.2.1-j106.tar.gz file and apply the patches.

tar -xzvf tc358743-r24.2.1-j106.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/JetPack-L4T-2.3.1/64_TX1/Linux_for_Tegra_64_tx1/sources_tc358743/images
export TEGRA_MODULES_OUT=/home/$USER/JetPack-L4T-2.3.1/64_TX1/Linux_for_Tegra_64_tx1/sources_tc358743/modules
mkdir -p $TEGRA_KERNEL_OUT
mkdir -p $TEGRA_MODULES_OUT

7. Configure your kernel

make -C kernel_source O=$TEGRA_KERNEL_OUT tegra21_defconfig
make -C kernel_source menuconfig

8. Configure your kernel

make -C kernel_source O=$TEGRA_KERNEL_OUT tegra21_defconfig

8. Enable driver

make -C kernel_source 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 TC358743 decoder

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 kernel_source O=$TEGRA_KERNEL_OUT zImage
make -C kernel_source O=$TEGRA_KERNEL_OUT dtbs
make -C kernel_source O=$TEGRA_KERNEL_OUT modules
make -C kernel_source O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$TEGRA_MODULES_OUT

Test your Kernel image using Jetpack 2.3.1 root file system

1. Go to Linux_for_Tegra_64_tx1 directory. Let's call $JETPACKDIR the path where you installed your development directory or Jetpack.

cd $JETPACKDIR/64_TX1/Linux_for_Tegra_64_tx1/

2. Put the board into force USB Recovery Mode:

1. Power down the device. If connected, remove the AC adapter from the device. The device must be
powered OFF, and not in a suspend or sleep state.
2. Connect the Micro-B plug on the USB cable to the Recovery (USB Micro-B) Port on the device and
the other end to an available USB port on the host PC.
3. Connect the power adapter to the device.
4. Press POWER button
5. Press and hold the RECOVERY FORCE (REC) button.
6. While pressing the RECOVERY FORCE button, press and release the RESET button.
7. Wait 2 seconds and release the RECOVERY FORCE button

3. Use ./flash.sh in order to configure TX1 board, Also this script configures jetpack rootfs to be used as SD filesystem. Execute the script as follows:

sudo ./flash.sh jetson-tx1 mmcblk1p1

4. Create ext4 partition called "rootfs".

 sudo mkfs.ext4 /dev/mmcblk0p1 -L "rootfs"

5. Copy rootfs from jetpack 2.3.1

sudo cp -a $JETPACKDIR/64_TX1/Linux_for_Tegra_tx1/rootfs/* /media/$USER/rootfs/

6. Copy kernel image, device tree, and modules.

cd $TEGRA_KERNEL_OUT
sudo cp -a arch/arm64/boot/Image /media/$USER/rootfs/boot/Image 
sudo cp -a arch/arm64/boot/dts/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb /media/$USER/rootfs/boot/tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb
cd $TEGRA_MODULES_OUT
sudo cp -a lib/* /media/$USER/rootfs/lib/

7. Unmount the device and Put the SD into the TX1 board, and boot the board.

umount /media/$USER/rootfs 

8. Check 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:

uname -a
Linux tegra-ubuntu 3.10.96+ #1 SMP PREEMPT Tue May 2 14:08:05 CST 2017 aarch64 aarch64 aarch64 GNU/Linux

J106

You can see that the driver is proved, execute the line: dmesg | grep "(Tegra I2C adapter)"

Expected output:

ubuntu@tegra-ubuntu:~$ dmesg | grep "(Tegra I2C adapter)"
[    4.554634] tc358743 0-000f: tc358743 found @ 0xf (Tegra I2C adapter)
[    4.665076] tc358743 2-000f: tc358743 found @ 0xf (Tegra I2C adapter)
[    4.727283] tc358743 2-000d: tc358743 found @ 0xd (Tegra I2C adapter)
[    4.843073] tc358743 6-000f: tc358743 found @ 0xf (Tegra I2C adapter)
[    4.907802] tc358743 6-000d: tc358743 found @ 0xd (Tegra I2C adapter)

NoteIn this case, I have connected 5 devices in J106 ports. The output varies slightly when 6 devices are connected.

I have 5 video devices created:

ls /dev/video*
/dev/video0  /dev/video2  /dev/video3  /dev/video4  /dev/video5

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

720p@60 autovideosink

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,format=I420,width=1280,height=720' ! \
perf !  nvvidconv ! autovideosink sync=false

720p@30 autovideosink

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,format=I420,width=1280,height=720' ! perf !  nvvidconv ! autovideosink sync=false

1080p@30-h264

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,format=I420,width=1920,height=1080' ! \
perf print-arm-load=yes ! \
nvvidconv ! \
omxh264enc bitrate=8000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! \
filesink location=test.h264 -e

Articles related

Toshiba TC358743 Linux driver for iMX6

Contact Us

If you are interested in purchasing the driver, or would like more information please send an email to support@ridgerun.com or post your inquiry at our Contact Us link