IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.42k stars 4.8k forks source link

Kernel Patch not working on ubuntu 5.0.0-23-generic #13052

Open devkrish23 opened 1 week ago

devkrish23 commented 1 week ago

Required Info
Camera Model { D435I }
Firmware Version (05.12.07.150)
Operating System & Version Ubuntu 18.04.5 LTS
Kernel Version (Linux Only) 5.0.0-23-generic
Platform PC
SDK Version 2.38.1

Issue Description

I am trying to patch the realsense on ubuntu platform. However i am facing issues with the bionic repo, the support for bionic doesn't seem to exists anymore.

Step1: git clone https://github.com/IntelRealSense/librealsense.git Step2: git checkout v2.38.1 Step3: sudo apt install libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at Step4: ./scripts/setup_udev_rules.sh step5: Apply patch kernel modules ./scripts/patch-realsense-ubuntu-lts.sh

Error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
bc is already the newest version (1.07.1-2).
build-essential is already the newest version (12.4ubuntu1).
git is already the newest version (1:2.17.1-1ubuntu0.18).
linux-headers-generic is already the newest version (4.15.0.213.196).
The following packages were automatically installed and are no longer required:
  apport-symptoms gir1.2-dbusmenu-glib-0.4 gir1.2-dee-1.0 gir1.2-unity-5.0 python3-debconf
  python3-debian python3-systemd update-notifier-common
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Package required libusb-1.0-0-dev:  - found
Package required libssl-dev:  - found
Create patches workspace in ubuntu-bionic-5 folder

Package required libelf-dev:  - found
Package required elfutils:  - found
Package required bison:  - found
Package required flex:  - found
Initialized empty Git repository in /home/bedgear/Downloads/librealsense/ubuntu-bionic-5/.git/
fatal: repository 'https://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git/' not found
Fetching Ubuntu LTS tag   to the local kernel sources folder
fatal: You need to specify a tag name.

After checking more, it seems support for bionic has been suspended and i was not able to find this repo; https://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git/' has this migrated somewhere else or is there any workaround?

MartyG-RealSense commented 1 week ago

Hi @devkrish23 Bionic is Ubuntu 18.04, which is still supported by the librealsense SDK.

It is possible to use a source code build of the librealsense SDK without applying a kernel patch script, though there may be unpredictable consequences in regards to stability.

Alternartively, instead of building 2.38.1 with git clone, you could instead download a zipped source code folder of 2.38.1, extract it and build from that with CMake.

https://github.com/IntelRealSense/librealsense/releases/tag/v2.38.1

If the flag -DFORCE_RSUSB_BACKEND=TRUE is included in the CMake build instruction then librealsense will bypass the kernel, avoiding the need to apply a patch script, and it will also not be dependent on a particular Linux version.

Instructions for an RSUSB build can be found at https://github.com/IntelRealSense/librealsense/issues/9931#issuecomment-964289692

devkrish23 commented 1 week ago

Hi @MartyG-RealSense, thank you for the response.

So, we are using Ubuntu 18.04.5 LTS that was shipped with 5.4 kernel. Since, this kernel was not supported by realsense we had to downgrade our kernel version to 5.0.0-23-generic. We tried using the camera (D435I x2), however we were experiencing a lot of issues, such as

XIOCTL (vidioc_s_ctrl) failed last error: connection timed out, NULL pointer passed for argument 'frame_ref', get_xu(ctrl=1) failed! last error: device or resource busy

Hence we resorted to patching our system as instructed in librealsense documentation and it worked fine few years back.

But now, when i am trying to patch the system, it fails at the following line kernel_git_tag=$(git ls-remote --tags origin | grep "${kernel_full_num}\." | grep '[^^{}]$' | tail -n 1 | awk -F/ '{print $NF}') in script patch-realsense-ubuntu-lts.sh

MartyG-RealSense commented 1 week ago

Is it possible for you to install librealsense from packages instead of building from source code? A package build of the SDK supports kernel 5.4 and you do not need to apply a patch script as the kernel patch is bundled within the packages.

https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md

image

MartyG-RealSense commented 4 days ago

Hi @devkrish23 Do you require further assistance with this case, please? Thanks!

devkrish23 commented 3 days ago

Hi @devkrish23 Do you require further assistance with this case, please? Thanks!

Hello, i am testing this solution with 5.4 kernel. Will update you in a day or two. Thank you!

MartyG-RealSense commented 3 days ago

You are very welcome. I look forward to your next report. Good luck!

devkrish23 commented 1 day ago

I did try your solution and started a fresh ubuntu install 18.0.4 with 5.4.0-150 kernel as mentioned in https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md I then performed stress testing on librealsense and intel realsense cameras. The cameras failed for 1 in 1500 times during picture capture. Do you think there is any patching issue or you suspect something else?

MartyG-RealSense commented 23 hours ago

Your system's setup looks correct and appropriate for librealsense 2.38.1 (Ubuntu 18.04, kernel 5.4, firmware 5.12.7.100).

Have you tried the suggestion earlier in this discussion at https://github.com/IntelRealSense/librealsense/issues/13052#issuecomment-2176458224 to build librealsense from source code with RSUSB = true in order to test whether the kernel is a factor when a failure occurs, since an RSUSB build of librealsense bypasses the kernel and does not require a patch.

devkrish23 commented 17 hours ago

My new ubuntu 18.04 machine has following specifications: kernel: 5.4 firmware: 5.16.0.1 SDK: 2.55.1

MartyG-RealSense commented 17 hours ago

A couple of possible paths that you could consider if an RSUSB = true source code build of librealsense is not suitable for your project are:

  1. Use a much more recent kernel with Ubuntu 18.04. My research suggests that up to kernel 5.13 could be used with 18.04.

  2. Disregard the stress test results, as such a test may not reflect the real-world circumstances that a program will be used in if it will not be capturing 1500 times in quick succession during actual use.