Difference between revisions of "VEYE CS Camera source for Jetson/zh"

From wiki_veye
Jump to navigation Jump to search
 
(37 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[VEYE CS Camera source for Jetson|English]]
 
[[VEYE CS Camera source for Jetson|English]]
  
'''英伟达Jetson平台上VEYE和CS系列摄像头驱动源码编译指南'''
+
'''英伟达Jetson平台上VEYE摄像头驱动源码编译指南'''
  
 
=== 概述 ===
 
=== 概述 ===
 +
NVIDIA为每个Jetpack版本都发布了Linux开发文档。比如L4T [https://docs.nvidia.com/jetson/archives/r35.1/DeveloperGuide/text/SD/Kernel.html 35.1]和[https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-325/#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/kernel_custom.html# 32.5]。本章节是以官方的Kernel Customization章节为基础的,不够详尽之处,请参考官方文档。
 +
 +
我们使用安装Ubuntu的host pc和Jetson板子作开发环境。
 +
 +
* Jetpack4.x
 +
 +
驱动与linux内核编译到一起,在host pc上进行。dtb的编译也在host pc进行。
 +
 +
* Jetpack5.x
 +
 +
驱动独立于linux内核,编译为modules,在Jetson板上进行。dtb的编译在host pc进行。
  
 
==== 版本对应关系 ====
 
==== 版本对应关系 ====
Line 11: Line 22:
 
* Jetpack4.4,L4T版本r32.4.3
 
* Jetpack4.4,L4T版本r32.4.3
 
* Jetpack4.4.1,L4T版本r32.4.4
 
* Jetpack4.4.1,L4T版本r32.4.4
 +
*Jetpack4.5,L4T版本r32.5
 +
*Jetpack4.5.1,L4T版本r32.5.1
 +
*Jetpack4.6,L4T版本r32.6.1
 +
*Jetpack4.6.1,L4T版本r32.7.1
 +
*Jetpack4.6.2,L4T版本r32.7.2
 +
*Jetpack4.6.3,L4T版本r32.7.3
 +
*Jetpack5.0.1DP,L4T版本r34.1.1
 +
*Jetpack5.0.2, L4T版本r35.1
 +
*Jetpack5.1, L4T版本r35.2.1
 +
*Jetpack5.1.1, L4T版本r35.3.1
 +
*Jetpack5.1.2, L4T版本r35.4.1
 +
*Jetpack5.1.3, L4T版本r35.5
  
 
====查看当前L4T版本====
 
====查看当前L4T版本====
Line 23: Line 46:
 
则表示当前版本为32.4.3。
 
则表示当前版本为32.4.3。
 
=== HOST开发环境准备 ===
 
=== HOST开发环境准备 ===
步骤参考:[[VEYE CS Camera for Jetson TX2/zh#HOST.E5.BC.80.E5.8F.91.E7.8E.AF.E5.A2.83.E5.87.86.E5.A4.87|3.5.1 HOST开发环境准备]]。
+
以下操作均为在HOST PC进行。
 +
 
 +
==== 编译工具链 ====
 +
 
 +
* Jetpack4.x
 +
 
 +
请参考[https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fxavier_toolchain.html%23wwpID0ESHA 这个链接]安装编译工具链。
 +
 
 +
* Jetpack5.x
 +
 
 +
请参考[https://docs.nvidia.com/jetson/archives/r35.1/DeveloperGuide/text/AT/JetsonLinuxToolchain.html 这个链接]安装编译工具链。
 +
 
 +
==== L4T源码和Rootfs ====
 +
首先使用SDK Manager在HOST PC上面下载对应的Linux_for_Tegra开发包。
 +
 
 +
可以通过SDK Manager或者[https://developer.nvidia.com/embedded/downloads 直接下载]两种方式来获得源码。具体参考官方文档,此处不再赘述。我推荐直接下载的方式。
 +
 
 +
使用SDK Manager时同步代码采用如下指令:
 +
 
 +
''- Jetpack4.2.2''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.2.1</code>
 +
 
 +
''- Jetpack4.3''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.3.1</code>
 +
 
 +
''- Jetpack4.4''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.4.3</code>
 +
 
 +
''- Jetpack4.4.1''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.4.4</code>
 +
 
 +
''- Jetpack4.5''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.5</code>
 +
 
 +
''- Jetpack4.5.1''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.5.1</code>
 +
 
 +
''- Jetpack4.6''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.6.1</code>
 +
 
 +
''- Jetpack4.6.1''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.7.1</code>
 +
 
 +
''- Jetpack4.6.2''
 +
 
 +
[https://forums.developer.nvidia.com/t/source-sync-sh-fails-with-tegra-l4t-r32-7-2-tag/212787/5 Nvidia did not push sources to nv-tegra for this 32.7.2 release because there have been no changes in the kernel and DTS compared to 32.7.1 release.]
 +
 
 +
''- Jetpack4.6.3''
 +
 
 +
<code>./source_sync.sh -t tegra-l4t-r32.7.3</code>
 +
 
 +
''- Jetpack5.0.1 DP''
 +
 
 +
<code>./source_sync.sh -t jetson_34.1.1</code>
 +
 
 +
''- Jetpack5.0.2''
 +
 
 +
<code>./source_sync.sh -t jetson_35.1</code>
 +
 
 +
''- Jetpack5.1''
 +
 
 +
<code>./source_sync.sh -t jetson_35.2.1</code>
 +
 
 +
''- Jetpack5.1.1''
 +
 
 +
<code>./source_sync.sh -t jetson_35.3.1</code>
 +
 
 +
''- Jetpack5.1.2''
 +
 
 +
<code>./source_sync.sh -t jetson_35.4.1</code>
 +
 
 +
''- Jetpack5.1.3''
 +
 
 +
<code>./source_sync.sh -t jetson_35.5</code>
 +
 
 +
==== 配置开发环境 ====
 +
以下步骤假设SDK安装目录为<TOPDIR>,源代码在$L4T_DIR/sources目录。
 +
 
 +
<code>export TOP_DIR=<absolute path to top dir accroding to your jetpack version and board name;for example /home/xumm/nvidia/nvidia_sdk/JetPack_4.5_Linux_JETSON_XAVIER_NX_DEVKIT/></code>
 +
 
 +
* 通用部分
 +
 
 +
<code>export L4T_DIR=$TOP_DIR/Linux_for_Tegra</code>
 +
 
 +
<code>export LOCALVERSION=-tegra</code>
 +
 
 +
<code>export LDK_ROOTFS_DIR=$TOP_DIR/Linux_for_Tegra/rootfs</code>
 +
 
 +
<code>export ARCH=arm64</code>
 +
 
 +
<code>export TEGRA_KERNEL_OUT=$L4T_DIR/sources/kernel/out_kernel</code>
 +
 
 +
<code>export KERNEL_PATH=$L4T_DIR/sources/kernel/out_kernel</code>
 +
 
 +
<code>export NVIDIA_PATH=$L4T_DIR/sources/kernel/nvidia</code>
 +
 
 +
<code>export NANO_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t210/</code>
 +
 
 +
<code>export TX2_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t18x</code>
 +
 
 +
<code>export XAVIER_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t19x</code>
 +
 
 +
<code>export ORIN_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t23x</code>
 +
 
 +
* Jetpack 4.x
 +
 
 +
<code>export CROSS_COMPILE=aarch64-linux-gnu-</code>
 +
 
 +
<code>export CROSS32CC=arm-linux-gnueabihf-gcc</code>
 +
 
 +
<code>export COMMON_DTS_PATH=$TEGRA_KERNEL_OUT/arch/arm64/boot/dts/</code>
 +
 
 +
* Jetpack 5.x
 +
 
 +
<code>export CROSS_COMPILE_AARCH64_PATH=$HOME/l4t-gcc</code>
 +
 
 +
<code>export CROSS_COMPILE_AARCH64=$HOME/l4t-gcc/bin/aarch64-buildroot-linux-gnu-</code>
 +
 
 +
<code>export CROSS_COMPILE=$CROSS_COMPILE_AARCH64</code>
 +
 
 +
<code>export COMMON_DTS_PATH=$TEGRA_KERNEL_OUT/arch/arm64/boot/dts/nvidia</code>
  
以下操作均为在HOST PC进行。
 
 
=== 下载我们的bsp包===
 
=== 下载我们的bsp包===
 
<code>cd $L4T_DIR</code>
 
<code>cd $L4T_DIR</code>
Line 33: Line 183:
 
<code>export RELEASE_PACK_DIR=$L4T_DIR/nvidia_jetson_veye_bsp</code><code><nowiki/></code><code><nowiki/></code><code><nowiki/></code>
 
<code>export RELEASE_PACK_DIR=$L4T_DIR/nvidia_jetson_veye_bsp</code><code><nowiki/></code><code><nowiki/></code><code><nowiki/></code>
 
===编译kernel===
 
===编译kernel===
 +
对于Jetpack4.x版本以及在Jetpack5.x版本下使用MV系列相机的,需要编译kernel。
 +
 +
==== MV系列相机的patch包 ====
 +
对于MV系列相机,除了在linux系统中增加了摄像头的驱动,我们还增加了一个内核补丁——veye_mv_l4t_[version].patch。
 +
 +
这个patch具备两个功能:
 +
 +
# 增加了黑白相机的Y10和Y12两种数据格式的支持。
 +
# 增加了trigger模式的支持。
 +
 +
这个补丁包对于VEYE系列和CS系列相机,可以不使用。
 +
 +
<code>cd $L4T_DIR/sources/kernel/</code>
 +
 +
<code>patch -p1 < [path to]veye_mv_l4t_[version].patch</code>
 +
 +
==== 对于Jetpack4.x,将camera驱动编译进Image ====
  
==== patch代码 ====
+
===== patch代码 =====
 
<code>cp $RELEASE_PACK_DIR/drivers_source/cam_drv_src/* $NVIDIA_PATH/drivers/media/i2c/</code>
 
<code>cp $RELEASE_PACK_DIR/drivers_source/cam_drv_src/* $NVIDIA_PATH/drivers/media/i2c/</code>
  
 
<code>cp $RELEASE_PACK_DIR/drivers_source/kernel_veyecam_config_<l4t_version> $L4T_DIR/sources/kernel/kernel-4.9/arch/arm64/configs/tegra_veyecam_defconfig</code>
 
<code>cp $RELEASE_PACK_DIR/drivers_source/kernel_veyecam_config_<l4t_version> $L4T_DIR/sources/kernel/kernel-4.9/arch/arm64/configs/tegra_veyecam_defconfig</code>
  
==== 编译 ====
+
===== 修改Kconfig和Makefile =====
 +
手动修改<code>$NVIDIA_PATH/drivers/media/i2c/</code>目录下的Kconfig和Makefile,增加对应camera驱动的编译选项。
 +
 
 +
===== 编译 =====
 
<code>cd $L4T_DIR/sources/kernel/kernel-4.9/</code>
 
<code>cd $L4T_DIR/sources/kernel/kernel-4.9/</code>
  
Line 46: Line 216:
 
<code>make ARCH=arm64 O=$TEGRA_KERNEL_OUT Image -j4</code>
 
<code>make ARCH=arm64 O=$TEGRA_KERNEL_OUT Image -j4</code>
  
 +
==== 对于Jetpack5.x,无需将camera驱动编译进Image ====
 +
 +
===== 编译 =====
 +
<code>cd $L4T_DIR/sources/</code>
 +
 +
<code>./nvbuild.sh -o $TEGRA_KERNEL_OUT</code>
 +
 +
如果没有找到此脚本:
 +
 +
<code>nvbuild.sh</code> is only included in the <code>kernel_src.tbz2</code> tar file that is part of <code>public_sources.tbz2</code>. If the kernel sources were synced from the Git server, you need to manually copy <code>nvbuild.sh</code> from the tar file.
 +
 +
==== 编译完成 ====
 
编译完成的Image文件在:
 
编译完成的Image文件在:
  
Line 54: Line 236:
 
以下用于整体烧写
 
以下用于整体烧写
  
<code>sudo cp $TEGRA_KERNEL_OUT/arch/arm64/boot/Image $L4T_DIR/kernel/ -f</code>
+
<code>cp $TEGRA_KERNEL_OUT/arch/arm64/boot/Image $L4T_DIR/kernel/ -f</code>
  
*对于xavier,进行签名
+
*对于xavier和Orin,需要进行签名
  
 
<code>cd $L4T_DIR</code>
 
<code>cd $L4T_DIR</code>
  
 
<code>./l4t_sign_image.sh --file kernel/Image --chip 0x19</code>
 
<code>./l4t_sign_image.sh --file kernel/Image --chip 0x19</code>
 +
 +
=== 编译modules(Jetpack5.x) ===
 +
Jetpack5.x以后的版本,可以直接以modules方式编译驱动,得到ko文件。推荐直接在Jetson Board上面编译驱动。
 +
 +
<code>cd $RELEASE_PACK_DIR/drivers_source/cam_drv_src/</code>
 +
 +
<code>make</code>
 +
 
===编译DTS===
 
===编译DTS===
 
首先需要patch代码。
 
首先需要patch代码。
Line 79: Line 269:
  
 
<code>cp $RELEASE_PACK_DIR/TX2/JetPack_<ver>_Linux_JETSON_TX2/dts\ dtb/<camera model>/tegra186-quill-p3310-1000-a00-00-base.dts $TX2_DTS_PATH/quill/kernel-dts/</code>
 
<code>cp $RELEASE_PACK_DIR/TX2/JetPack_<ver>_Linux_JETSON_TX2/dts\ dtb/<camera model>/tegra186-quill-p3310-1000-a00-00-base.dts $TX2_DTS_PATH/quill/kernel-dts/</code>
 +
 +
<code>cp $RELEASE_PACK_DIR/TX2/JetPack_<ver>_Linux_JETSON_TX2/dts\ dtb/<camera model>/tegra186-p3636-0001-p3509-0000-a01.dts $TX2_DTS_PATH/lanai/kernel-dts</code>
  
 
==== AGX Xavier ====
 
==== AGX Xavier ====
Line 95: Line 287:
  
 
<code>cp $RELEASE_PACK_DIR/Xavier-NX/JetPack_<ver>_Linux_JETSON_XAVIER_NX_DEVKIT/dts\ dtb/<camera model>/tegra194-p3509-0000-a00.dtsi $XAVIER_DTS_PATH/jakku/kernel-dts/common/</code>
 
<code>cp $RELEASE_PACK_DIR/Xavier-NX/JetPack_<ver>_Linux_JETSON_XAVIER_NX_DEVKIT/dts\ dtb/<camera model>/tegra194-p3509-0000-a00.dtsi $XAVIER_DTS_PATH/jakku/kernel-dts/common/</code>
 +
 +
==== Orin ====
 +
<code>cp $RELEASE_PACK_DIR/Orin/JetPack_<ver>_Linux_JETSON_ORIN_TARGETS/dts\ dtb/common/t23x/* -r $ORIN_DTS_PATH/</code>
 +
 +
For <camera model>
 +
 +
<code>cp $RELEASE_PACK_DIR/Orin/JetPack_<ver>_Linux_JETSON_ORIN_TARGETS/dts\ dtb/<camera model>/tegra234-p3737-camera-modules.dtsi $ORIN_DTS_PATH/concord/kernel-dts/cvb/</code>
 +
 +
<code>cp $RELEASE_PACK_DIR/Orin/JetPack_<ver>_Linux_JETSON_ORIN_TARGETS/dts\ dtb/<camera model>/tegra234-p3768-0000-a0.dtsi $ORIN_DTS_PATH/p3768/kernel-dts/cvb</code>
  
 
==== 编译 ====
 
==== 编译 ====
 +
 +
* For Jetpack4.X
 +
 +
<code>export COMMON_DTS_PATH=$TEGRA_KERNEL_OUT/arch/arm64/boot/dts</code>
 +
 
<code>cd $L4T_DIR/sources/kernel/kernel-4.9/</code>
 
<code>cd $L4T_DIR/sources/kernel/kernel-4.9/</code>
 +
 +
* For Jetpack5.X
 +
 +
<code>export COMMON_DTS_PATH=$TEGRA_KERNEL_OUT/arch/arm64/boot/dts/nvidia</code>
 +
 +
<code>cd $L4T_DIR/sources/kernel/kernel-5.10/</code>
  
 
<code>make ARCH=arm64 O=$TEGRA_KERNEL_OUT dtbs</code>
 
<code>make ARCH=arm64 O=$TEGRA_KERNEL_OUT dtbs</code>
  
编译完成的dtb文件路径如下所示,可手动升级或整体升级。
+
You can get the compiled DTB file in the following path.
 +
=====Nano=====
 +
<code>$COMMON_DTS_PATH/tegra210-p3448-0000-p3449-0000-a02.dtb</code>
 +
 
 +
<code>$COMMON_DTS_PATH/tegra210-p3448-0000-p3449-0000-b00.dtb</code>
  
===== Nano =====
+
<code>$COMMON_DTS_PATH/tegra210-p3448-0003-p3542-0000.dtb</code>
<code>cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra210-p3448-0000-p3449-0000-a02.dtb $L4T_DIR/kernel/dtb/</code>
+
=====TX2=====
 +
<code>$COMMON_DTS_PATH/tegra186-quill-p3310-1000-c03-00-base.dtb</code>
 +
=====TX2 NX(p3509-0000 carrier board)=====
 +
<code>$COMMON_DTS_PATH/tegra186-p3636-0001-p3509-0000-a01.dtb</code>
 +
=====AGX XAVIER=====
 +
<code>$COMMON_DTS_PATH/tegra194-p2888-0001-p2822-0000.dtb</code>
 +
=====XAVIER NX=====
 +
<code>$COMMON_DTS_PATH/tegra194-p3668-all-p3509-0000.dtb</code>
  
<code>cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra210-p3448-0000-p3449-0000-b00.dtb $L4T_DIR/kernel/dtb/</code>
+
===== AGX Orin =====
 +
<code>$COMMON_DTS_PATH/tegra234-p3701-0000-p3737-0000.dtb</code>
  
<code>cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra210-p3448-0003-p3542-0000.dtb $L4T_DIR/kernel/dtb/</code>
+
===== Orin Nano =====
 +
<code>$COMMON_DTS_PATH/tegra234-p3767-0003-p3768-0000-a0.dtb</code>
  
===== TX2 =====
+
<code>$COMMON_DTS_PATH/tegra234-p3767-0004-p3768-0000-a0.dtb</code>
<code>cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb $L4T_DIR/kernel/dtb/</code>
 
  
===== AGX XAVIER =====
+
===== Orin NX =====
<code>cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra194-p2888-0001-p2822-0000.dtb $L4T_DIR/kernel/dtb/</code>
+
<code>$COMMON_DTS_PATH/tegra234-p3767-0000-p3768-0000-a0.dtb</code>
  
===== XAVIER NX =====
+
<code>$COMMON_DTS_PATH/tegra234-p3767-0001-p3768-0000-a0.dtb</code>
<code>cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra194-p3668-all-p3509-0000.dtb $L4T_DIR/kernel/dtb/</code>
+
<br />

Latest revision as of 14:54, 22 May 2024

English

英伟达Jetson平台上VEYE摄像头驱动源码编译指南

1 概述

NVIDIA为每个Jetpack版本都发布了Linux开发文档。比如L4T 35.132.5。本章节是以官方的Kernel Customization章节为基础的,不够详尽之处,请参考官方文档。

我们使用安装Ubuntu的host pc和Jetson板子作开发环境。

  • Jetpack4.x

驱动与linux内核编译到一起,在host pc上进行。dtb的编译也在host pc进行。

  • Jetpack5.x

驱动独立于linux内核,编译为modules,在Jetson板上进行。dtb的编译在host pc进行。

1.1 版本对应关系

  • Jetpack4.2.2,L4T版本r32.2.1
  • Jetpack4.3,L4T版本r32.3.1
  • Jetpack4.4,L4T版本r32.4.3
  • Jetpack4.4.1,L4T版本r32.4.4
  • Jetpack4.5,L4T版本r32.5
  • Jetpack4.5.1,L4T版本r32.5.1
  • Jetpack4.6,L4T版本r32.6.1
  • Jetpack4.6.1,L4T版本r32.7.1
  • Jetpack4.6.2,L4T版本r32.7.2
  • Jetpack4.6.3,L4T版本r32.7.3
  • Jetpack5.0.1DP,L4T版本r34.1.1
  • Jetpack5.0.2, L4T版本r35.1
  • Jetpack5.1, L4T版本r35.2.1
  • Jetpack5.1.1, L4T版本r35.3.1
  • Jetpack5.1.2, L4T版本r35.4.1
  • Jetpack5.1.3, L4T版本r35.5

1.2 查看当前L4T版本

首先查看当前L4T版本,尽量使用同一版本进行替换。

cat /etc/nv_tegra_release

如显示:

# R32 (release), REVISION: 4.3......

则表示当前版本为32.4.3。

2 HOST开发环境准备

以下操作均为在HOST PC进行。

2.1 编译工具链

  • Jetpack4.x

请参考这个链接安装编译工具链。

  • Jetpack5.x

请参考这个链接安装编译工具链。

2.2 L4T源码和Rootfs

首先使用SDK Manager在HOST PC上面下载对应的Linux_for_Tegra开发包。

可以通过SDK Manager或者直接下载两种方式来获得源码。具体参考官方文档,此处不再赘述。我推荐直接下载的方式。

使用SDK Manager时同步代码采用如下指令:

- Jetpack4.2.2

./source_sync.sh -t tegra-l4t-r32.2.1

- Jetpack4.3

./source_sync.sh -t tegra-l4t-r32.3.1

- Jetpack4.4

./source_sync.sh -t tegra-l4t-r32.4.3

- Jetpack4.4.1

./source_sync.sh -t tegra-l4t-r32.4.4

- Jetpack4.5

./source_sync.sh -t tegra-l4t-r32.5

- Jetpack4.5.1

./source_sync.sh -t tegra-l4t-r32.5.1

- Jetpack4.6

./source_sync.sh -t tegra-l4t-r32.6.1

- Jetpack4.6.1

./source_sync.sh -t tegra-l4t-r32.7.1

- Jetpack4.6.2

Nvidia did not push sources to nv-tegra for this 32.7.2 release because there have been no changes in the kernel and DTS compared to 32.7.1 release.

- Jetpack4.6.3

./source_sync.sh -t tegra-l4t-r32.7.3

- Jetpack5.0.1 DP

./source_sync.sh -t jetson_34.1.1

- Jetpack5.0.2

./source_sync.sh -t jetson_35.1

- Jetpack5.1

./source_sync.sh -t jetson_35.2.1

- Jetpack5.1.1

./source_sync.sh -t jetson_35.3.1

- Jetpack5.1.2

./source_sync.sh -t jetson_35.4.1

- Jetpack5.1.3

./source_sync.sh -t jetson_35.5

2.3 配置开发环境

以下步骤假设SDK安装目录为<TOPDIR>,源代码在$L4T_DIR/sources目录。

export TOP_DIR=<absolute path to top dir accroding to your jetpack version and board name;for example /home/xumm/nvidia/nvidia_sdk/JetPack_4.5_Linux_JETSON_XAVIER_NX_DEVKIT/>

  • 通用部分

export L4T_DIR=$TOP_DIR/Linux_for_Tegra

export LOCALVERSION=-tegra

export LDK_ROOTFS_DIR=$TOP_DIR/Linux_for_Tegra/rootfs

export ARCH=arm64

export TEGRA_KERNEL_OUT=$L4T_DIR/sources/kernel/out_kernel

export KERNEL_PATH=$L4T_DIR/sources/kernel/out_kernel

export NVIDIA_PATH=$L4T_DIR/sources/kernel/nvidia

export NANO_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t210/

export TX2_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t18x

export XAVIER_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t19x

export ORIN_DTS_PATH=$L4T_DIR/sources/hardware/nvidia/platform/t23x

  • Jetpack 4.x

export CROSS_COMPILE=aarch64-linux-gnu-

export CROSS32CC=arm-linux-gnueabihf-gcc

export COMMON_DTS_PATH=$TEGRA_KERNEL_OUT/arch/arm64/boot/dts/

  • Jetpack 5.x

export CROSS_COMPILE_AARCH64_PATH=$HOME/l4t-gcc

export CROSS_COMPILE_AARCH64=$HOME/l4t-gcc/bin/aarch64-buildroot-linux-gnu-

export CROSS_COMPILE=$CROSS_COMPILE_AARCH64

export COMMON_DTS_PATH=$TEGRA_KERNEL_OUT/arch/arm64/boot/dts/nvidia

3 下载我们的bsp包

cd $L4T_DIR

git clone https://github.com/veyeimaging/nvidia_jetson_veye_bsp.git

export RELEASE_PACK_DIR=$L4T_DIR/nvidia_jetson_veye_bsp

4 编译kernel

对于Jetpack4.x版本以及在Jetpack5.x版本下使用MV系列相机的,需要编译kernel。

4.1 MV系列相机的patch包

对于MV系列相机,除了在linux系统中增加了摄像头的驱动,我们还增加了一个内核补丁——veye_mv_l4t_[version].patch。

这个patch具备两个功能:

  1. 增加了黑白相机的Y10和Y12两种数据格式的支持。
  2. 增加了trigger模式的支持。

这个补丁包对于VEYE系列和CS系列相机,可以不使用。

cd $L4T_DIR/sources/kernel/

patch -p1 < [path to]veye_mv_l4t_[version].patch

4.2 对于Jetpack4.x,将camera驱动编译进Image

4.2.1 patch代码

cp $RELEASE_PACK_DIR/drivers_source/cam_drv_src/* $NVIDIA_PATH/drivers/media/i2c/

cp $RELEASE_PACK_DIR/drivers_source/kernel_veyecam_config_<l4t_version> $L4T_DIR/sources/kernel/kernel-4.9/arch/arm64/configs/tegra_veyecam_defconfig

4.2.2 修改Kconfig和Makefile

手动修改$NVIDIA_PATH/drivers/media/i2c/目录下的Kconfig和Makefile,增加对应camera驱动的编译选项。

4.2.3 编译

cd $L4T_DIR/sources/kernel/kernel-4.9/

make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_veyecam_defconfig

make ARCH=arm64 O=$TEGRA_KERNEL_OUT Image -j4

4.3 对于Jetpack5.x,无需将camera驱动编译进Image

4.3.1 编译

cd $L4T_DIR/sources/

./nvbuild.sh -o $TEGRA_KERNEL_OUT

如果没有找到此脚本:

nvbuild.sh is only included in the kernel_src.tbz2 tar file that is part of public_sources.tbz2. If the kernel sources were synced from the Git server, you need to manually copy nvbuild.sh from the tar file.

4.4 编译完成

编译完成的Image文件在:

$TEGRA_KERNEL_OUT/arch/arm64/boot/Image

可以用于整体烧写,也可以用于动态升级。

以下用于整体烧写

cp $TEGRA_KERNEL_OUT/arch/arm64/boot/Image $L4T_DIR/kernel/ -f

  • 对于xavier和Orin,需要进行签名

cd $L4T_DIR

./l4t_sign_image.sh --file kernel/Image --chip 0x19

5 编译modules(Jetpack5.x)

Jetpack5.x以后的版本,可以直接以modules方式编译驱动,得到ko文件。推荐直接在Jetson Board上面编译驱动。

cd $RELEASE_PACK_DIR/drivers_source/cam_drv_src/

make

6 编译DTS

首先需要patch代码。

6.1 Nano

cp $RELEASE_PACK_DIR/Nano/JetPack_<ver>_Linux_JETSON_NANO_DEVKIT/dts\ dtb/common/t210/* -r $NANO_DTS_PATH/

For <camera model>

cp $RELEASE_PACK_DIR/Nano/JetPack_<ver>_Linux_JETSON_NANO_DEVKIT/dts\ dtb/<camera model>/tegra210-porg-plugin-manager.dtsi -r $NANO_DTS_PATH/porg/kernel-dts/porg-plugin-manager

6.2 TX2

cp $RELEASE_PACK_DIR/TX2/JetPack_<ver>_Linux_JETSON_TX2/dts\ dtb/common/t18x/* -r $TX2_DTS_PATH/

For <camera model>

cp $RELEASE_PACK_DIR/TX2/JetPack_<ver>_Linux_JETSON_TX2/dts\ dtb/<camera model>/tegra186-quill-p3310-1000-a00-00-base.dts $TX2_DTS_PATH/quill/kernel-dts/

cp $RELEASE_PACK_DIR/TX2/JetPack_<ver>_Linux_JETSON_TX2/dts\ dtb/<camera model>/tegra186-p3636-0001-p3509-0000-a01.dts $TX2_DTS_PATH/lanai/kernel-dts

6.3 AGX Xavier

cp $RELEASE_PACK_DIR/AGX-Xaviar/JetPack_<ver>_Linux_JETSON_AGX_XAVIER/dts\ dtb/common/t19x/* -r $XAVIER_DTS_PATH/

For <camera model>

cp $RELEASE_PACK_DIR/AGX-Xaviar/JetPack_<ver>_Linux_JETSON_AGX_XAVIER/dts\ dtb/<camera model>/tegra194-p2888-0001-p2822-0000.dts $XAVIER_DTS_PATH/galen/kernel-dts/

6.4 Xavier NX

cp $RELEASE_PACK_DIR/Xavier-NX/JetPack_<ver>_Linux_JETSON_XAVIER_NX_DEVKIT/dts\ dtb/common/t19x/* -r $XAVIER_DTS_PATH/

For <camera model>

cp $RELEASE_PACK_DIR/Xavier-NX/JetPack_<ver>_Linux_JETSON_XAVIER_NX_DEVKIT/dts\ dtb/<camera model>/tegra194-p3509-0000-a00.dtsi $XAVIER_DTS_PATH/jakku/kernel-dts/common/

6.5 Orin

cp $RELEASE_PACK_DIR/Orin/JetPack_<ver>_Linux_JETSON_ORIN_TARGETS/dts\ dtb/common/t23x/* -r $ORIN_DTS_PATH/

For <camera model>

cp $RELEASE_PACK_DIR/Orin/JetPack_<ver>_Linux_JETSON_ORIN_TARGETS/dts\ dtb/<camera model>/tegra234-p3737-camera-modules.dtsi $ORIN_DTS_PATH/concord/kernel-dts/cvb/

cp $RELEASE_PACK_DIR/Orin/JetPack_<ver>_Linux_JETSON_ORIN_TARGETS/dts\ dtb/<camera model>/tegra234-p3768-0000-a0.dtsi $ORIN_DTS_PATH/p3768/kernel-dts/cvb

6.6 编译

  • For Jetpack4.X

export COMMON_DTS_PATH=$TEGRA_KERNEL_OUT/arch/arm64/boot/dts

cd $L4T_DIR/sources/kernel/kernel-4.9/

  • For Jetpack5.X

export COMMON_DTS_PATH=$TEGRA_KERNEL_OUT/arch/arm64/boot/dts/nvidia

cd $L4T_DIR/sources/kernel/kernel-5.10/

make ARCH=arm64 O=$TEGRA_KERNEL_OUT dtbs

You can get the compiled DTB file in the following path.

6.6.1 Nano

$COMMON_DTS_PATH/tegra210-p3448-0000-p3449-0000-a02.dtb

$COMMON_DTS_PATH/tegra210-p3448-0000-p3449-0000-b00.dtb

$COMMON_DTS_PATH/tegra210-p3448-0003-p3542-0000.dtb

6.6.2 TX2

$COMMON_DTS_PATH/tegra186-quill-p3310-1000-c03-00-base.dtb

6.6.3 TX2 NX(p3509-0000 carrier board)

$COMMON_DTS_PATH/tegra186-p3636-0001-p3509-0000-a01.dtb

6.6.4 AGX XAVIER

$COMMON_DTS_PATH/tegra194-p2888-0001-p2822-0000.dtb

6.6.5 XAVIER NX

$COMMON_DTS_PATH/tegra194-p3668-all-p3509-0000.dtb

6.6.6 AGX Orin

$COMMON_DTS_PATH/tegra234-p3701-0000-p3737-0000.dtb

6.6.7 Orin Nano

$COMMON_DTS_PATH/tegra234-p3767-0003-p3768-0000-a0.dtb

$COMMON_DTS_PATH/tegra234-p3767-0004-p3768-0000-a0.dtb

6.6.8 Orin NX

$COMMON_DTS_PATH/tegra234-p3767-0000-p3768-0000-a0.dtb

$COMMON_DTS_PATH/tegra234-p3767-0001-p3768-0000-a0.dtb