Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copilot Instructions for realsense_mipi_platform_driver

## Project Overview
This repository provides the RealSense™ camera driver for GMSL/MIPI interfaces, targeting NVIDIA® Jetson platforms (AGX Xavier, AGX Orin) and supporting multiple JetPack versions (6.x, 5.x, 4.6.1). It enables control and streaming of RealSense™ 3D MIPI cameras via custom kernel drivers, device trees, and build scripts.

## Architecture & Key Components
- **hardware/**: Device tree overlays and platform-specific configuration files for NVIDIA and RealSense hardware.
- **kernel/**: Kernel patches and sources for different JetPack and kernel versions.
- **nvidia-oot/**: Out-of-tree NVIDIA kernel modules and related patches.
- **scripts/**: Build, patch, and utility scripts for workspace setup, compilation, and firmware management.
- **test/**: Test scripts and metadata validation tools.
- **utilities/**: Example applications, parsers, and stream utilities for RealSense cameras.

## Developer Workflows
### 1. Workspace Setup & Build
- Use `setup_workspace.sh [JetPack_version]` to prepare sources and toolchains.
- Apply kernel and driver patches with `apply_patches.sh [--one-cam|--dual-cam] apply [JetPack_version]`.
- For CI/external builds, use `apply_patches_ext.sh`.
- Build all components with `build_all.sh [--dev-dbg] [JetPack_version]`.
- Example:
```sh
./setup_workspace.sh 6.2
./apply_patches.sh 6.2
./build_all.sh 6.2
```
- For debug logging, add `--dev-dbg` to build scripts.

### 2. Testing & Validation
- Use `test/` scripts for firmware and metadata validation.
- After installation, verify driver and video devices:
```sh
sudo dmesg | grep d4xx
ls -l /dev/video*
```
- Use V4L2 utilities for device checks: `sudo apt install v4l-utils`

### 3. Device Tree & Kernel Integration
- Device tree overlays are in `hardware/realsense/` and `hardware/nvidia/platform/`.
- Kernel patches are versioned under `kernel/` and must match JetPack version.
- Out-of-tree modules are managed in `nvidia-oot/`.

## Project-Specific Conventions
- JetPack version is a required argument for most scripts and build steps.
- Patch scripts support single/dual camera configuration for JetPack 5.x (`--one-cam`, `--dual-cam`).
- Kernel versioning and file paths must be updated per JetPack release.
- Artifacts (modules, images, dtb, etc.) are archived under `images/[JetPack_version]/`.

## Integration Points & External Dependencies
- Relies on NVIDIA Jetson Linux BSP sources and toolchains (see README_JP6.md, README_JP5.md, README_JP4.md).
- Uses RealSense de-serialize hardware and Leopard Imaging adapter boards.
- Artifactory integration for CI/CD and artifact uploads (see Jenkins pipeline scripts).

## Example: CI Pipeline Highlights

## CI Pipeline: GitHub Actions & Jenkins

### GitHub Actions Workflows
- Located in `.github/workflows/`, these YAML files automate build and release for each JetPack version:
- `build-jp6.yml`, `build-jp6.2.yml`, `build-jp6.1.yml`, `build-jp512.yml`, `build-jp502.yml`: Build/test for JetPack 6.x/5.x/4.x on push/PR.
- `release-jp6.yml`: Publishes release artifacts for JetPack 6.x.
- Each workflow:
- Checks out code
- Runs setup (`setup_workspace.sh [version]`), applies patches, builds (`build_all.sh [version]`)
- Archives build outputs (modules, dtb, rootfs, etc.)
- Uploads artifacts (via `actions/upload-artifact` or `softprops/action-gh-release`)
- Example build steps:
```yaml
- name: setup workspace
run: yes | ./setup_workspace.sh 6.2
- name: apply patches
run: ./apply_patches.sh 6.2
- name: build
run: ./build_all.sh 6.2
```
- Artifacts are found in `images/[JetPack_version]/` and uploaded for CI/release consumption.

### Jenkins Pipeline
- `LRS_Jetson_mipi_usb_driver_jp6.groovy` (legacy/optional): Automates checkout, patching, build, artifact archiving, and upload to Artifactory.
- Environment variables and parameters control build options, JetPack version, and artifact destinations.
- Artifacts are uploaded to Artifactory and notification emails are sent on build completion/failure.

## References
- See `README.md` for overall project intro and hardware requirements.
- See `README_JP6.md`, `README_JP5.md`, `README_JP4.md` for JetPack-specific build instructions.
- See `README_tools.md` for build script usage and options.
- See `README_driver.md` for driver API and validation steps.

---
**Feedback Requested:**
If any section is unclear or missing key details, please specify which workflows, conventions, or integration points need further documentation for AI agents.
61 changes: 61 additions & 0 deletions .github/workflows/build-jp6.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,64 @@ jobs:
run: git config --global user.email "builder@example.com" && git config --global user.name "builder" && ./apply_patches.sh 6.1
- name: build
run: ./build_all.sh 6.1

- name: Create artifact archives
run: |
JETPACK_VER="6.1"
KERNEL_VERSION="5.15.148-tegra"

# Create nvidia-oot modules archive
echo "Creating nvidia-oot modules archive"
tar -czf "./images/${JETPACK_VER}/nvidia-oot-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/updates"

# Create kernel HID modules archive
echo "Creating kernel HID modules archive"
tar -czf "./images/${JETPACK_VER}/kernel-hid-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/extra"

# Create rootfs archive
echo "Creating rootfs archive"
tar -cjf "./images/${JETPACK_VER}/rootfs.tar.bz2" -C "./images/${JETPACK_VER}/rootfs/" .

- name: Upload nvidia-oot modules
uses: actions/upload-artifact@v4
with:
name: nvidia-oot-modules
path: ./images/6.1/nvidia-oot-modules.tar.gz
retention-days: 30

- name: Upload kernel HID modules
uses: actions/upload-artifact@v4
with:
name: kernel-hid-modules
path: ./images/6.1/kernel-hid-modules.tar.gz
retention-days: 30

- name: Upload d4xx.ko
uses: actions/upload-artifact@v4
with:
name: d4xx-ko
path: ./images/6.1/rootfs/lib/modules/5.15.148-tegra/updates/drivers/media/i2c/d4xx.ko
retention-days: 30

- name: Upload rootfs
uses: actions/upload-artifact@v4
with:
name: rootfs
path: ./images/6.1/rootfs.tar.bz2
retention-days: 30

- name: Upload dtbo files
uses: actions/upload-artifact@v4
with:
name: dtbo-files
path: |
./images/6.1/rootfs/boot/tegra234-camera-d4xx-overlay.dtbo
./images/6.1/rootfs/boot/dtb/tegra234-p3737-0000+p3701-0000-nv.dtb
retention-days: 30

- name: Upload kernel Image
uses: actions/upload-artifact@v4
with:
name: kernel-image
path: ./images/6.1/rootfs/boot/Image
retention-days: 30
61 changes: 61 additions & 0 deletions .github/workflows/build-jp6.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,64 @@ jobs:
run: git config --global user.email "builder@example.com" && git config --global user.name "builder" && ./apply_patches.sh 6.2
- name: build
run: ./build_all.sh 6.2

- name: Create artifact archives
run: |
JETPACK_VER="6.2"
KERNEL_VERSION="5.15.148-tegra"

# Create nvidia-oot modules archive
echo "Creating nvidia-oot modules archive"
tar -czf "./images/${JETPACK_VER}/nvidia-oot-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/updates"

# Create kernel HID modules archive
echo "Creating kernel HID modules archive"
tar -czf "./images/${JETPACK_VER}/kernel-hid-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/extra"

# Create rootfs archive
echo "Creating rootfs archive"
tar -cjf "./images/${JETPACK_VER}/rootfs.tar.bz2" -C "./images/${JETPACK_VER}/rootfs/" .

- name: Upload nvidia-oot modules
uses: actions/upload-artifact@v4
with:
name: nvidia-oot-modules
path: ./images/6.2/nvidia-oot-modules.tar.gz
retention-days: 30

- name: Upload kernel HID modules
uses: actions/upload-artifact@v4
with:
name: kernel-hid-modules
path: ./images/6.2/kernel-hid-modules.tar.gz
retention-days: 30

- name: Upload d4xx.ko
uses: actions/upload-artifact@v4
with:
name: d4xx-ko
path: ./images/6.2/rootfs/lib/modules/5.15.148-tegra/updates/drivers/media/i2c/d4xx.ko
retention-days: 30

- name: Upload rootfs
uses: actions/upload-artifact@v4
with:
name: rootfs
path: ./images/6.2/rootfs.tar.bz2
retention-days: 30

- name: Upload dtbo files
uses: actions/upload-artifact@v4
with:
name: dtbo-files
path: |
./images/6.2/rootfs/boot/tegra234-camera-d4xx-overlay.dtbo
./images/6.2/rootfs/boot/dtb/tegra234-p3737-0000+p3701-0000-nv.dtb
retention-days: 30

- name: Upload kernel Image
uses: actions/upload-artifact@v4
with:
name: kernel-image
path: ./images/6.2/rootfs/boot/Image
retention-days: 30
61 changes: 61 additions & 0 deletions .github/workflows/build-jp6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,64 @@ jobs:
run: git config --global user.email "builder@example.com" && git config --global user.name "builder" && ./apply_patches.sh 6.0
- name: build
run: ./build_all.sh 6.0

- name: Create artifact archives
run: |
JETPACK_VER="6.0"
KERNEL_VERSION="5.15.136-tegra"
Comment on lines +29 to +30

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded version values '6.0' and '5.15.136-tegra' create duplication with the '6.0' parameter passed to build scripts in line 25. Consider extracting these as workflow-level environment variables or job outputs to maintain consistency and avoid version mismatches.

Copilot uses AI. Check for mistakes.

# Create nvidia-oot modules archive
echo "Creating nvidia-oot modules archive"
tar -czf "./images/${JETPACK_VER}/nvidia-oot-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/updates"

# Create kernel HID modules archive
echo "Creating kernel HID modules archive"
tar -czf "./images/${JETPACK_VER}/kernel-hid-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/extra"
Comment on lines +34 to +38

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tar command uses a relative path for the archive target './lib/modules/${KERNEL_VERSION}/updates' which may not work as intended. When using '-C' to change directory, the path should be relative to that new directory. This should likely be 'lib/modules/${KERNEL_VERSION}/updates' without the leading './'.

Suggested change
tar -czf "./images/${JETPACK_VER}/nvidia-oot-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/updates"
# Create kernel HID modules archive
echo "Creating kernel HID modules archive"
tar -czf "./images/${JETPACK_VER}/kernel-hid-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/extra"
tar -czf "./images/${JETPACK_VER}/nvidia-oot-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "lib/modules/${KERNEL_VERSION}/updates"
# Create kernel HID modules archive
echo "Creating kernel HID modules archive"
tar -czf "./images/${JETPACK_VER}/kernel-hid-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "lib/modules/${KERNEL_VERSION}/extra"

Copilot uses AI. Check for mistakes.

Copilot AI Dec 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tar command uses a relative path for the archive target './lib/modules/${KERNEL_VERSION}/extra' which may not work as intended. When using '-C' to change directory, the path should be relative to that new directory. This should likely be 'lib/modules/${KERNEL_VERSION}/extra' without the leading './'.

Suggested change
tar -czf "./images/${JETPACK_VER}/kernel-hid-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/extra"
tar -czf "./images/${JETPACK_VER}/kernel-hid-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "lib/modules/${KERNEL_VERSION}/extra"

Copilot uses AI. Check for mistakes.

# Create rootfs archive
echo "Creating rootfs archive"
tar -cjf "./images/${JETPACK_VER}/rootfs.tar.bz2" -C "./images/${JETPACK_VER}/rootfs/" .

- name: Upload nvidia-oot modules
uses: actions/upload-artifact@v4
with:
name: nvidia-oot-modules
path: ./images/6.0/nvidia-oot-modules.tar.gz
retention-days: 30

- name: Upload kernel HID modules
uses: actions/upload-artifact@v4
with:
name: kernel-hid-modules
path: ./images/6.0/kernel-hid-modules.tar.gz
retention-days: 30

- name: Upload d4xx.ko
uses: actions/upload-artifact@v4
with:
name: d4xx-ko
path: ./images/6.0/rootfs/lib/modules/5.15.136-tegra/updates/drivers/media/i2c/d4xx.ko
retention-days: 30

- name: Upload rootfs
uses: actions/upload-artifact@v4
with:
name: rootfs
path: ./images/6.0/rootfs.tar.bz2
retention-days: 30

- name: Upload dtbo files
uses: actions/upload-artifact@v4
with:
name: dtbo-files
path: |
./images/6.0/rootfs/boot/tegra234-camera-d4xx-overlay.dtbo
./images/6.0/rootfs/boot/dtb/tegra234-p3737-0000+p3701-0000-nv.dtb
retention-days: 30

- name: Upload kernel Image
uses: actions/upload-artifact@v4
with:
name: kernel-image
path: ./images/6.0/rootfs/boot/Image
retention-days: 30
47 changes: 47 additions & 0 deletions .github/workflows/release-jp6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release JP 6.0

on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3
- name: setup workspace
run: yes | ./setup_workspace.sh 6.0
- name: apply patches
run: git config --global user.email "builder@example.com" && git config --global user.name "builder" && ./apply_patches.sh 6.0
- name: build
run: ./build_all.sh 6.0
- name: Create artifact archives
run: |
JETPACK_VER="6.0"
KERNEL_VERSION="5.15.136-tegra"
# Create nvidia-oot modules archive
echo "Creating nvidia-oot modules archive"
tar -czf "./images/${JETPACK_VER}/nvidia-oot-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/updates"
# Create kernel HID modules archive
echo "Creating kernel HID modules archive"
tar -czf "./images/${JETPACK_VER}/kernel-hid-modules.tar.gz" -C "./images/${JETPACK_VER}/rootfs/" "./lib/modules/${KERNEL_VERSION}/extra"
# Create rootfs archive
echo "Creating rootfs archive"
tar -cjf "./images/${JETPACK_VER}/rootfs.tar.bz2" -C "./images/${JETPACK_VER}/rootfs/" .
- name: Upload artifacts to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
./images/6.0/nvidia-oot-modules.tar.gz
./images/6.0/kernel-hid-modules.tar.gz
./images/6.0/rootfs/lib/modules/5.15.136-tegra/updates/drivers/media/i2c/d4xx.ko
./images/6.0/rootfs.tar.bz2
./images/6.0/rootfs/boot/tegra234-camera-d4xx-overlay.dtbo
./images/6.0/rootfs/boot/dtb/tegra234-p3737-0000+p3701-0000-nv.dtb
./images/6.0/rootfs/boot/Image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading