Skip to content

Commit 1feabac

Browse files
authored
PR #14442 from remibettan: patches script for jetson - replacing uvcvideo in its relevant place
2 parents defc7dd + b9f97b2 commit 1feabac

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

scripts/patch-realsense-ubuntu-L4T.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ else
7373
exit;
7474
fi
7575

76+
# setting UBUNTU_CODENAME
7677
[[ -f /etc/os-release ]] && eval $(cat /etc/os-release|grep UBUNTU_CODENAME=)
7778

7879
PATCHES_REV=""
@@ -191,21 +192,6 @@ else
191192
make ARCH=arm64 defconfig -j$(($(nproc)-1))
192193
fi
193194

194-
#Reuse existing module.symver
195-
kernel_ver=`uname -r`
196-
LINUX_HEADERS_NAME="linux-headers-${kernel_ver}-ubuntu18.04_aarch64"
197-
if [[ "$PATCHES_REV" = "5.0.2" ]]; then
198-
LINUX_HEADERS_NAME="linux-headers-${kernel_ver}-ubuntu20.04_aarch64"
199-
fi
200-
if [[ "$PATCHES_REV" = "6.0" ]]; then
201-
LINUX_HEADERS_NAME="linux-headers-${kernel_ver}-ubuntu22.04_aarch64"
202-
fi
203-
if [[ "$PATCHES_REV" = "7.0" ]]; then
204-
LINUX_HEADERS_NAME="linux-headers-${kernel_ver}-ubuntu24.04_aarch64"
205-
fi
206-
207-
export KBUILD_EXTRA_SYMBOLS="/lib/modules/${kernel_ver}/build/Module.symvers"
208-
209195
#Jetpack prior to 4.4.1 requires manual reconfiguration of kernel
210196
if [[ "$PATCHES_REV" = "4.4" ]]; then
211197
echo -e "\e[32mUpdate the kernel tree to support HID IMU sensors\e[0m"
@@ -214,8 +200,6 @@ if [[ "$PATCHES_REV" = "4.4" ]]; then
214200
sed -i '/CONFIG_HID_SENSOR_IIO_COMMON/c\CONFIG_HID_SENSOR_IIO_COMMON=m\nCONFIG_HID_SENSOR_IIO_TRIGGER=m' .config
215201
fi
216202

217-
make ARCH=arm64 prepare modules_prepare LOCALVERSION='' -j$(($(nproc)-1))
218-
219203
#Remove previously applied patches
220204
git reset --hard
221205
echo -e "\e[32mApply Librealsense Kernel Patches\e[0m"
@@ -237,6 +221,13 @@ else
237221
sed -i s'/1.1.1/1.1.1-realsense/'g ./drivers/media/usb/uvc/uvcvideo.h
238222
fi
239223

224+
#Building modules_prepare, which:
225+
#1. Prepares kernel headers for building external modules
226+
#2. Generates Module.symvers if it doesn’t already exist.
227+
# Extract the local version suffix from the running kernel (e.g., "-tegra" or "")
228+
KERNEL_LOCALVERSION="$(uname -r | sed -E 's/^[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?//')"
229+
make ARCH=arm64 prepare modules_prepare LOCALVERSION="${KERNEL_LOCALVERSION}" -j$(($(nproc)-1))
230+
240231
echo -e "\e[32mCompiling uvcvideo kernel module\e[0m"
241232
#sudo -s make -j -C $KBASE M=$KBASE/drivers/media/usb/uvc/ modules
242233
make -j$(($(nproc)-1)) ARCH=arm64 M=drivers/media/usb/uvc/ modules
@@ -298,9 +289,17 @@ fi
298289
# update kernel module dependencies
299290
sudo depmod
300291

292+
# special attention to uvcvideo because it is one of the files that is set to /lib/modules/`uname -r`/updates/ folder
293+
# when using our jetson drivers instructions
294+
UVCVIDEO_PATH=$(modinfo -F filename uvcvideo)
295+
if [[ -z "$UVCVIDEO_PATH" ]]; then
296+
UVCVIDEO_PATH="/lib/modules/$(uname -r)/updates/uvcvideo.ko"
297+
echo -e "\e[33mCould not find the uvcvideo kernel module.\nIt will be loaded into updates folder: $UVCVIDEO_PATH.\e[0m"
298+
fi
299+
301300
echo -e "\e[32mInsert the modified kernel modules\e[0m"
302301
if version_lt "$PATCHES_REV" "6.0"; then
303-
try_module_insert uvcvideo ~/${TEGRA_TAG}-uvcvideo.ko /lib/modules/`uname -r`/kernel/drivers/media/usb/uvc/uvcvideo.ko
302+
try_module_insert uvcvideo ~/${TEGRA_TAG}-uvcvideo.ko $UVCVIDEO_PATH
304303
try_load_module uvcvideo
305304
try_load_module hid-sensor-gyro-3d
306305
try_load_module hid-sensor-accel-3d

0 commit comments

Comments
 (0)