Skip to content

TechNexion-Vision/tn-rpi-camera-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tn-rpi-camera-driver

Technexion

Producer: Technexion License: GPL v2

Introduction

TechNexion Embedded Vision Solutions provide embedded system developers access to high-performance, industrial-grade camera solutions to accelerate their time to market for embedded vision projects.

Version 0.0.1 (Beta)


Support System Version

Support Camera Modules

MIPI Cameras

  • TEVS-AR0144-C
  • TEVS-AR0145-M
  • TEVS-AR0234-C
  • TEVS-AR0521-C
  • TEVS-AR0522-C
  • TEVS-AR0522-M
  • TEVS-AR0821-C
  • TEVS-AR0822-C
  • TEVS-AR1335-C

More Camera Products Details...

Supported Raspberry Pi


Install TN Camera on Raspberry Pi

Adaptor for Raspberry Pi Camera

TEVS-RPI15 Adaptor for TEVS

Connect TEVS camera and TEVS-RPI15 adaptor to Raspberry Pi directly.


Method 1 - Using Technexion Pre-built modules, only for kernel 6.1.77-v8l

  1. Make a SD card with "Raspberry Pi OS (64-bit) 2023-12-06" on Raspberry Pi Imager.

  2. Boot RPI4 with SD card.

  3. Download pre-built modules.

$ wget https://download.technexion.com/demo_software/EVK/RPI/RPI4/pre-built-modules/latest/tn_camera_module_rpi4_6.1.y.tar.gz
  1. Uncompress the modules.
$ tar -xf tn_camera_module_rpi4_6.1.y.tar.gz
  1. Run installation script.
$ cd tn_camera_module_rpi4_6.1.y/
$ sh tn_install.sh
****** TechNexion Camera Driver Installation ******
This installation is easy to install TechnNexion Camera Drivers for Raspberry Pi 4.
Before start to install camera driver, You should BACKUP your image and config
to avoid any file you lost while installing process.
Do you want to continue?[Y/n]y
Continuing with the installation...
Install TN-CAM modules: tevs.ko.xz
Installed TN-CAM module file Done.
Install TN-CAM DTBO file: tevs-rpi15.dtbo
Installed TN-CAM DTBO file Done.
Add TN-CAM Configuration for modules: tevs-rpi15
Install TN-CAM service...
Launch TN-CAM Service...
Created symlink /etc/systemd/system/multi-user.target.wants/tn_cam.service → /etc/systemd/system/tn_cam.service.
Finish Camera Driver Installation. Return Code:[1]
You should Reboot Device to enable TEVS Cameras.
Do you want to reboot now?[Y/n]y
Rebooting....

Method 2 - Build drivers from source code (cross-compiling)

  1. You can reference Raspberrypi Documentation - Building the kernel.

  2. Make sure the dependencies

$ sudo apt install -y git bc bison flex libssl-dev make libc6-dev libncurses5-dev

# Install the 64-bit toolchain for a 64-bit kernel
$ sudo apt install -y crossbuild-essential-arm64
  1. Get the kernel sources
# raspberrypi linux kerbel
$ git clone --depth=1 -b rpi-6.1.y https://github.com/raspberrypi/linux

# technexion rpi camera driver
$ git clone --depth=1 -b tn_rpi_kernel-6.1 https://github.com/TechNexion-Vision/tn-rpi-camera-driver.git
  1. Copy TN rpi camera driver to raspberrypi linux kernel
$ cp -rv tn-rpi-camera-driver/drivers/media/i2c/* linux/drivers/media/i2c/
$ cp -rv tn-rpi-camera-driver/arch/arm64/boot/dts/overlays/* linux/arch/arm64/boot/dts/overlays/
  1. Build sources
$ cd linux
$ KERNEL=kernel8

# default configuration
$ make distclean
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig

# config camera
$ make menuconfig
# -> Device Drivers
#   -> Multimedia support
#     -> Media ancillary drivers
#       -> Camera sensor devices
#         -> TechNexion TEVS sensor support
#            Set "VIDEO_TEVS" to module,
#            Press "m", save to original name (.config) and exit

# build kernel
$ mkdir -p modules
$ MODULE_PATH=./modules
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LOCALVERSION="-tn-raspi" -j$(nproc) Image modules dtbs
$ sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_PATH=$MODULE_PATH modules_install
  1. Plug in the SD card which burned "Raspberry Pi OS (64-bit) 2023-12-06" to PC

  2. Install onto the SD card

$ sudo cp arch/arm64/boot/Image /media/$(users)/bootfs/$KERNEL.img
$ sudo cp arch/arm64/boot/dts/broadcom/*.dtb /media/$(users)/bootfs
$ sudo cp arch/arm64/boot/dts/overlays/*.dtb* /media/$(users)/bootfs/overlays/
$ sudo cp arch/arm64/boot/dts/overlays/README /media/$(users)/bootfs/overlays/
# you can use "make kernelversion" to check kernel version
$ sudo cp -ra modules/lib/modules/$(make kernelversion)-v8-tn-raspi/ /media/$(users)/rootfs/lib/modules/.
$ sync
  1. Boot RPI4 with SD card.

  2. Modify the config.txt file to add camera configuraion.

$ sudo nano /boot/firmware/config.txt

# Automatically load overlays for detected cameras
> camera_auto_detect=0
> dtoverlay=tevs-rpi15,media-controller=0

Modify camera_auto_detect=0 and add dtoverlay=tevs-rpi15,media-controller=0 after the line. And then Ctrl+x > y > Enter to save file.

  1. Restart system.
$ sudo reboot

Bring up Camera by GStreamer

If you succeed in initialing the camera, you can follow the steps to open the camera.

  1. Check the media deivce. (The /dev/mediaN node number may move as they are not fixed allocations).
$ media-ctl -d /dev/mediaN -p
Device topology
- entity 1: tevs 10-0048 (1 pad, 1 link)
            type V4L2 subdev subtype Sensor flags 0
            device node name /dev/v4l-subdev0
        pad0: Source
                [fmt:UYVY8_2X8/640x480@1/30 colorspace:srgb xfer:srgb ycbcr:601 quantization:full-range
                 crop.bounds:(0,0)/640x480
                 crop:(0,0)/640x480]
                -> "unicam-image":0 [ENABLED,IMMUTABLE]

- entity 3: unicam-image (1 pad, 1 link)
            type Node subtype V4L flags 1
            device node name /dev/video0
         pad0: Sink
                <- "tevs 10-0048":0 [ENABLED,IMMUTABLE]
  1. Install GStreamer.
$ sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa \
gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-pulseaudio
  1. List device support formats and resolutions.
$ gst-device-monitor-1.0
Device found:

        name  : unicam
        class : Video/Source
        caps  : video/x-raw, format=UYVY, width=1280, height=800, pixel-aspect-ratio=1/1, framerate=60/1
                video/x-raw, format=UYVY, width=1280, height=720, pixel-aspect-ratio=1/1, framerate=60/1
                video/x-raw, format=UYVY, width=640, height=480, pixel-aspect-ratio=1/1, framerate=60/1
                video/x-raw(format:Interlaced), format=UYVY, width=640, height=480, pixel-aspect-ratio=1/1, framerate=60/1, interlace-mode=alternate
        properties:
                udev-probed = true
                device.bus_path = platform-fe801000.csi
                sysfs.path = /sys/devices/platform/soc/fe801000.csi/video4linux/video0
                device.subsystem = video4linux
                device.product.name = unicam
                device.capabilities = :capture:
                device.api = v4l2
                device.path = /dev/video0
                v4l2.device.driver = unicam
                v4l2.device.card = unicam
                v4l2.device.bus_info = platform:fe801000.csi
                v4l2.device.version = 393549 (0x0006014d)
                v4l2.device.capabilities = 2241855489 (0x85a00001)
                v4l2.device.device_caps = 85983233 (0x05200001)
        gst-launch-1.0 v4l2src ! ...
  1. Bring up the camera (/dev/video0) with 640x480 by Gstreamer pipeline.
$ DISPLAY=:0 gst-launch-1.0 v4l2src device=/dev/video0 ! \
"video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480" ! \
fpsdisplaysink video-sink=glimagesink sync=false
  1. Change resolution with 1280x720 and bring up by Gstreamer pipeline directly.
$ DISPLAY=:0 gst-launch-1.0 v4l2src device=/dev/video0 ! \
"video/x-raw, format=(string)UYVY, width=(int)1280, height=(int)720" ! \
fpsdisplaysink video-sink=glimagesink sync=false
  1. List all camera controls using v4l2-ctl.
$ v4l2-ctl -d /dev/v4l-subdev0 --list-ctrls

Troubleshooting


WIKI Pages

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published