#!/usr/bin/env bash # Use the previously deployed 0920 drivers; do not force module compatibility. set -euo pipefail root="$(cd "$(dirname "$0")/.." && pwd)" driver_dir="${DRIVER_DIR:-$root/../vision-anti-pinch-0920/orin/bin/drivers}" device="${1:-/dev/video5}" kernel="$(uname -r)" for driver in max9295 max9296 sgx-yuv-gmsl2; do module="${driver//-/_}" [[ -d "/sys/module/$module" ]] && continue file="$driver_dir/$driver.ko" [[ -f "$file" ]] || { echo "Missing driver: $file" >&2; exit 1; } vermagic="$(modinfo -F vermagic "$file")" if [[ -n "$vermagic" && "${vermagic%% *}" != "$kernel" ]]; then echo "Kernel mismatch: $file ($vermagic), running $kernel" >&2; exit 1 fi if [[ -z "$vermagic" ]]; then echo "No vermagic metadata: $file; using normal insmod kernel validation." fi options=() [[ "$driver" == sgx-yuv-gmsl2 ]] && options=(gmsl_mode=2,2,2,2) sudo -n insmod "$file" "${options[@]}" done for _ in {1..20}; do [[ -c "$device" ]] && break; sleep .25; done [[ -c "$device" ]] || { echo "Camera not created: $device" >&2; exit 1; } v4l2-ctl -d "$device" -c sensor_mode=1,trig_pin=0xffff0007 echo "Camera ready: $device"