|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (C) 2025 Intel Corporation |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +test(){ |
| 8 | + rm -rf wget* |
| 9 | + sudo rm /usr/share/keyrings/oneapi-archive-keyring.gpg |
| 10 | + sudo rm /etc/apt/sources.list.d/oneAPI.list |
| 11 | + sudo rm /etc/apt/preferences.d/oneapi |
| 12 | + sudo rm /usr/share/keyrings/ros-archive-keyring.gpg |
| 13 | + lsmod | grep intel_ipu6 |
| 14 | + sudo rmmod intel_ipu6 intel_ipu6_psys intel_ipu6_isys |
| 15 | + sudo apt purge ros-jazzy-librealsense2-tools |
| 16 | +} |
| 17 | + |
| 18 | +verify_os() { |
| 19 | + echo -e "\n# Verifying operating system" |
| 20 | + if [ ! -e /etc/os-release ]; then |
| 21 | + echo "Error: /etc/os-release file not found" |
| 22 | + exit 1 |
| 23 | + fi |
| 24 | + VERSION_CODENAME=$(grep -E '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2- | tr -d '"') |
| 25 | +} |
| 26 | + |
| 27 | +setup_eci_ros() { |
| 28 | + echo -e "Setting up ECI apt repository..." |
| 29 | + sudo gpg --output /etc/apt/trusted.gpg.d/oneapi-archive-keyring.gpg --dearmor GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB |
| 30 | + sudo gpg --output /usr/share/keyrings/eci-archive-keyring.gpg --dearmor GPG-PUB-KEY-INTEL-ECI.gpg |
| 31 | + verify_os |
| 32 | + echo "deb [signed-by=/usr/share/keyrings/eci-archive-keyring.gpg] https://eci.intel.com/repos/${VERSION_CODENAME} isar main" | sudo tee /etc/apt/sources.list.d/eci.list |
| 33 | + echo "deb-src [signed-by=/usr/share/keyrings/eci-archive-keyring.gpg] https://eci.intel.com/repos/${VERSION_CODENAME} isar main" | sudo tee -a /etc/apt/sources.list.d/eci.list |
| 34 | + sudo bash -c 'echo -e "Package: *\nPin: origin eci.intel.com\nPin-Priority: 1000" > /etc/apt/preferences.d/isar' |
| 35 | + sudo bash -c 'echo -e "\nPackage: libflann*\nPin: version 1.19.*\nPin-Priority: -1\n\nPackage: flann*\nPin: version 1.19.*\nPin-Priority: -1" >> /etc/apt/preferences.d/isar' |
| 36 | + echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list |
| 37 | + sudo bash -c 'echo -e "Package: intel-oneapi-runtime-*\nPin: version 2024.1.*\nPin-Priority: 1001" > /etc/apt/preferences.d/oneapi' |
| 38 | + # add signed entry to APT sources and configure the APT client to use OpenVINO repository: |
| 39 | + sudo bash -c 'echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/openvino/2023 ubuntu22 main" > /etc/apt/sources.list.d/intel-openvino-2023.list' |
| 40 | + sudo bash -c 'echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/openvino/2024 ubuntu22 main" > /etc/apt/sources.list.d/intel-openvino-2024.list' |
| 41 | + echo -e "Setting up ROS Humble apt repository..." |
| 42 | + # download the key to system keyring |
| 43 | + sudo -E wget -O- https://raw.githubusercontent.com/ros/rosdistro/master/ros.key | sudo tee /usr/share/keyrings/ros-archive-keyring.gpg > /dev/null |
| 44 | + # add signed entry to APT sources and configure the APT client to use ROS repository: |
| 45 | + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu ${VERSION_CODENAME} main" | sudo tee /etc/apt/sources.list.d/ros2.list |
| 46 | + echo "Setting up ROS Humble apt repository..." |
| 47 | + sudo apt update |
| 48 | +} |
| 49 | + |
| 50 | +enable_igc() { |
| 51 | + # Update GRUB configuration |
| 52 | + sudo sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/"$/ i915.enable_guc=3"/' /etc/default/grub.d/09_eci-default.cfg |
| 53 | + sudo update-grub |
| 54 | + # Install linux-firmware |
| 55 | + sudo apt install -y linux-firmware |
| 56 | + # Prompt to reboot the system |
| 57 | + echo "Please reboot the system and rerun the script." |
| 58 | + |
| 59 | + # Check for i915 messages in dmesg after reboot |
| 60 | + if dmesg | grep -q 'i915.*GUC: submission enabled'; then |
| 61 | + echo "i915 messages found, no need to reboot." |
| 62 | + else |
| 63 | + # Reinstall linux-firmware and prompt to reboot again |
| 64 | + sudo apt install -y linux-firmware |
| 65 | + echo "Please reboot the system and rerun the script." |
| 66 | + fi |
| 67 | +} |
| 68 | + |
| 69 | +install_ipu6() { |
| 70 | + echo -e "\n Install Linux headers and intel_ipu6 DKMS Debian packages.." |
| 71 | + sudo apt install linux-firmware |
| 72 | + sudo apt install -y pahole "linux-headers-$(uname -r)" intel-ipu6-dkms |
| 73 | + |
| 74 | + # Check DKMS status |
| 75 | + DKMS_STATUS="$(dkms status | grep 'ipu6-drivers')" # Quote the assignment |
| 76 | + |
| 77 | + if echo "$DKMS_STATUS" | grep -q 'installed'; then |
| 78 | + echo "DKMS driver installed successfully." |
| 79 | + sudo usermod -a -G video "$USER" |
| 80 | + sudo usermod -a -G render "$USER" |
| 81 | + else |
| 82 | + echo "DKMS driver install incomplete. Attempting to force install the DKMS driver." |
| 83 | + # Force install the DKMS driver |
| 84 | + sudo dkms install --force ipu6-drivers/20240118+iotgipu6-0eci* |
| 85 | + |
| 86 | + # Re-check DKMS status |
| 87 | + DKMS_STATUS="$(dkms status | grep 'ipu6-drivers')" # Quote again |
| 88 | + |
| 89 | + if echo "$DKMS_STATUS" | grep -q 'installed'; then |
| 90 | + echo "DKMS driver installed successfully after force install." |
| 91 | + sudo usermod -a -G video "$USER" |
| 92 | + sudo usermod -a -G render "$USER" |
| 93 | + else |
| 94 | + echo "DKMS driver install failed. Please check the installation logs and try again." |
| 95 | + return 1 |
| 96 | + fi |
| 97 | + fi |
| 98 | +} |
| 99 | + |
| 100 | +ros2_setup() { |
| 101 | + echo "Enable ROS2 Intel® RealSense™ Depth Camera D457 GMSL" |
| 102 | + echo "Installing ROS2 Jazzy Jalisco for Ubuntu 24.04" |
| 103 | + |
| 104 | + # Install ros-jazzy-librealsense2-tools |
| 105 | + if sudo apt install -y ros-jazzy-librealsense2-tools; then |
| 106 | + echo "ros-jazzy-librealsense2-tools installed successfully." |
| 107 | + return |
| 108 | + fi |
| 109 | + |
| 110 | + echo "Encountered dependency issue. Attempting to resolve..." |
| 111 | + check_available_versions |
| 112 | + install_highest_version |
| 113 | + |
| 114 | + # Retry installing ros-jazzy-librealsense2-tools |
| 115 | + if ! sudo apt install -y ros-jazzy-librealsense2-tools; then |
| 116 | + echo "Failed to install ros-jazzy-librealsense2-tools. Please check the dependencies and try again." |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | + |
| 120 | + echo "Ensure system-udevd daemon Intel® RealSense™ ROS2 rules exist" |
| 121 | + # cat /lib/udev/rules.d/99-realsense-d4xx-mipi-dfu.rules |
| 122 | +} |
| 123 | + |
| 124 | +check_available_versions() { |
| 125 | + echo "Checking available versions of ros-jazzy-librealsense2..." |
| 126 | + apt-cache policy ros-jazzy-librealsense2 |
| 127 | +} |
| 128 | + |
| 129 | +install_highest_version() { |
| 130 | + REQUIRED_VERSION=$(apt-cache madison ros-jazzy-librealsense2 | awk '{print $3}' | sort -V | tail -n 1) |
| 131 | + echo "Highest available version of ros-jazzy-librealsense2 is $REQUIRED_VERSION" |
| 132 | + |
| 133 | + echo "Installing ros-jazzy-librealsense2 version $REQUIRED_VERSION..." |
| 134 | + if ! sudo apt install -y "ros-jazzy-librealsense2=$REQUIRED_VERSION"; then |
| 135 | + echo "Failed to install ros-jazzy-librealsense2 version $REQUIRED_VERSION. Please check the repository and try again." |
| 136 | + exit 1 |
| 137 | + fi |
| 138 | + |
| 139 | + verify_installation |
| 140 | +} |
| 141 | + |
| 142 | +verify_installation() { |
| 143 | + if dpkg -l | grep -q "ros-jazzy-librealsense2.*$REQUIRED_VERSION"; then |
| 144 | + echo "ros-jazzy-librealsense2 version $REQUIRED_VERSION installed successfully." |
| 145 | + else |
| 146 | + echo "Failed to install ros-jazzy-librealsense2 version $REQUIRED_VERSION. Please check the repository and try again." |
| 147 | + exit 1 |
| 148 | + fi |
| 149 | +} |
| 150 | + |
| 151 | +kernel_print () { |
| 152 | + sudo dmesg -n 7 |
| 153 | + sudo modprobe intel-ipu6-isys |
| 154 | + sudo dmesg | grep -e ipu6 -e d4xx -e max929 |
| 155 | + # Check dmesg for IPU6 errors |
| 156 | + if sudo dmesg | grep -q -e "FW authentication failed(-5)"; then |
| 157 | + echo "FW authentication failed(-5) error found. Please replace firmware..." |
| 158 | + exit 1 |
| 159 | + # Define the directory for cloning the repository |
| 160 | + else |
| 161 | + echo "No FW authentication error found in dmesg." |
| 162 | + fi |
| 163 | +} |
| 164 | + |
| 165 | +main() { |
| 166 | + #test |
| 167 | + setup_eci_ros |
| 168 | + install_ipu6 |
| 169 | + ros2_setup |
| 170 | + kernel_print |
| 171 | +} |
| 172 | +main |
0 commit comments