一、系统配置:
- 系统环境:Ubuntu16.04
- 内核版本:4.15.0-112-generic
D435i 驱动支持的内核有: supported kernel version (4.[4,8,10,13,15,16]]),可通过:uname -r
查看内核版本
二、驱动安装:
以下采用source code方式进行安装
(!!!注意:驱动安装过程中不要连接相机!!!)
- Make Ubuntu Up-to-date::
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
- Download/Clone librealsense github repository:
git clone https://github.com/IntelRealSense/librealsense.git
- Prepare Linux Backend and the Dev. Environment:
sudo apt-get install git libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev
sudo apt-get install libglfw3-dev
- 进入 librealsense 根目录,运行 Intel Realsense permissions script :
./scripts/setup_udev_rules.sh
- Build and apply patched kernel modules for:
./scripts/patch-realsense-ubuntu-lts.sh
这里可能会遇到一些问题:
(1)g++需要升级,按照提示依次运行以下命令即可:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update -y
sudo apt-get install g++-7 -y
(2)Applying the patched module … modprobe: ERROR: could not insert ‘videodev’: Required key not available
Failed to insert the patched module. Operation is aborted, the original module is restored
Verify that the current kernel version is aligned to the patched module version
出现此问题的原因是,Ubuntu Kernel 使用 EFI_SECURE_BOOT_SIG_ENFORCE 内核配置,这样会阻止内核载入第三方模块。解决方法如下:
- 在终端输入:
sudo apt install mokutil
sudo mokutil --disable-validation
- 执行后,终端会让你设置8-16位的密码(下一步要用,所以一定要记得设置的密码)
- 然后,重启电脑,会出现蓝屏,按下任意键进入选择界面 ,出现以下四个选项:
- Continue boot
- Change Secure Boot state
- Enroll key from disk
- Enroll hash from disk
- 选择Change Secure Boot state,接下来会提示让你输入之前的密码。
!!!注意:可能不是输入完整的密码(我的就不是),而是:Enter password character 3,意思是输入密码的第3位!!!(我是按照提示要求依次输入了密码的第3位、第6位和第1位,大家根据自己的实际情况操作) - 然后进入 Disable Secure Boot 选择界面,选择 yes,回车。
- 接下来回到最开始的界面,选择reboot,重新进入系统。
- 再次执行:
./scripts/patch-realsense-ubuntu-lts.sh
,成功。
- TM1-specific:
echo 'hid_sensor_custom' | sudo tee -a /etc/modules
- 编译librealsense2 SDK:
cd librealsense
mkdir build && cd build
cmake ..
# The default build is set to produce the core shared object and unit-tests binaries in Debug mode. Use -DCMAKE_BUILD_TYPE=Release to build with optimizations.
下面两个步骤可酌情跳过:
cmake ../ -DBUILD_EXAMPLES=true # - Builds librealsense along with the demos and tutorials
cmake ../ -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=false # - For systems without OpenGL or X11 build only textual examples
- 重新编译和安装:
sudo make uninstall && make clean && make && sudo make install
说明:The shared object will be installed in /usr/local/lib, header files in /usr/local/include.
The binary demos, tutorials and test files will be copied into /usr/local/bin.
三、测试SDK:
连接相机,新开一个终端,输入:realsense-viewer
启动即可:
看到类似画面就说明OK啦!