TX2安装Intel-D435驱动
项目: 基于ROS的导航功能小车
计算机模块:NVIDIA Jetson TX2 刷机:Jetpack 4.3 (若使用摄像头D435,不推荐)
查看内核版本的指令: uname -r
返回信息:4.9.140-tegra
查看L4T版本: $ cat /etc/nv_tegra_release | head -n 1
返回信息:#R32 (release), REVISION:3.1
摄像头:Intel Realsense D435
link:https://github.com/IntelRealSense/librealsense
雷达: 思岚科技 RPLIDAR A3
友情提示以及反思:
在刷机之前,还是先了解一下所刷的镜像内核,能不能支持驱动,如果有直接支持的内核还是选择合适的Jetpack版本刷机。比如这里的Intel Realsense D435 动态内核驱动包,支持的Ubuntu的内核版本: 4.4, 4.10, 4.13, 4.15, 4.18*, 5.0* and 5.3*。
The Realsense DKMS kernel drivers package (librealsense2-dkms) supports Ubuntu LTS kernels 4.4, 4.8, 4.10, 4.13, 4.15, 4.18* 5.0* and 5.3*.
由于内核版本为:4.9.140 无法直接安装D435官方提供的驱动包。D435通过USB3.0口与TX2连接,想要能够使得TX2成功识别出D435,需要在内核代码中加入设备ID的预置代码。(给内核打补丁并重新编译内核。)
参考博客如下,博客还给出了内核源码下载地址,以及编译方法的链接:
https://blog.csdn.net/SIR_wkp/article/details/103254051
下面这篇博客根据JetsonHack给Xavier打补丁的代码,给出了TX2版本
(TX2: Jetpack4.2+kernel4.9.140+librealsense v2.22)(所以如果使用Ubuntu18可以刷机选择的Jetpack版本可以选择4.2)
https://blog.csdn.net/TengYun_zhang/article/details/90452856
Github地址:https://github.com/Tengyun-Mo/buildLibrealsense2TX2
由于L4T版本与上述博客的不同,修改了/sripts/getKernelSourcesNoGUI.sh代码。
执行:
$ ./buildPatchedKernel.sh
补丁文件基本了解:
@@:补丁块,帮助补丁工具定位到打补丁的位置(需要加代码与删除代码的位置)。
+++:表示改后的文件
---:表示原文件
+:增加的代码
-: 减少的代码
link:https://zhuanlan.zhihu.com/p/44422762
找到第二块补丁的代码并和kernel 4.9的源码做了对比。
Kernel 4.9源码如下:
static void uvc_video_decode_bulk(struct urb *urb, struct uvc_streaming *stream,struct uvc_buffer *buf)
{
u8 *mem;
int len, ret;
/*
* Ignore ZLPs if they're not part of a frame, otherwise process them
* to trigger the end of payload detection.
*/
if (urb->actual_length == 0 && stream->bulk.header_size == 0)
return;
mem = urb->transfer_buffer;
len = urb->actual_length;
stream->bulk.payload_size += len;
/* If the URB is the first of its payload, decode and save the
* header.
*/
if (stream->bulk.header_size == 0 && !stream->bulk.skip_payload) {
do {
ret = uvc_video_decode_start(stream, buf, mem, len);
if (ret == -EAGAIN)
buf = uvc_queue_next_buffer(&stream->queue,
buf);
} while (ret == -EAGAIN);
/* If an error occurred skip the rest of the payload. */
if (ret < 0 || buf == NULL) {
stream->bulk.skip_payload = 1;
} else {
memcpy(stream->bulk.header, mem, ret);
stream->bulk.header_size = ret;
mem += ret;
len -= ret;
}
}
/* The buffer queue might have been cancelled while a bulk transfer
* was in progress, so we can reach here with buf equal to NULL. Make
* sure buf is never dereferenced if NULL.
*/
/* Process video data. */
if (!stream->bulk.skip_payload && buf != NULL)
uvc_video_decode_data(stream, buf, mem, len);
/* Detect the payload end by a URB smaller than the maximum size (or
* a payload size equal to the maximum) and process the header again.
*/
if (urb->actual_length < urb->transfer_buffer_length ||
stream->bulk.payload_size >= stream->bulk.max_payload_size) {
if (!stream->bulk.skip_payload && buf != NULL) {
uvc_video_decode_end(stream, buf, stream->bulk.header,
stream->bulk.payload_size);
if (buf->state == UVC_BUF_STATE_READY)
buf = uvc_queue_next_buffer(&stream->queue,
buf);
}
stream->bulk.header_size = 0;
stream->bulk.skip_payload = 0;
stream->bulk.payload_size = 0;
}
}
报错的地方在 uvcvideo.h的补丁部分:
发现是源码与补丁不一致的地方:

解决方案
在github上找到了jetpack4.3 对应的L4T版本:R32 (release), REVISION:3.1 的打补丁的方法,在补丁里没有了上述图片补丁中的 “+-define UVC_MAX_PACKETS” 的操作。
Link:https://github.com/rsx-utoronto/buildLibrealsense2TX2
注意 librealsense 一定要去官网看看,改成最新的版本,我当时改的是v2.37.0
浙公网安备 33010602011771号