Difference between revisions of "CaspaPX"

From Gumstix User Wiki
Jump to: navigation, search
m (relay)
Line 1: Line 1:
The MT9V032 sensor at the heart off the CaspaPX is not yet supported in the kernel, so a little work is necessary to get the camera up and running.
+
For information about the Caspa camera boards, go to the [http://wiki.gumstix.org/index.php?title=Caspa Caspa wiki page].
 
+
OMAP35x processors have dedicated hardware for capturing and processing data from image sensors. The CaspaPX camera sensor outputs raw 10-bit Bayer images which is transfered to the Image Signal Processor (ISP) via a parallel interface. The ISP contains various submodules that can be exported as Video for Linux (V4L2) devices in /dev. For additional hardware information see the external links section.
+
 
+
[[Image:Altoids.jpg|thumb|300px]]
+
 
+
== Quickstart ==
+
 
+
=== Install Pre-built Kernel ===
+
 
+
The easiest way to get started is to replace the kernel and modules of an existing image. This has been tested on an Overo Fire with a Tobi expansion board using the desktop image available [http://www.sakoman.com/feeds/omap3/glibc/images/overo/201011150741/ here].
+
 
+
Get the kernel and modules.
+
$ wget http://cumulus.gumstix.org/images/angstrom/misc/caspapx/uImage-2.6.34
+
$ wget http://cumulus.gumstix.org/images/angstrom/misc/caspapx/modules-2.6.34.tgz
+
 
+
Copy to a bootable microSD card.
+
$ tar -xf modules-2.6.34.tgz -C /media/mmcblk0p2/
+
$ cp uImage-2.6.34 /media/mmcblk0p1/uImage
+
$ cp uImage-2.6.34 /media/mmcblk0p2/boot/uImage
+
 
+
Alternatively, if you have a network connection, you can copy the files without removing the microSD.
+
$ tar -xf modules-2.6.34.tgz
+
$ scp -r lib root@overo:/
+
$ scp uImage-2.6.34 root@overo:/boot/uImage
+
$ scp uImage-2.6.34 root@overo:/media/mmcblk0p1/uImage
+
$ ssh root@overo 'depmod; shutdown -r now'
+
 
+
=== Test ===
+
 
+
From the serial console:
+
 
+
# export DISPLAY=:0.0
+
 
+
# gst-launch v4l2src ! xvimagesink
+
''or''
+
# mplayer tv:// -tv driver=v4l2:device=/dev/video0
+
 
+
From the desktop:
+
 
+
<left-click> Applications > Multimedia > Cheese
+
 
+
If video0 doesn't appear in /dev you might have to load the driver manually.
+
 
+
# depmod
+
# modprobe mt9v032
+
 
+
== Bitbake ==
+
 
+
You can build the kernel and modules using bitbake. This allows you to incorporate the kernel with camera driver into an image of your design.
+
 
+
$ cd ~/overo-oe/org.openembedded.dev
+
$ git pull origin overo
+
$ bitbake linux-omap3-caspapx
+
 
+
When the build completes, the kernel and modules will appear in ~/overo-oe/tmp/deploy/glibc/images/overo.
+
 
+
== Customization ==
+
 
+
This section describes how to customize the camera driver and kernel for your needs.
+
 
+
=== 2.6.34 ===
+
 
+
Get the kernel source that is used in the Gumstix kernel recipe (~/overo-oe/org.openmebedded.dev/recipes/linux/linux-omap3_2.6.34.bb) and create a new branch from the recipe SRCREV.
+
$ cd ~
+
$ git clone git://www.sakoman.com/git/linux-omap-2.6.git
+
$ cd linux-omap-2.6
+
$ git checkout -b 2.6.34 cb89736af28f583598e49a05249334a194d00f1d
+
 
+
Get the patch.
+
$ wget http://cumulus.gumstix.org/sources/mt9v032-2.6.34.patch
+
$ patch -p1 < mt9v032-2.6.34.patch
+
 
+
Get the kernel configuration. This is the same one used for the linux-omap3-caspapx image.
+
$ wget http://cumulus.gumstix.org/sources/mt9v032-2.6.34.defconfig
+
$ cp mt9v032-2.6.34.defconfig .config
+
 
+
If you haven't done so yet, you'll need to [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Setting-up-a-build-environment/111.html set up your build environment]. Build the console image. This will ensure that the cross compiler, binutils, and libraries need to compile the kernel are installed.
+
$ bitbake omap3-console-image
+
 
+
Add the cross compiler to your path and configure the kernel. The cross compiler location depends on the architecture of your build machine.
+
''32-bit processors''
+
$ export PATH=/home/<username>/overo-oe/tmp/sysroots/i686-linux/usr/armv7a/bin:${PATH} <br />
+
''64-bit processors''
+
$ export PATH=/home/<username>/overo-oe/tmp/sysroots/x86_64-linux/usr/armv7a/bin:${PATH}
+
 
+
Build kernel and modules
+
$ make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage
+
$ make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- modules
+
 
+
Install modules
+
$ mkdir ~/linux-omap-2.6/modules
+
$ make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- INSTALL_MOD_PATH=./modules modules_install
+
 
+
=== Other Kernel Versions ===
+
 
+
The ISP code used for the 2.6.34 patch came from the arago-project. This is the OMAP3 PSP kernel integration/staging tree
+
$ git remote add git://arago-project.org/git/projects/linux-omap3.git aragoOMAP3 PSP kernel integration/staging tree
+
$ git fetch arago
+
$ git checkout -b arago
+
 
+
The V4L2 subdevice framework offers a way to configure the Image Signal Processor pipeline from userspace. This is currently under active development and users wishing to make use of this should visit the Media controller development repository [http://git.linuxtv.org/pinchartl/media.git here]. This contains the bleeding edge Video for Linux media framework, ISP, and MT9V032 drivers.
+
 
+
=== MT9V032 Driver ===
+
 
+
If you want to take advantage of an unimplemented sensor feature, change defaults, etc., you need to modify the driver source. After you've made a change you can use a script like the following to quickly test your new driver.
+
 
+
#! /bin/bash <br>
+
TARGET_OVERO="root@10.0.1.15"
+
make -j8 ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- modules
+
ssh $TARGET_OVERO 'rmmod mt9v032'
+
scp drivers/media/video/mt9v032.ko $TARGET_OVERO:/lib/modules/2.6.34/kernel/drivers/media/video/
+
ssh $TARGET_OVERO 'insmod /lib/modules/2.6.34/kernel/drivers/media/video/mt9v032.ko'
+
ssh $TARGET_OVERO 'mplayer -display :0.0 tv:// -tv driver=v4l2:device=/dev/video0'
+
 
+
=== Image Signal Processor ===
+
 
+
There is some code that you can't modularize and modifying means rebuilding the kernel. Such is the case for the ISP code which is used by board-overo.c for hardware configuration. Another script like that in the previous section can be very useful.
+
 
+
This script rebuilds the kernel, copies it to the COM, and resets:
+
 
+
#! /bin/bash <br />
+
TARGET_OVERO="root@10.0.1.15"
+
make -j8 ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage;
+
scp arch/arm/boot/uImage $TARGET_OVERO:/boot/uImage;
+
scp arch/arm/boot/uImage $TARGET_OVERO:/media/mmcblk0p1/uImage
+
ssh $TARGET_OVERO 'shutdown -r now'
+
 
+
This is useful for adjusting the filters, white balance, and color blending coefficients used by the ISP preview module. The preview module is used for doing hardware conversion from 10-bit Bayer to YUV. If you are having color problems - especially under certain lighting conditions but not others - look at '''isppreview.c''' and the gamma correction tables in '''drivers/media/video/isp/'''
+
 
+
== Tuning ==
+
 
+
=== Module Parameters ===
+
By default, auto exposure, auto gain, and high dynamic range are all enabled. You can disable any or all of these to suit your needs by reloading the driver.
+
 
+
Get a list of driver parameters.
+
# modinfo mt9v032
+
filename:      /lib/modules/2.6.34/kernel/drivers/media/video/mt9v032.ko
+
license:        GPL
+
author:        Ignacio Garcia Perez <iggarpe@gmail.com>
+
description:    mt9v032 camera sensor driver
+
srcversion:    A46920FD64C35A2645E0D54
+
alias:          i2c:mt9v032
+
depends:       
+
vermagic:      2.6.34 mod_unload modversions ARMv7
+
parm:          sensor_type:Sensor type: "color" or "mono" (charp)
+
parm:          auto_exp:Initial state of automatic exposure (int)
+
parm:          auto_gain:Initial state of automatic gain (int)
+
parm:          hdr:High dynamic range (int)
+
parm:          low_light:Enable companding (int)
+
parm:          hflip:Horizontal flip (int)
+
parm:          vflip:Vertical flip (int)
+
 
+
Depending on the light level, auto exposure might reduce the framerate as low as 15 frames per second. You can disable auto exposure like so:
+
# rmmod mt9v032;
+
# insmod /lib/modules/2.6.34/kernel/drivers/media/video/mt9v032.ko auto_exp=0
+
 
+
If this makes your image too dark you can disable auto gain and enable companding mode (more information [http://www.aptina.com/assets/downloadDocument.do?id=668 here]).
+
# rmmod mt9v032
+
# insmod /lib/modules/2.6.34/kernel/drivers/media/video/mt9v032.ko auto_exp=0 auto_gain=0 low_light=1
+
 
+
<!-- === Userspace control (IOCTL) === -->
+
 
+
== External Links ==
+
 
+
[http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=spruf98m&fileType=pdf OMAP35x Technical Reference Manual]
+
 
+
[http://www.aptina.com/assets/downloadDocument.do?id=668 MT9V032 Datasheet]
+
 
+
[http://pubs.gumstix.com/boards/CASPAPX/PCB30009-R2496/ CaspaPX CAD files]
+

Revision as of 16:38, 28 February 2011

For information about the Caspa camera boards, go to the Caspa wiki page.