7373 exit ;
7474fi
7575
76+ # setting UBUNTU_CODENAME
7677[[ -f /etc/os-release ]] && eval $( cat /etc/os-release| grep UBUNTU_CODENAME=)
7778
7879PATCHES_REV=" "
@@ -191,21 +192,6 @@ else
191192 make ARCH=arm64 defconfig -j$(( $(nproc)- 1 ))
192193fi
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
210196if [[ " $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
215201fi
216202
217- make ARCH=arm64 prepare modules_prepare LOCALVERSION=' ' -j$(( $(nproc)- 1 ))
218-
219203# Remove previously applied patches
220204git reset --hard
221205echo -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
238222fi
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+
240231echo -e " \e[32mCompiling uvcvideo kernel module\e[0m"
241232# sudo -s make -j -C $KBASE M=$KBASE/drivers/media/usb/uvc/ modules
242233make -j$(( $(nproc)- 1 )) ARCH=arm64 M=drivers/media/usb/uvc/ modules
298289# update kernel module dependencies
299290sudo 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+
301300echo -e " \e[32mInsert the modified kernel modules\e[0m"
302301if 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