Skip to content

Commit b284eea

Browse files
author
Wojciech Gladysz
committed
fixed version comparison issues
1 parent 62fcd91 commit b284eea

1 file changed

Lines changed: 24 additions & 27 deletions

File tree

scripts/patch-realsense-ubuntu-L4T.sh

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ exec 2>&3
1414
function DisplayNvidiaLicense {
1515
revision=$1
1616

17-
# verify that curl is installed
18-
if ! which curl > /dev/null ; then
19-
echo "curl is not installed."
20-
echo "curl can be installed by 'sudo apt-get install curl'."
21-
exit 1
22-
fi
23-
2417
# By default referencing license agreement of JP 5.0.2
2518
license_path="https://developer.download.nvidia.com/embedded/L4T/${revision}/release/Tegra_Software_License_Agreement-Tegra-Linux.txt"
2619

@@ -34,6 +27,15 @@ function DisplayNvidiaLicense {
3427
read -t 30 -n 1 -s -r -e -p 'Press any key to continue (or wait 30 seconds..)'
3528
}
3629

30+
function version_lt {
31+
IFS='.' read -r -a v1 <<< "$1"
32+
IFS='.' read -r -a v2 <<< "$2"
33+
for i in 0 1 2; do
34+
[[ v1[i] -lt v2[i] ]] && return 0
35+
done
36+
return 1
37+
}
38+
3739
if [[ $con_dev -ne 0 ]];
3840
then
3941
echo -e "\e[32m"
@@ -107,8 +109,8 @@ esac
107109
echo -e "\e[32mL4T ${JETSON_L4T_VERSION} to use patches revision ${PATCHES_REV}\e[0m"
108110

109111
# Get the required tools to build the patched modules
110-
sudo apt-get install build-essential git libssl-dev -y
111-
if [[ "$PATCHES_REV" < "6.0" ]]; then
112+
sudo apt-get install build-essential git libssl-dev curl -y
113+
if version_lt "$PATCHES_REV" "6.0"; then
112114
# Get the linux kernel repo, extract the L4T tag
113115
echo -e "\e[32mRetrieve the corresponding L4T git tag the kernel source tree\e[0m"
114116
l4t_gh_dir=../linux-${KERNEL_RELEASE}-source-tree
@@ -160,8 +162,7 @@ DisplayNvidiaLicense "r${JETSON_L4T_RELEASE}_Release_v${JETSON_L4T_REVISION_LONG
160162
# Download NVIDIA source
161163
./Tegra/$TEGRA_SOURCE_SYNC_SH -k ${TEGRA_TAG}
162164

163-
echo ${KBASE}
164-
pushd ${KBASE}
165+
pushd ${KBASE} > /dev/null
165166

166167
echo -e "\e[32mCopy LibRealSense patches to the sandbox\e[0m"
167168
L4T_Patches_Dir=${sdk_dir}/scripts/Tegra/LRS_Patches/
@@ -175,7 +176,9 @@ fi
175176
#Clean the kernel WS
176177
echo -e "\e[32mPrepare workspace for kernel build\e[0m"
177178

178-
if [[ "$PATCHES_REV" >= "6.0" ]]; then
179+
if version_lt "$PATCHES_REV" "6.0"; then
180+
make ARCH=arm64 mrproper -j$(($(nproc)-1)) && make ARCH=arm64 tegra_defconfig -j$(($(nproc)-1))
181+
else
179182
make ARCH=arm64 mrproper -j$(($(nproc)-1))
180183
echo -e "\e[32mUpdate the kernel tree to support HID IMU sensors\e[0m"
181184
# appending config to defconfig so later .config will be generated with all necessary dependencies
@@ -185,8 +188,6 @@ if [[ "$PATCHES_REV" >= "6.0" ]]; then
185188
echo 'CONFIG_HID_SENSOR_IIO_COMMON=m' >> ./arch/arm64/configs/defconfig
186189
echo 'CONFIG_HID_SENSOR_IIO_TRIGGER=m' >> ./arch/arm64/configs/defconfig
187190
make ARCH=arm64 defconfig -j$(($(nproc)-1))
188-
else
189-
make ARCH=arm64 mrproper -j$(($(nproc)-1)) && make ARCH=arm64 tegra_defconfig -j$(($(nproc)-1))
190191
fi
191192

192193
#Reuse existing module.symver
@@ -217,7 +218,7 @@ make ARCH=arm64 prepare modules_prepare LOCALVERSION='' -j$(($(nproc)-1))
217218
#Remove previously applied patches
218219
git reset --hard
219220
echo -e "\e[32mApply Librealsense Kernel Patches\e[0m"
220-
if [[ "$PATCHES_REV" < "6.0" ]]; then
221+
if version_lt "${PATCHES_REV}" "6.0"; then
221222
patch -p1 < ./LRS_Patches/01-realsense-camera-formats-L4T-${PATCHES_REV}.patch
222223
patch -p1 < ./LRS_Patches/02-realsense-metadata-L4T-${PATCHES_REV}.patch
223224
if [[ "$PATCHES_REV" = "4.4" ]]; then # for Jetpack 4.4 and older
@@ -227,9 +228,7 @@ if [[ "$PATCHES_REV" < "6.0" ]]; then
227228
patch -p1 < ./LRS_Patches/04-media-uvcvideo-mark-buffer-error-where-overflow.patch
228229
fi
229230
patch -p1 < ./LRS_Patches/05-realsense-powerlinefrequency-control-fix.patch
230-
fi
231-
232-
if [[ "$PATCHES_REV" >= "6.0" ]]; then
231+
else
233232
patch -p1 < ${sdk_dir}/scripts/realsense-camera-formats-"${UBUNTU_CODENAME}"-master.patch
234233
patch -p1 < ${sdk_dir}/scripts/realsense-metadata-"${UBUNTU_CODENAME}"-master.patch
235234
[[ -f ${sdk_dir}/scripts/realsense-powerlinefrequency-control-fix-"${UBUNTU_CODENAME}".patch ]] \
@@ -247,18 +246,16 @@ if [[ "$PATCHES_REV" = "4.4" ]]; then # for Jetpack 4.4 and older
247246
echo -e "\e[32mCompiling accelerometer and gyro modules\e[0m"
248247
make -j$(($(nproc)-1)) ARCH=arm64 M=drivers/iio modules
249248
fi
250-
if [[ "$PATCHES_REV" >= "6.0" ]]; then # from Jetpack 6.0 onward
251-
echo -e "\e[32mCompiling hid support, accelerometer and gyro modules\e[0m"
252-
make -j$(($(nproc)-1)) ARCH=arm64 M=drivers/hid modules
253-
export KBUILD_MODPOST_WARN=1
254-
make -j$(($(nproc)-1)) ARCH=arm64 M=drivers/iio modules
255-
fi
256-
if [[ "$PATCHES_REV" < "6.0" ]]; then # for Jetpack 4-5
249+
if version_lt "$PATCHES_REV" "6.0"; then # for Jetpack 4-5
257250
echo -e "\e[32mCopying the patched modules to (~/) \e[0m"
258251
sudo cp drivers/media/usb/uvc/uvcvideo.ko ~/${TEGRA_TAG}-uvcvideo.ko
259252
sudo cp drivers/media/v4l2-core/videobuf-vmalloc.ko ~/${TEGRA_TAG}-videobuf-vmalloc.ko
260253
sudo cp drivers/media/v4l2-core/videobuf-core.ko ~/${TEGRA_TAG}-videobuf-core.ko
261254
else
255+
echo -e "\e[32mCompiling hid support, accelerometer and gyro modules\e[0m"
256+
make -j$(($(nproc)-1)) ARCH=arm64 M=drivers/hid modules
257+
export KBUILD_MODPOST_WARN=1
258+
make -j$(($(nproc)-1)) ARCH=arm64 M=drivers/iio modules
262259
echo -e "\e[32mCopying the patched modules to destination \e[0m"
263260
fi
264261
if [[ "$PATCHES_REV" = "4.4" ]]; then # for Jetpack 4.4 and older
@@ -268,7 +265,7 @@ if [[ "$PATCHES_REV" = "4.4" ]]; then # for Jetpack 4.4 and older
268265
sudo cp drivers/iio/gyro/hid-sensor-gyro-3d.ko ~/${TEGRA_TAG}-hid-sensor-gyro-3d.ko
269266
fi
270267

271-
if [[ "$PATCHES_REV" >= "6.0" ]]; then # from Jetpack 6 onward
268+
if ! version_lt "$PATCHES_REV" "6.0"; then # from Jetpack 6 onward
272269
sudo mkdir -p /lib/modules/$(uname -r)/extra/
273270
# uvc modules with formats/sku support
274271
sudo cp drivers/media/usb/uvc/uvcvideo.ko /lib/modules/$(uname -r)/extra/
@@ -301,7 +298,7 @@ fi
301298
sudo depmod
302299

303300
echo -e "\e[32mInsert the modified kernel modules\e[0m"
304-
if [[ "$PATCHES_REV" < "6.0" ]]; then
301+
if version_lt "$PATCHES_REV" "6.0"; then
305302
try_module_insert uvcvideo ~/${TEGRA_TAG}-uvcvideo.ko /lib/modules/`uname -r`/kernel/drivers/media/usb/uvc/uvcvideo.ko
306303
try_load_module uvcvideo
307304
try_load_module hid-sensor-gyro-3d

0 commit comments

Comments
 (0)