codo/readme.md
2025-05-02 13:37:23 +03:00

130 lines
3.1 KiB
Markdown

# TK1-SOM AR0330 Camera Setup Guide
## Hardware Information
- The TK1-SOM supports dual CSI-2 ports
- AR0330 sensor: 3MP, 1/3" CMOS
- Camera connects through CSI interface and I2C for control
## System Requirements
- TK1-SOM running L4T (Linux for Tegra) R21.3
- Kernel Version: 3.10.40
- AR0330 driver built into kernel (CONFIG_VIDEO_AR0330=y)
## AR0330 Camera Module Conflict Resolution
The AR0330 camera on TK1-SOM has a known issue with module conflicts. The `nvhost_vi` and `tegra_camera` modules both try to register the VI driver, causing initialization failures.
### Manual Fix
To manually fix the issue:
1. Check if the `nvhost_vi` module is loaded:
```bash
lsmod | grep -i vi
```
2. Unload `nvhost_vi` and load `tegra_camera`:
```bash
sudo rmmod nvhost_vi
sudo modprobe tegra_camera
```
3. Verify that the camera modules are now loaded correctly:
```bash
lsmod | grep -E "video|tegra|camera"
```
Expected output:
```
tegra_camera 20484 0
soc_camera_platform 2106 1
videobuf2_dma_contig 8796 1 tegra_camera
```
4. Check if the video device node has been created:
```bash
ls -l /dev/video*
```
### Automatic Fix (Recommended)
For a permanent solution that works across reboots, create an init script:
1. Create the init script:
```bash
sudo tee /etc/init.d/camera-module-fix << EOF
#!/bin/sh
### BEGIN INIT INFO
# Provides: camera-module-fix
# Required-Start: \$local_fs \$remote_fs
# Required-Stop: \$local_fs \$remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fix camera module loading
### END INIT INFO
case "\$1" in
start)
echo "Unloading nvhost_vi module..."
rmmod nvhost_vi || true
echo "Loading tegra_camera module..."
modprobe tegra_camera || true
;;
stop)
;;
*)
echo "Usage: /etc/init.d/camera-module-fix {start|stop}"
exit 1
;;
esac
exit 0
EOF
```
2. Make the script executable and enable it to run at boot time:
```bash
sudo chmod +x /etc/init.d/camera-module-fix
sudo update-rc.d camera-module-fix defaults
```
3. Run the script manually to apply changes immediately:
```bash
sudo /etc/init.d/camera-module-fix start
```
## Testing the Camera
1. Verify the camera is working by checking its properties:
```bash
v4l2-ctl --all --device /dev/video0
```
2. Test camera stream with GStreamer:
```bash
gst-launch-1.0 nvcamerasrc ! 'video/x-raw(memory:NVMM),width=1280,height=720,format=NV12,framerate=30/1' ! nvvidconv ! nvoverlaysink
```
## Troubleshooting
If the camera is still not detected:
1. Check physical connections to CSI port
2. Verify I2C detection (AR0330 should be on bus 2 at address 0x10 or 0x18):
```bash
for i in {0..5}; do echo "=== i2c-$i ==="; sudo i2cdetect -y $i; done
```
3. Check kernel logs for errors:
```bash
dmesg | grep -i "camera\|ar0330\|tegra\|vi"
```
## Additional Resources
- TK1-SOM Reference Guide
- AR0330 Datasheet
- L4T Documentation