VC-MIPI-modules / vc_mipi_nvidia

Vision Components MIPI CSI-2 driver for NVIDIA Jetson Nano, Xavier NX, AGX Xavier, TX2 and Orin Nano, Orin NX
69 stars 31 forks source link

Patch files fail to apply to release 32.6.1 #6

Closed bfoz closed 9 months ago

bfoz commented 1 year ago

I'm trying to apply the kernel patches listed in Integrate the driver in your own BSP to a kernel that I'm building for a Jetson AGX devkit. The kernel source is from R32.6.1. Unfortunately, the patches from the kernel_Xavier_32.6.1+ directory don't apply cleanly. Am I doing something wrong?

Using this simple shell snippet:

for patch in $vc_mipi_patch_dir/kernel_Xavier_32.6.1+/*.patch; do
    echo "--- APPLYING PATCH FILE: $patch ---"
    patch --dry-run --ignore-whitespace --binary -p1 -d $build_dir -i $patch
done

NOTE: I used a similar for-loop (without --dry-run) to apply the patches from kernel_common_32.3.1+ before running the above. Those patches, except the one for .gitignore, applied cleanly.

The resulting output:

--- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0001-Added-RAW8-grey-RAW10-y10-and-RAW12-y12-format-to-th.patch --- checking file kernel/nvidia/drivers/media/platform/tegra/camera/camera_common.c Hunk #1 succeeded at 126 (offset 5 lines). checking file kernel/nvidia/drivers/media/platform/tegra/camera/sensor_common.c Hunk #1 FAILED at 227 (different line endings). 1 out of 1 hunk FAILED checking file kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_formats.h Hunk #1 FAILED at 95 (different line endings). Hunk #2 FAILED at 115 (different line endings). 2 out of 2 hunks FAILED --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0001-Added-controls-trigger_mode-flash_mode-and-black_lev.patch --- checking file kernel/nvidia/drivers/media/platform/tegra/camera/tegracam_ctrls.c checking file kernel/nvidia/include/media/camera_common.h checking file kernel/nvidia/include/media/tegra-v4l2-camera.h --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0001-Bugfix-in-destroy_buffer_table-.-When-the-capture_bu.patch --- checking file kernel/nvidia/drivers/media/platform/tegra/camera/capture_common.c --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0001-Disable-VB2_BUF_STATE_REQUEUEING-in-vi5_fops.c.patch --- checking file kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_fops.c --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0002-Changed-control-flash_mode-to-io_mode.patch --- checking file kernel/nvidia/drivers/media/platform/tegra/camera/tegracam_ctrls.c Hunk #1 FAILED at 186. Hunk #2 FAILED at 341. Hunk #3 FAILED at 696. Hunk #4 FAILED at 889. 4 out of 4 hunks FAILED checking file kernel/nvidia/include/media/camera_common.h Hunk #1 FAILED at 193. 1 out of 1 hunk FAILED checking file kernel/nvidia/include/media/tegra-v4l2-camera.h Hunk #1 FAILED at 39. 1 out of 1 hunk FAILED --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0002-Increased-tegra-channel-timeout-due-to-trigger-modes.patch --- checking file kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_fops.c --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0003-Added-RAW14-y14-format-to-the-tegra-framework.patch --- checking file kernel/kernel-4.9/Documentation/media/uapi/v4l/pixfmt-y14.rst checking file kernel/kernel-4.9/Documentation/media/uapi/v4l/yuv-formats.rst checking file kernel/kernel-4.9/drivers/media/v4l2-core/v4l2-ioctl.c checking file kernel/kernel-4.9/include/uapi/linux/media-bus-format.h checking file kernel/kernel-4.9/include/uapi/linux/videodev2.h checking file kernel/nvidia/drivers/media/platform/tegra/camera/camera_common.c Hunk #1 succeeded at 126 with fuzz 2 (offset -15 lines). checking file kernel/nvidia/drivers/media/platform/tegra/camera/sensor_common.c Hunk #1 FAILED at 241. 1 out of 1 hunk FAILED checking file kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_formats.h Hunk #1 succeeded at 116 with fuzz 2 (offset -6 lines). --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0003-Added-control-single_trigger-to-the-tegra-framework.patch --- checking file kernel/nvidia/drivers/media/platform/tegra/camera/tegracam_ctrls.c Hunk #1 FAILED at 178. Hunk #2 FAILED at 188. Hunk #3 FAILED at 198. Hunk #4 FAILED at 347. Hunk #5 FAILED at 710. Hunk #6 FAILED at 907. 6 out of 6 hunks FAILED checking file kernel/nvidia/include/media/camera_common.h Hunk #1 FAILED at 195. 1 out of 1 hunk FAILED checking file kernel/nvidia/include/media/tegra-v4l2-camera.h Hunk #1 FAILED at 41. 1 out of 1 hunk FAILED --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0003-Changed-Interrupt-Mask-for-csi4-to-emit-CRC-and-mul.patch --- checking file kernel/nvidia/drivers/media/platform/tegra/camera/csi/csi4_fops.c --- APPLYING PATCH FILE: /home/build/vc_mipi_nvidia-0.12.3/patch/kernel_Xavier_32.6.1+/0004-Added-VC-MIPI-Driver-sources-to-Makefile.patch --- checking file kernel/nvidia/drivers/media/i2c/Makefile

It appears that some of the problems are whitespace-related, despite passing --ignore-whitespace and --binary. I'm not sure if that's a problem with the version of patch that I'm using (GNU patch 2.7.6) or if there's something odd about the patch files themselves.

I've checked that $build_dir is correct given the paths in the patch files. I've also tried without --dry-run in case that was the problem.

Any other ideas?

bazo80 commented 11 months ago

Hello bfoz,

the problem is carriage return/line feed related. If you are using the gnu patch, you could convert the patch files with: dos2unix file.patch After that, the gnu patch binary should be succeeding

noob502 commented 3 months ago

@bfoz did you apply this patch in Yocto build ?

andresmanelli commented 3 months ago

@bfoz in 32.6 the nvidia Kernel modules live out of tree in the nvidia-oot directory.

So you need to apply them in the kernel or in nvidia-oot, as it fits.

Also, the csi stream write functions are not there in 32.6 so there is a patch that does not apply (you can add the missing code if necessary).

Beware that the nvcsi registers are protected behind a firewall in the default mb2 so you need to add some extra rules and reflash (you can find this in the forums)

Hope it helps.

I can share what I've done if anyone is interested, but I saw an open ticket to support 36.2 so maybe this will come soon.

noob502 commented 3 months ago

@bfoz I am working on 35.4.1; yes, they have milestones for 35.4.1 and 36.x, but I do not know when they will be available.

I am working with Jetson Orin Nano Devkit 8GB variation. I am building my custom image using Yocto-OpemEmbedded reference distribution. I have added the driver and device tree following Integrate the driver in your own BSP instructions. Later, I added my custom distro within the kernel recipe with the vc_mipi patches. It flashed without any error, but I could not see any traces of vc_mipi in the live image.

According to your last comment, I think I applied them in the kernel using the bb append file. Any idea am I doing it right ?

bfoz commented 2 months ago

I was trying to apply the patches using buildroot.

I'm no longer working on the project that triggered this PR, so I haven't kept up with the latest changes.

noob502 commented 1 month ago

Hello bfoz,

the problem is carriage return/line feed related. If you are using the gnu patch, you could convert the patch files with: dos2unix file.patch After that, the gnu patch binary should be succeeding

Can you please explain more about this ?