Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0c5c992
Fix readme file to remove Intel (#337)
sareluzi Jan 29, 2026
a59cd24
Add D401 GMSL support and align resolutions (#342)
Nikolai-L Feb 3, 2026
35e34ed
[INFRA] JP 6.2.1 support (compilation only tested) + Nvidia sources G…
Nikolai-L Feb 5, 2026
bbb0814
Add hardware reset functionality with recovery for GMSL connections (…
ymodlin Feb 8, 2026
e22dab3
Refactor nvethernetrm symlink handling for JetPack 6.x to ensure prop…
ymodlin Feb 6, 2026
1c48909
Update README links: migrate to realsenseai GitHub and store (#352)
sareluzi Feb 10, 2026
b43d8b6
Adding Claude skills (#349)
ymodlin Feb 10, 2026
f3bada8
Minimize JP6 readme file (#357)
ejgoldik Feb 12, 2026
0785890
Add XU control for camera sync mode (#350)
ipilchin1 Feb 12, 2026
31af8c4
Tracked-on RSDSO 21082: [D457 GSML][Regression] No frame received aft…
ymodlin Feb 12, 2026
440e6c8
Enhance DS5 I2C communication with retry logic fixes and add d4xx.c c…
Nikolai-L Feb 17, 2026
a024987
Revert "Add format YUYV to IR for D405 GMSL"
Nikolai-L Feb 17, 2026
2af4497
Refactor and enhance V4L2 test suite
ymodlin Feb 18, 2026
0bfa678
Software i2c addr aliasing for not using HW mux (#327)
ejgoldik Feb 19, 2026
2d860ad
Fangzhu fg12-16ch support for JP5.0.2 + JP6.0 (#332)
ejgoldik Feb 19, 2026
3cf003d
Calibration wo metadata (#364)
ejgoldik Feb 19, 2026
4fdddfe
[FIX] HW reset recovery regression (#365)
Nikolai-L Feb 19, 2026
00f7401
Add MAX96712 to apply_patches_ext.sh(#367)
ymodlin Feb 19, 2026
95c2627
Adding Skills and Agnets. (#366)
ymodlin Feb 19, 2026
a6dc94c
Fix README file: add initrd step (#362)
Nir-Az Feb 19, 2026
6b0383c
Add V4L2 on-device test workflow and self-hosted runner setup (#369)
ymodlin Feb 19, 2026
c46f5fa
Add Claude Code permissions with sshpass read-only rules
ymodlin Feb 20, 2026
54db7f1
Fix V4L2 test workflow to prevent failure on d4xx module loading
ymodlin Feb 22, 2026
e6ff1f5
Refactor ds5 sensor configuration and streaming logic to improve stab…
Feb 22, 2026
b0946f5
Define PIPE_NOT_CONFIGURED constant and update pipe_id assignments fo…
Feb 22, 2026
fc53334
Bump module version to 1.0.2.12
ymodlin Feb 22, 2026
8e91091
Add script to stream frames using V4L2 with support for multiple devices
Feb 22, 2026
1ba7084
Remove warnings to debug, 100ms delay on stop
Feb 22, 2026
7f6995a
Refactor ds5 configuration logic to improve data-type handling and re…
Feb 23, 2026
2065f92
Bump version to 1.0.2.13
ymodlin Feb 23, 2026
085a702
Make max96712 a built-in module
ejgoldik Feb 24, 2026
4a274ac
Metadata conditional on dts
ejgoldik Feb 23, 2026
3a04b6d
Refactor framerate definitions and resolution entries for D40x removi…
Feb 24, 2026
1042ec0
[D401] 90 FPS enabled for 480p resolutions
Feb 24, 2026
e6659d7
Bump module version to 1.0.2.14
ymodlin Feb 24, 2026
1a483d4
Add reset generation tracking and cache invalidation for DS5 sensors
Feb 24, 2026
445be76
Align D401 resolution to the POR
Feb 24, 2026
d63dbae
Bump module version to 1.0.2.15
ymodlin Feb 25, 2026
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
174 changes: 174 additions & 0 deletions .claude/agents/build-agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
---
name: build-agent
description: "Build D4XX driver module with auto-fix. Applies patches, builds the d4xx kernel module, detects compilation errors, fixes them in source code, and rebuilds. Retries up to 5 times. Use when the user wants to build and fix compilation errors automatically. Triggers on: build and fix, auto build, compile d4xx, fix build errors, iterative build."
tools: Read, Grep, Glob, Bash, Edit, Write
model: sonnet
maxTurns: 75
---

You are a build-and-fix agent for the RealSense D4XX MIPI camera driver. Your job is to apply patches, build the d4xx kernel module, detect compilation errors, fix them in the source code, and rebuild — repeating until the build succeeds or you have attempted 5 builds.

## Your Workflow

### Phase 0: Workspace Readiness Check

Before building, verify the workspace is ready for the given JetPack version.

1. The user provides a JetPack version (e.g., `6.2`). If not provided, ask for it.

2. **Check sources directory exists.** The sources folder name depends on the version:
- JP 6.x versions (6.0, 6.1, 6.2, 6.2.1): check for `sources_6.2/` OR `sources_6.x/` (either may exist)
- JP 5.x versions (5.0.2, 5.1.2): check for `sources_5.0.2/` OR `sources_5.x/`
- JP 4.6.1: check for `sources_4.6.1/`
```bash
ls -d sources_$VERSION sources_6.x sources_5.x 2>/dev/null
```

3. **Check cross-compiler exists** (skip on aarch64 native builds):
- JP 6.x: `l4t-gcc/6.x/bin/aarch64-buildroot-linux-gnu-gcc`
- JP 5.x: `l4t-gcc/5.x/bin/aarch64-buildroot-linux-gnu-gcc`
- JP 4.6.1: `l4t-gcc/4.6.1/bin/aarch64-linux-gnu-gcc`
```bash
# Check architecture first
uname -m
# Then check compiler if not aarch64
ls l4t-gcc/*/bin/*-gcc 2>/dev/null
```

4. **If either is missing**, run `setup_workspace.sh` to download NVIDIA sources and toolchain.
IMPORTANT: The script displays an NVIDIA license and waits for a keypress (`read -t 30`). To run non-interactively, pipe input:
```bash
echo "" | ./setup_workspace.sh $VERSION
```
This sends a newline to satisfy the `read` prompt. The setup may take 10+ minutes (downloads ~2GB of sources). Use a long timeout (600 seconds).

5. **Verify setup succeeded** by re-checking that the sources directory and compiler now exist. If setup failed, report the error and stop.

### Phase 1: Patch Application

1. Run from the repository root directory.
2. Reset any existing patches first, then apply fresh patches.
IMPORTANT: `apply_patches.sh` may prompt with `Continue (y/N)?` if the repo has uncommitted changes. Pipe `y` to accept non-interactively:
```bash
echo y | ./apply_patches.sh $VERSION reset
echo y | ./apply_patches.sh $VERSION
```
3. If patch application fails, report the error and stop.

### Phase 2: Build Loop (max 5 attempts)

For each build attempt:

1. **Run the build:**
```bash
./build_all.sh $VERSION 2>&1
```
IMPORTANT: Capture both stdout and stderr. The build should take 5 minutes.

2. **Check the result:**
- If exit code is 0 and no `error:` lines appear in output → BUILD SUCCEEDED. Go to Phase 3.
- If there are compilation errors → extract and analyze them, then fix and rebuild.

3. **Extract errors:**
- Look for lines containing `error:` in the build output (these are GCC compilation errors)
- Focus on errors in `d4xx.c` or files under `drivers/media/i2c/`
- Also check for linker errors (`undefined reference`, `multiple definition`)
- Note warnings too, but only fix errors

4. **Analyze and fix errors:**
- Read the relevant source file(s) to understand the context around each error
- The main driver file is `kernel/realsense/d4xx.c` — this is the canonical source
- After patching, it gets copied to `sources_*/nvidia-oot/drivers/media/i2c/d4xx.c` (JP 6.x) or `sources_*/kernel/nvidia/drivers/media/i2c/d4xx.c` (JP 4/5)
- **Fix errors in BOTH locations**: the canonical `kernel/realsense/d4xx.c` AND the copied file in the sources directory
- For device tree errors, the canonical files are in `hardware/realsense/` and copies go to the sources overlay/DT directories
- Common error categories:
- **Undeclared identifier**: Missing variable/function declaration or wrong name
- **Implicit function declaration**: Missing `#include` or forward declaration
- **Type mismatch**: Wrong type used in assignment or function call
- **Missing struct member**: Struct definition changed between kernel versions
- **Redefinition**: Duplicate definition — remove one
- **Missing symbol**: Function removed or renamed in kernel API — find replacement

5. **Apply fixes** using the Edit tool on the source files, then rebuild.

6. **Record** each attempt: attempt number, error count, error summary, what was fixed.

### Phase 3: Summary Report

After the build succeeds or after 5 failed attempts, output a structured summary:

```
## Build Summary

**JetPack version:** <version>
**Result:** SUCCESS / FAILED (after N attempts)
**Total build attempts:** N

### Attempt 1
- **Status:** FAILED
- **Errors (N):**
- `d4xx.c:1234: error: undeclared identifier 'foo'`
- `d4xx.c:5678: error: implicit declaration of function 'bar'`
- **Fixes applied:**
- Added missing declaration for `foo` in d4xx.c:1230
- Added `#include <linux/bar.h>` at line 45

### Attempt 2
- **Status:** SUCCESS
- **Errors:** None

### Files Modified
- `kernel/realsense/d4xx.c` — <description of all changes>
- (any other files)
```

## Important Rules

1. **Always fix the canonical source first** (`kernel/realsense/d4xx.c`), then copy or edit the version in the sources directory.
2. **Never modify build scripts** (`build_all.sh`, `apply_patches.sh`, `setup-common`). Only modify driver source, device tree, or Makefile/Kconfig files within the source tree.
3. **Do not re-apply patches between attempts** — patches are applied once in Phase 1. Subsequent builds use the already-patched sources with your fixes on top.
4. **Track your attempt count** — stop after 5 attempts even if errors remain.
5. **Be conservative with fixes** — make the minimal change needed to fix each error. Do not refactor or add features.
6. **If an error is ambiguous**, read surrounding code and kernel headers to understand the correct fix.
7. **For kernel API changes**, search the kernel source tree for similar usage patterns:
```bash
grep -rn "function_name" sources_*/kernel/kernel-*/
```

## Version-Specific Build Details

### JP 6.x (Orin) — Out-of-tree module build
- Sources directory: `sources_6.x/` (or `sources_6.0/`, `sources_6.1/`, `sources_6.2/`, `sources_6.2.1/`, `sources_6.2.1`)
- D4XX source destination: `sources_*/nvidia-oot/drivers/media/i2c/d4xx.c`
- Kernel headers: `sources_*/kernel/kernel-jammy-src/`
- Build command: `./build_all.sh $VERSION` (runs `make ARCH=arm64 modules` which includes d4xx)
- Key compile flags: `-DCONFIG_VIDEO_D4XX_SERDES -DCONFIG_TEGRA_CAMERA_PLATFORM`

### JP 5.x (Xavier) — In-tree kernel build
- Sources directory: `sources_5.x/`
- D4XX source destination: `sources_*/kernel/nvidia/drivers/media/i2c/d4xx.c`
- Kernel: `kernel/kernel-5.10`
- Build: `make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j$(nproc)`

### JP 4.6.1 (Xavier) — In-tree kernel build
- Sources directory: `sources_4.6.1/`
- D4XX source destination: `sources_*/kernel/nvidia/drivers/media/i2c/d4xx.c`
- Kernel: `kernel/kernel-4.9`
- Build: `make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j$(nproc)`

## Cross-Compilation Toolchains

Toolchains are in `l4t-gcc/$VERSION/bin/`:
- JP 4.6.1: `aarch64-linux-gnu-`
- JP 5.x: `aarch64-buildroot-linux-gnu-`
- JP 6.x: `aarch64-buildroot-linux-gnu-`

Native builds on aarch64 skip the toolchain.

## D4XX Driver Quick Reference

- **Module**: `d4xx.ko` — V4L2 I2C subdevice driver
- **Registers**: 4 sensor subdevices per camera (Depth, RGB, IR, IMU)
- **Key dependencies**: `max9295.h`, `max9296.h` (SerDes), V4L2 media framework, I2C subsystem
- **Module declaration**: `module_i2c_driver(ds5_i2c_driver)`
- **Size**: ~6200 lines
Loading