VEYE CS Camera source for Jetson/zh

From wiki_veye
Jump to navigation Jump to search

English

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

1 概述

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

1.2 查看当前L4T版本

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

cat /etc/nv_tegra_release

如显示:

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

则表示当前版本为32.4.3。

2 HOST开发环境准备

  • 编译工具链

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

  • 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

  • 配置开发环境

以下步骤假设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 CROSS_COMPILE=aarch64-linux-gnu-

export CROSS32CC=arm-linux-gnueabihf-gcc

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

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

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

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

4.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 编译

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

编译完成的Image文件在:

$TEGRA_KERNEL_OUT/arch/arm64/boot/Image

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

以下用于整体烧写

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

  • 对于xavier,进行签名

cd $L4T_DIR

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

5 编译DTS

首先需要patch代码。

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

5.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/

5.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/

5.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/

5.5 编译

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

make ARCH=arm64 O=$TEGRA_KERNEL_OUT dtbs

编译完成的dtb文件路径如下所示,可手动升级或整体升级。

5.5.1 Nano

cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra210-p3448-0000-p3449-0000-a02.dtb $L4T_DIR/kernel/dtb/

cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra210-p3448-0000-p3449-0000-b00.dtb $L4T_DIR/kernel/dtb/

cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra210-p3448-0003-p3542-0000.dtb $L4T_DIR/kernel/dtb/

5.5.2 TX2

cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb $L4T_DIR/kernel/dtb/

5.5.3 TX2 NX(p3509-0000 carrier board)

cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra186-p3636-0001-p3509-0000-a01.dtb $L4T_DIR/kernel/dtb/

5.5.4 AGX XAVIER

cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra194-p2888-0001-p2822-0000.dtb $L4T_DIR/kernel/dtb/

5.5.5 XAVIER NX

cp $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra194-p3668-all-p3509-0000.dtb $L4T_DIR/kernel/dtb/