Skip to content

Commit bc40c00

Browse files
committed
[PATCH] Add D401 GPIO tunneling for the external sync support
[INFRA] Update kernel deployment scripts to support JP5.0.2 and update apply_patches.sh to simplify patch creation process
1 parent 7cc6490 commit bc40c00

4 files changed

Lines changed: 253 additions & 0 deletions

File tree

apply_patches.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,33 @@ if [[ "$ACTION" = "apply" ]]; then
9191
else
9292
cp "hardware/realsense/${JP5_D4XX_DTSI}" "sources_$SOURCES_VERSION/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-camera-d4xx.dtsi"
9393
fi
94+
95+
# Stage all modified files after patching
96+
git -C "sources_$SOURCES_VERSION/$D4XX_SRC_DST" add -A
97+
[[ -d "sources_$SOURCES_VERSION/$KERNEL_DIR" ]] && git -C "sources_$SOURCES_VERSION/$KERNEL_DIR" add -A
98+
git -C "sources_$SOURCES_VERSION/hardware/nvidia/platform/t19x/galen/kernel-dts" add -A || git -C "sources_$SOURCES_VERSION/hardware/nvidia/t23x/nv-public" add -A
99+
100+
# Get author identity from root repo
101+
GIT_AUTHOR_NAME=$(git config user.name)
102+
GIT_AUTHOR_EMAIL=$(git config user.email)
103+
104+
# Update local git identity for subrepos
105+
git -C "sources_$SOURCES_VERSION/$D4XX_SRC_DST" config user.name "$GIT_AUTHOR_NAME"
106+
git -C "sources_$SOURCES_VERSION/$D4XX_SRC_DST" config user.email "$GIT_AUTHOR_EMAIL"
107+
if [[ -d "sources_$SOURCES_VERSION/$KERNEL_DIR" ]]; then
108+
git -C "sources_$SOURCES_VERSION/$KERNEL_DIR" config user.name "$GIT_AUTHOR_NAME"
109+
git -C "sources_$SOURCES_VERSION/$KERNEL_DIR" config user.email "$GIT_AUTHOR_EMAIL"
110+
fi
111+
if [[ -d "sources_$SOURCES_VERSION/hardware/nvidia/platform/t19x/galen/kernel-dts" ]]; then
112+
git -C "sources_$SOURCES_VERSION/hardware/nvidia/platform/t19x/galen/kernel-dts" config user.name "$GIT_AUTHOR_NAME"
113+
git -C "sources_$SOURCES_VERSION/hardware/nvidia/platform/t19x/galen/kernel-dts" config user.email "$GIT_AUTHOR_EMAIL"
114+
elif [[ -d "sources_$SOURCES_VERSION/hardware/nvidia/t23x/nv-public" ]]; then
115+
git -C "sources_$SOURCES_VERSION/hardware/nvidia/t23x/nv-public" config user.name "$GIT_AUTHOR_NAME"
116+
git -C "sources_$SOURCES_VERSION/hardware/nvidia/t23x/nv-public" config user.email "$GIT_AUTHOR_EMAIL"
117+
fi
118+
119+
# Commit all staged files
120+
git -C "sources_$SOURCES_VERSION/$D4XX_SRC_DST" commit -m "RS patched" || true
121+
[[ -d "sources_$SOURCES_VERSION/$KERNEL_DIR" ]] && git -C "sources_$SOURCES_VERSION/$KERNEL_DIR" commit -m "RS patched" || true
122+
git -C "sources_$SOURCES_VERSION/hardware/nvidia/platform/t19x/galen/kernel-dts" commit -m "RS patched" || git -C "sources_$SOURCES_VERSION/hardware/nvidia/t23x/nv-public" commit -m "RS patched" || true
94123
fi
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
From f44c0d640f10125458ec3f65403b50cda607c49d Mon Sep 17 00:00:00 2001
2+
From: Nikolai-L <nikolai.lyskov@realsenseai.com>
3+
Date: Sun, 1 Feb 2026 10:30:13 +0200
4+
Subject: [PATCH] [PATCH] Add GPIO tunneling for the external sync support
5+
updating pipe setting functions for max9295 and max9296 drivers
6+
7+
---
8+
drivers/media/i2c/max9295.c | 11 +++++++++--
9+
drivers/media/i2c/max9296.c | 11 +++++++++++
10+
2 files changed, 20 insertions(+), 2 deletions(-)
11+
12+
diff --git a/drivers/media/i2c/max9295.c b/drivers/media/i2c/max9295.c
13+
index 4b03b1ef8..51e02edd7 100644
14+
--- a/drivers/media/i2c/max9295.c
15+
+++ b/drivers/media/i2c/max9295.c
16+
@@ -34,6 +34,7 @@
17+
#define MAX9295_CTRL0_ADDR 0x10
18+
#define MAX9295_SRC_CTRL_ADDR 0x2BF
19+
#define MAX9295_SRC_PWDN_ADDR 0x02BE
20+
+#define MAX9295_2C0_ADDR 0x02C0
21+
#define MAX9295_SRC_OUT_RCLK_ADDR 0x3F1
22+
#define MAX9295_START_PIPE_ADDR 0x311
23+
#define MAX9295_PIPE_EN_ADDR 0x2
24+
@@ -94,7 +95,12 @@
25+
26+
#define MAX9295_RESET_ALL 0x80
27+
#define MAX9295_RESET_SRC 0x60
28+
+#define MAX9295_RESET_ESYNC 0x77
29+
+
30+
#define MAX9295_PWDN_GPIO 0x90
31+
+#define MAX9295_PWDN_ESYNC 0x04
32+
+
33+
+#define MAX9295_2C0_ESYNC 0x57
34+
35+
#define MAX9295_MAX_PIPES 0x4
36+
37+
@@ -364,8 +370,9 @@ int max9295_setup_control(struct device *dev)
38+
max9295_write_reg(dev, MAX9295_I2C4_ADDR, (g_ctx->sdev_reg << 1));
39+
max9295_write_reg(dev, MAX9295_I2C5_ADDR, (g_ctx->sdev_def << 1));
40+
41+
- max9295_write_reg(dev, MAX9295_SRC_PWDN_ADDR, MAX9295_PWDN_GPIO);
42+
- max9295_write_reg(dev, MAX9295_SRC_CTRL_ADDR, MAX9295_RESET_SRC);
43+
+ max9295_write_reg(dev, MAX9295_SRC_PWDN_ADDR, MAX9295_PWDN_ESYNC);
44+
+ max9295_write_reg(dev, MAX9295_SRC_CTRL_ADDR, MAX9295_RESET_ESYNC);
45+
+ max9295_write_reg(dev, MAX9295_2C0_ADDR, MAX9295_2C0_ESYNC);
46+
max9295_write_reg(dev, MAX9295_SRC_OUT_RCLK_ADDR, MAX9295_SRC_RCLK);
47+
48+
g_ctx->serdev_found = true;
49+
diff --git a/drivers/media/i2c/max9296.c b/drivers/media/i2c/max9296.c
50+
index 87f9dcf7a..829657bca 100644
51+
--- a/drivers/media/i2c/max9296.c
52+
+++ b/drivers/media/i2c/max9296.c
53+
@@ -26,6 +26,10 @@
54+
#include <media/max9296.h>
55+
56+
/* register specifics */
57+
+#define MAX9296_2C5_ADDR 0x2C5
58+
+#define MAX9296_2C6_ADDR 0x2C6
59+
+#define MAX9296_2C7_ADDR 0x2C7
60+
+
61+
#define MAX9296_DST_CSI_MODE_ADDR 0x330
62+
#define MAX9296_LANE_MAP1_ADDR 0x333
63+
#define MAX9296_LANE_MAP2_ADDR 0x334
64+
@@ -54,6 +58,10 @@
65+
#define MAX9296_CTRL0_ADDR 0x10
66+
67+
/* data defines */
68+
+#define MAX9296_2C5_ESYNC 0xAA
69+
+#define MAX9296_2C6_ESYNC 0x17
70+
+#define MAX9296_2C7_ESYNC 0x47
71+
+
72+
#define MAX9296_CSI_MODE_4X2 0x1
73+
#define MAX9296_CSI_MODE_2X4 0x4
74+
#define MAX9296_LANE_MAP1_4X2 0x44
75+
@@ -364,6 +372,9 @@ int max9296_setup_control(struct device *dev, struct device *s_dev)
76+
77+
max9296_write_reg(dev,
78+
MAX9296_PWDN_PHYS_ADDR, MAX9296_ALLPHYS_NOSTDBY);
79+
+ max9296_write_reg(dev, MAX9296_2C5_ADDR, MAX9296_2C5_ESYNC);
80+
+ max9296_write_reg(dev, MAX9296_2C6_ADDR, MAX9296_2C6_ESYNC);
81+
+ max9296_write_reg(dev, MAX9296_2C7_ADDR, MAX9296_2C7_ESYNC);
82+
83+
priv->sdev_ref++;
84+
85+
--
86+
2.43.0
87+

scripts/deploy_kernel.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
2+
#!/bin/bash
3+
4+
# Display help message
5+
if [ "$#" -eq 0 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
6+
echo "Usage: $0 <JETPACK_VERSION> [TARGET] [USERNAME] [REMOTE_PATH] [REMOTE_BOOT_FOLDER]"
7+
echo ""
8+
echo "Package kernel modules, optionally copy them to the TARGET, update boot files and reboot the TARGET."
9+
echo ""
10+
echo "Arguments:"
11+
echo " JETPACK_VERSION JetPack version (e.g., 5.0.2, 5.1.2, 6.0, 6.2) - REQUIRED"
12+
echo " TARGET Target device hostname or IP address"
13+
echo " USERNAME SSH username for TARGET (default: administrator)"
14+
echo " REMOTE_PATH Remote path to copy files to (default: dev)"
15+
echo " REMOTE_BOOT_FOLDER Folder name under /boot on TARGET (default: dev)"
16+
echo ""
17+
echo "Example:"
18+
echo " $0 6.2 192.168.1.100 - pack and copy to /home/administrator/dev, update /boot/dev and reboot TARGET"
19+
echo " $0 6.2 192.168.1.100 nvidia - pack and copy to /home/nvidia/dev, update /boot/dev and reboot TARGET"
20+
echo " $0 6.2 192.168.1.100 nvidia foo - pack and copy to /home/nvidia/foo, update /boot/dev and reboot TARGET"
21+
echo " $0 6.2 192.168.1.100 nvidia foo bar - pack and copy to /home/nvidia/foo, update /boot/bar and reboot TARGET"
22+
exit 0
23+
fi
24+
25+
# Set defaults
26+
JETPACK_VERSION="$1"
27+
TARGET="$2"
28+
USERNAME="${3:-administrator}"
29+
REMOTE_PATH="${4:-dev}"
30+
REMOTE_BOOT_FOLDER="${5:-dev}"
31+
LOCAL_DIR="."
32+
33+
# Check if kernel_mod directory exists, create if not
34+
if [ ! -d ${LOCAL_DIR}/kernel_mod ]; then
35+
echo "Creating directory ${LOCAL_DIR}/kernel_mod..."
36+
mkdir -p ${LOCAL_DIR}/kernel_mod/${JETPACK_VERSION}
37+
else
38+
mkdir -p ${LOCAL_DIR}/kernel_mod/${JETPACK_VERSION}
39+
fi
40+
41+
# Clean version folder if files exist
42+
if [ "$(ls -A ${LOCAL_DIR}/kernel_mod/${JETPACK_VERSION} 2>/dev/null)" ]; then
43+
echo "Cleaning ${LOCAL_DIR}/kernel_mod/${JETPACK_VERSION}..."
44+
rm -rf ${LOCAL_DIR}/kernel_mod/${JETPACK_VERSION}/*
45+
fi
46+
47+
48+
# Copy specific kernel files for compatibility with legacy scripts (only for 5.0.2)
49+
IMG_DIR="images/${JETPACK_VERSION}"
50+
DEST_DIR="${LOCAL_DIR}/kernel_mod/${JETPACK_VERSION}"
51+
52+
if [ "${JETPACK_VERSION}" = "5.0.2" ]; then
53+
echo "Copying kernel files to ${DEST_DIR} (5.0.2 only)..."
54+
cp "${IMG_DIR}/arch/arm64/boot/Image" "${DEST_DIR}/" 2>/dev/null || true
55+
cp "${IMG_DIR}/arch/arm64/boot/dts/nvidia/tegra194-p2888-0001-p2822-0000.dtb" "${DEST_DIR}/" 2>/dev/null || true
56+
cp "${IMG_DIR}/drivers/media/i2c/d4xx.ko" "${DEST_DIR}/" 2>/dev/null || true
57+
cp "${IMG_DIR}/drivers/media/i2c/max96712.ko" "${DEST_DIR}/" 2>/dev/null || true
58+
cp "${IMG_DIR}/drivers/media/usb/uvc/uvcvideo.ko" "${DEST_DIR}/" 2>/dev/null || true
59+
cp "${IMG_DIR}/drivers/media/v4l2-core/videobuf-core.ko" "${DEST_DIR}/" 2>/dev/null || true
60+
cp "${IMG_DIR}/drivers/media/v4l2-core/videobuf-vmalloc.ko" "${DEST_DIR}/" 2>/dev/null || true
61+
elif [ "${JETPACK_VERSION}" = "6.2" ]; then
62+
echo "Packing ${DEST_DIR}/rootfs.tar.gz"
63+
tar czf ${DEST_DIR}/rootfs.tar.gz -C images/${JETPACK_VERSION}/rootfs boot lib
64+
fi
65+
if [ "$#" -eq 0 ]; then
66+
echo "No TARGET specified, skipping copy and reboot."
67+
else
68+
echo "Copying files and setting permissions on remote host..."
69+
cp ${LOCAL_DIR}/scripts/install_to_kernel.sh ${LOCAL_DIR}/kernel_mod/${JETPACK_VERSION}/
70+
# Use SSH ControlMaster to reuse a single SSH connection
71+
CONTROL_PATH="/tmp/ssh-control-${USERNAME}-${TARGET}"
72+
ssh -o ControlMaster=yes -o ControlPath="${CONTROL_PATH}" -o ControlPersist=10s -fN ${USERNAME}@${TARGET}
73+
ssh -o ControlMaster=no -o ControlPath="${CONTROL_PATH}" ${USERNAME}@${TARGET} "rm -rf ${REMOTE_PATH}/kernel_mod/${JETPACK_VERSION} && mkdir -p ${REMOTE_PATH}/kernel_mod"
74+
scp -o ControlMaster=no -o ControlPath="${CONTROL_PATH}" -r ${LOCAL_DIR}/kernel_mod/${JETPACK_VERSION} ${USERNAME}@${TARGET}:${REMOTE_PATH}/kernel_mod/
75+
ssh -o ControlMaster=no -o ControlPath="${CONTROL_PATH}" ${USERNAME}@${TARGET} "chmod +x ${REMOTE_PATH}/kernel_mod/${JETPACK_VERSION}/install_to_kernel.sh"
76+
ssh -o ControlMaster=no -o ControlPath="${CONTROL_PATH}" ${USERNAME}@${TARGET} "cd ${REMOTE_PATH}/kernel_mod/${JETPACK_VERSION} && ./install_to_kernel.sh ${JETPACK_VERSION} ${REMOTE_BOOT_FOLDER}"
77+
ssh -o ControlPath="${CONTROL_PATH}" -O exit ${USERNAME}@${TARGET} 2>/dev/null
78+
fi

scripts/install_to_kernel.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Display help message
4+
if [ "$#" -lt 1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
5+
echo "Usage: $0 <JETPACK_VERSION> [BOOT_FOLDER]"
6+
echo ""
7+
echo "Update the kernel modules and boot files on the local device for a specific JetPack version."
8+
echo ""
9+
echo "Arguments:"
10+
echo " JETPACK_VERSION JetPack version (e.g., 5.0.2, 5.1.2, 6.2)"
11+
echo " BOOT_FOLDER Folder name under /boot to copy Image (default: dev)"
12+
echo ""
13+
echo "Example:"
14+
echo " $0 6.2 foo"
15+
exit 0
16+
fi
17+
18+
JETPACK_VERSION="$1"
19+
FOLDER="${2:-dev}"
20+
21+
if [ ! -d /boot/${FOLDER} ]; then
22+
sudo mkdir /boot/${FOLDER}
23+
fi
24+
25+
# Only extract and use rootfs.tar.gz for 5.0.2 and 5.1.2
26+
if [ "${JETPACK_VERSION}" = "5.0.2" ] || [ "${JETPACK_VERSION}" = "5.1.2" ]; then
27+
tar xf rootfs.tar.gz
28+
fi
29+
30+
echo "Copying kernel files for JetPack ${JETPACK_VERSION}..."
31+
if [ "${JETPACK_VERSION}" = "5.0.2" ]; then
32+
echo "sudo cp tegra194-p2888-0001-p2822-0000.dtb /boot/${FOLDER}/"
33+
sudo cp tegra194-p2888-0001-p2822-0000.dtb /boot/${FOLDER}/
34+
echo "sudo cp d4xx.ko /lib/modules/$(uname -r)/updates/"
35+
sudo cp d4xx.ko /lib/modules/$(uname -r)/updates/
36+
echo "sudo cp max96712.ko /lib/modules/$(uname -r)/updates/"
37+
sudo cp max96712.ko /lib/modules/$(uname -r)/updates/
38+
echo "sudo cp uvcvideo.ko /lib/modules/$(uname -r)/updates/"
39+
sudo cp uvcvideo.ko /lib/modules/$(uname -r)/updates/
40+
echo "sudo cp videobuf-core.ko /lib/modules/$(uname -r)/updates/"
41+
sudo cp videobuf-core.ko /lib/modules/$(uname -r)/updates/
42+
echo "sudo cp videobuf-vmalloc.ko /lib/modules/$(uname -r)/updates/"
43+
sudo cp videobuf-vmalloc.ko /lib/modules/$(uname -r)/updates/
44+
elif [ "${JETPACK_VERSION}" = "6.2" ]; then
45+
tar xf rootfs.tar.gz
46+
echo "sudo cp -r lib/modules/$(uname -r) /lib/modules/."
47+
sudo cp -r lib/modules/$(uname -r) /lib/modules/.
48+
echo "sudo cp boot/tegra234-camera-d4xx-overlay*.dtbo /boot/."
49+
sudo cp boot/tegra234-camera-d4xx-overlay*.dtbo /boot/.
50+
echo "sudo cp boot/dtb/tegra234-p3737-0000+p3701-0005-nv.dtb /boot/dtb/."
51+
sudo cp boot/dtb/tegra234-p3737-0000+p3701-0005-nv.dtb /boot/dtb/.
52+
fi
53+
54+
echo "sudo cp Image /boot/${FOLDER}/."
55+
sudo cp Image /boot/${FOLDER}/.
56+
echo "sudo depmod"
57+
sudo depmod
58+
echo "done - rebooting"
59+
sudo reboot

0 commit comments

Comments
 (0)