Difference between revisions of "Dev/Caspa"

From PaparazziUAV
Jump to navigation Jump to search
 
(94 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page describes the ongoing work to fully integrate a [http://www.gumstix.com/store/product_info.php?products_id=254 Caspa FS camera] on a [[Lisa]]/L board. Any advices/suggestions/contributions are welcome.
This page describes the work to fully integrate a [http://www.gumstix.com/store/product_info.php?products_id=254 Caspa FS camera] on a [[Lisa]]/L board. Any advices/suggestions/contributions are welcome.


= Final Goal =
== Final Goal ==
The final goal is to have a [http://www.gumstix.com/store/product_info.php?products_id=254 Caspa FS camera] connected to the Overo chip on a [[Lisa]]/L board. The Overo chip should be able to communicate with the STM32 via SPI. The link shall be used to transmit the result of the image processing computed by the Overo. However this should be flexible enough to let some room for the developer to decide which processing to do and which kind of data to send.
The final goal is to have a [http://www.gumstix.com/store/product_info.php?products_id=254 Caspa FS camera] connected to the Overo chip on a [[Lisa]]/L board. The Overo chip should be able to communicate with the STM32 via SPI. The link shall be used to transmit the result of the image processing computed by the Overo. However this should be flexible enough to let some room for the developer to decide which processing to do and which kind of data to send. Digital video streaming to the groundstation is also interesting.


= Methods =
The following lists the steps that are deemed to be important in achieving the final goal.


# Bitbake a kernel for Overo that includes the camera modules and the SPI modules
# Bitbake a kernel for STM32 that includes the SPI modules


== Caspa camera on an Overo expansion board ==
As a first step a simple connection between the camera and the Overo was tried using an Overo expansion board, i.e. not the the [[Lisa]]/L board.


=== Hardware components ===
* [http://www.gumstix.com/store/product_info.php?products_id=254 Caspa FS camera]
* [http://www.gumstix.com/store/product_info.php?products_id=258 CLB047 cable]
* [http://www.gumstix.com/store/index.php?cPath=33 Overo board]
* [http://www.gumstix.com/store/product_info.php?products_id=237 Chestnut43 expansion board]
* [http://www.gumstix.com/store/product_info.php?products_id=244 LCD Touch Screen]


=== Step-by-step ===


> Hardware components
===== Create a bootable MicroSD card if you do not have one =====
1 Pixhawk (Gumstix) camera
1 CLB047 (Gumstix) flat cable
1 Overo board (Gumstix) + expansion board + LCD touchscreen


> Procedure
[http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat Follow this] and use LABEL1 as 'mmcblk0p1' and LABEL2 as 'mmcblk0p2'.


1. Create a bootable MicroSD card if you do not have one
===== Load a pre-built standard image =====


http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat
sudo chown [user_name] /media/mmcblk0p1
(use LABEL1 as mmcblk0p1 and LABEL2 as mmcblk0p2)
sudo chown [user_name] /media/mmcblk0p2
wget http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/omap3-desktop-nand-image-overo-booted.tar.bz2
tar -xjf omap3-desktop-nand-image-overo-booted.tar.bz2 -C /media/mmcblk0p2    // ignore errors
wget http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/MLO
wget http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/u-boot.bin
wget http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/uImage
cp MLO /media/mmcblk0p1
cp u-boot.bin /media/mmcblk0p1
cp uImage /media/mmcblk0p1


2. Load it with a pre-built standard image
When populating mmcblk0p1 it is important to copy the MLO first otherwise it will not be found by the Overo booting mechanism


Go to http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/
===== Replace some files to get the camera modules working =====
Untar the content of 'omap3-desktop-nand-image-overo-booted.tar.bz2' to the partion mmcblk0p2
Put the files 'MLO', 'u-boot.bin', 'uImage' into the partition mmcblk0p1


3. Replace some files to get the camera modules working
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
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


Download:
===== Attach the camera to the Overo board =====
http://cumulus.gumstix.org/images/angstrom/misc/caspapx/uImage-2.6.34
http://cumulus.gumstix.org/images/angstrom/misc/caspapx/modules-2.6.34.tgz


Do:
Insert the white ribbon cable contact-side-up into the Caspa connector and contact side down into the Overo connector.
$ tar -xf modules-2.6.34.tgz -C /media/mmcblk0p2/
 
$ cp uImage-2.6.34 /media/mmcblk0p1/uImage
===== Insert MicroSD card in the Overo board =====
$ cp uImage-2.6.34 /media/mmcblk0p2/boot/uImage
 
===== Set environment variables =====
* Connect the expansion board to the host machine via USB B (Console)
* On the host machine do:
[sudo apt-get install ckermit]
kermit -l /dev/ttyUSB0
C-Kermit>set flow-control none
C-Kermit>set carrier-watch off
C-Kermit>set speed 115200
/dev/ttyUSB0, 115200 bps
C-Kermit>connect
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
 
You have now a console connection to the Overo
 
* Power-up the expansion board
* Hit 'Enter' to interrupt the boot sequence
* Type in the console:
nand erase 240000 20000
reset
 
This makes the Overo to read the environment variables defined by the kernel in the MicroSD. You just have to do this once after setting up the card.
 
* Hit 'Enter' to interrupt the boot sequence again
* Type in the console:
setenv defaultdisplay lcd43; saveenv;
reset
 
You just have to do this once after setting up the card.
 
===== Get the image =====
 
* Let the Overo boot properly
* Touch the screen and calibrate it as indicated. You just have to do this once after setting up the card.
* Type in the console:
overo login: root
export DISPLAY=:0.0
mplayer tv:// -tv driver=v4l2:device=/dev/video0 -x 480 -y 272 -vo x11
 
The camera image should appear on the LCD display.
 
Based on [http://wiki.gumstix.org/index.php?title=Caspa_camera_boards Gumstix wiki].
 
== WiFi digital video streaming ==
Here we show how to achieve WiFi digital video streaming with the [[Lisa]]/L board. This setup can be used as a parallel system to the autopilot running in the STM32. However, as connection from the Overo to the STM32 is envisaged we prepare the Overo kernel for SPI support.
 
=== Hardware components ===
* [http://www.gumstix.com/store/product_info.php?products_id=254 Caspa FS camera]
* [http://www.gumstix.com/store/product_info.php?products_id=258 CLB047 cable]
* [http://www.gumstix.com/store/index.php?cPath=33 Overo board]
* [http://www.gumstix.com/store/product_info.php?products_id=173 Antenna]
* [[Lisa]]/L
 
=== Step-by-step ===
The general idea is to build a Linux kernel and a filesystem image for the Overo board which supports both the Caspa camera (sensor mt9v032) and SPI. Aside from this we use the DSP for encoding the image and WiFi for streaming to the groundstation.
 
It helps if you have notions of [http://www.gumstix.org/software-development/open-embedded.html Bitbake & OpenEmbedded] and [http://git-scm.com/ git]. Otherwise you can try doing it in a mindless way and it should also work. For that follow only the steps marked with a (*).
 
===== Get the Overo toolchain =====
$ cd ~
$ mkdir overo-oe
$ cd overo-oe
$ git clone git://gitorious.org/gumstix-oe/mainline.git org.openembedded.dev
$ cd org.openembedded.dev
$ git checkout --track -b overo4lisa-2011.03 origin/overo-2011.03
 
$ cd ~/overo-oe
$ git clone git://git.openembedded.net/bitbake bitbake
$ cd bitbake
$ git checkout 1.10.2
 
$ cd ~/overo-oe
$ cp -r org.openembedded.dev/contrib/gumstix/build .
$ source build/profile
 
This last command is required whenever you want to use bitbake. More info [http://www.gumstix.org/software-development/open-embedded/61-using-the-open-embedded-build-system.html here].
 
===== Changes to the original repository =====
In org.openembedded.dev/conf/machine/overo.conf edit the lines:
'SERIAL_CONSOLE = "115200 ttyO2' to 'SERIAL_CONSOLE = "115200 ttyS2'
'PREFERRED_PROVIDER_virtual/kernel = "linux-omap3"' to 'PREFERRED_PROVIDER_virtual/kernel = "linux-omap3-caspapx"'
This will make kernel 2.6.34 to be compiled instead of 2.6.39 which has no support for the camera at the time of writing.
 
Now we need to give the right configuration before compiling the kernel. Here you can choose to do it yourself:
$ bitbake -c menuconfig linux-omap3-caspapx
$ cp ~/overo-oe/tmp/work/overo-angstrom-linux-gnueabi/linux-omap3-caspapx-2.6.34-r101/git/.config ~/overo-oe/org.openembedded.dev/recipes/linux/linux-omap3-caspapx/overo/defconfig
Add support to the mt9v032 sensor, disable touchscreens and LCD displays (which use the same I/O lines as SPI) and add support to SPI.
 
'''Or''' you can use the same configuration as I did:
 
$ wget https://raw.github.com/gist/1094791/a97f9a16556d3986ba1ceabd2ab9d4898b75244f/linux-omap3-caspapx-kernelConfig
$ cp linux-omap3-caspapx-kernelConfig ~/overo-oe/org.openembedded.dev/recipes/linux/linux-omap3-caspapx/overo/defconfig
 
Notice in the configuration file the line 'CONFIG_SOC_CAMERA_MT9V032=m'. This means that the mt9v032 sensor driver will be added to the kernel as a module. This is a better approach because then you can load and unload it for changing operational configurations like auto exposure features.
 
For SPI support we have to patch de kernel. Do:
$ wget https://raw.github.com/gist/1109520/5fd3137aca87e2b8557534a53b2cee2c428bc5cb/spidev_enable.patch ~/overo-oe/org.openembedded.dev/recipes/linux/linux-omap3-caspapx/spidev_enable.patch
$ wget https://raw.github.com/gist/1109520/bc00de1dc37b249f4fe109fe0696c9d371724825/linux-omap3-caspapx_2.6.34_mod.bb ~/overo-oe/org.openembedded.dev/recipes/linux/linux-omap3-caspapx_2.6.34.bb
This will result in two SPI devices being listed under /dev, spidev1.0 and spidev1.1. In the [[Lisa]]/L board we use spidev1.1 for communication with the STM32.
 
Then, I modified the original filesystem image recipe so that every necessary components are included. Do:
 
$ wget https://raw.github.com/gist/1094809/bf6ce898134fe4ef96bfc0ba7ecac7577583d2b8/omap3-overo4lisa-image.bb
$ cp omap3-overo4lisa-image.bb ~/overo-oe/org.openembedded.dev/recipes/images/omap3-overo4lisa-image.bb


4. Attach the camera to the Overo board
Finally, follow the step 'Building task-gstreamer-ti' in [http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=81:gumstix-dsp-gstreamer&catid=35:gumstix&Itemid=67 jumpnowtek] but do not run the last 2 commands.


Insert the white ribbon cable contact-side-up into the Caspa connector and contact side down into the Overo connector.
===== Compiling the kernel =====
$ bitbake -c clean linux-omap3-caspapx
$ bitbake linux-omap3-caspapx
$ bitbake x-load
$ bitbake u-boot-omap3
 
===== Building the filesystem image =====
$ bitbake omap3-overo4lisa-image
 
===== Load a bootable microSD card =====
See [[Dev/Caspa#Create_a_bootable_MicroSD_card_if_you_do_not_have_one | Create a bootable MicroSD card if you do not have one]].
$ cd ~/overo-oe/tmp/deploy/glibc/images/overo
$ cp MLO-overo-1.44+r20+gitr24b8b7f41a83540433024854736518876257672c-r20 /media/mmcblk0p1/MLO
$ cp u-boot-overo-2010.9+r1+git1e4e5ef0469050f014aee1204dae8a9ab6053e49-r1.bin /media/mmcblk0p1/u-boot.bin
$ cp uImage-2.6.34-r101-overo.bin /media/mmcblk0p1/uImage
$ tar -xvf Angstrom-omap3-overo4lisa-image-glibc-ipk-2011.03-overo.rootfs.tar.bz2 -C /media/mmcblk0p2
$ tar -xf modules-2.6.34-r101-overo.tgz -C /media/mmcblk0p2
 
File names might change a bit. Change the commands accordingly.
 
In /media/mmcblk0p2/etc/inittab edit the line:
'S:2345:respawn:/sbin/getty 115200 ttyO2' to 'S:2345:respawn:/sbin/getty 115200 ttyS2'
 
This is due to an incompatibility among kernel versions. The earlier ones use the ttyS2 console while the newer use ttyO2. Not editing this line prevents us from using the console.
 
===== Load a bootable microSD card with a prebuilt kernel and filesystem (*) =====
 
ToDo
 
===== Setup WiFi connection (*)=====
In /media/mmcblk0p2/etc/network/interfaces add the lines:
auto wlan0
iface wlan0 inet static
  wireless_mode ad-hoc
  wireless_channel 1
  wireless_essid caspa
  address 192.168.0.202
  netmask 255.255.255.0
 
Setup (p.e via NetworkManager) a similar network in the groundstation side and give to this the address '192.168.0.200'. Of course other configurations are possible.
 
===== Edit u-Boot parameters (*) =====
* Put the microSD card in the Overo board.
* Connect the expansion board to the host machine via USB B (Console)
* On the host machine do:
[sudo apt-get install ckermit]
kermit -l /dev/ttyUSB0
C-Kermit>set flow-control none
C-Kermit>set carrier-watch off
C-Kermit>set speed 115200
/dev/ttyUSB0, 115200 bps
C-Kermit>connect
 
You have now a console connection to the Overo.
 
* Power-up the expansion board
* Hit 'Enter' to interrupt the boot sequence
* Type in the console:
nand erase 240000 20000
reset
* Interrupt again the boot sequence
* Follow the step 'U-Boot Kernel Parameters' in [http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=81:gumstix-dsp-gstreamer&catid=35:gumstix&Itemid=67 jumpnowtek] (Gumstix procedure)
* Finally type:
reset
 
===== Streaming (*) =====
Now the Overo is ready to start streaming. Set up the connection in the groundstation with NetworkManager. A blue LED should light up in the Overo board indicating that it is wireless connected. Use the following:
$ wget https://raw.github.com/gist/1094865/efc9578a0fa23784636d0ef02d9281e8b490dcca/videostreaming.sh
$ sudo chmod +x videostreaming.sh
$ ./videostreaming.sh
 
This connection was tested in open field with a simple laptop without external antenna. Ranges of 75m are possible. However the image quality in bright lighting conditions is low for all distances.
 
Based on [http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=81:gumstix-dsp-gstreamer&catid=35:gumstix&Itemid=67 jumpnowtek].
 
=== Troubleshooting ===
* Gumstix ships two types of this camera. One with IR filter (version VL - PCB30009C) and one without (version FS - PCB30009). However the board might be mislabeled and so the only way to know your version is to unmount the lenses and check for the IR filter.
 
* If you are OK with disabling the auto exposure driver feature this can increase a lot the image quality and reliability. For changing driver parameters you have to add mt9v032 sensor support to the kernel as a module and not as a built-in feature. Then:
$ rmmod mt9v032
$ insmod /lib/modules/2.6.34/kernel/drivers/media/video/mt9v032.ko auto_exp=0
 
For checking all the possible parameters do:
$ modinfo mt9v032
 
=== Inflight testing ===
'''Caution!''' During our first tests the high usage of the WiFi link for streaming resulted in loss of RC. Luckily the autopilot took over until we could issue a shutdown command to the Overo board. After that we changed the WiFi configurations to stick to channel 1 but this was not tested yet and we still do not know if it solves the problem.
 
== Frame retrieval in C code ==
 
The next logical step is to manipulate camera images in C code. For that we will be using [http://opencv.willowgarage.com/wiki/Welcome OpenCV]. This framework includes a full range of image processing tools and algorithms.


5. Insert MicroSD card in the Overo board
=== Cross compiling ===


6. Set environment variables
For enabling cross compilation (compilation of Overo programs in the development machine) do:
$ cd ~/overo-oe
$ bitbake opencv


Connect the expansion board to the host machine via USB
This compiles the OpenCV library for inclusion in our C programs. A sample program that retrieves a frame and saves it as a .JPG file and its Makefile can be downloaded by doing:
$ wget https://raw.github.com/gist/1108913/43893c3a266741077523eb72d8234978e0659119/helloImage.c
$ wget https://raw.github.com/gist/1108913/9670763f37466a1232a5a026d18e3d347d4eae1f/Makefile


On the host machine do:
If the network connection is enabled you can get a capture in your development machine by doing:
sudo apt-get install ckermit
$ make helloImage install
$ kermit -l /dev/ttyUSB0
$ ssh root@192.168.0.202 './helloImage'
C-Kermit>set flow-control none
$ scp root@192.168.0.202:~/cap.jpg cap.jpg
C-Kermit>set carrier-watch off
C-Kermit>set speed 115200
/dev/ttyUSB0, 115200 bps
C-Kermit>connect
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.


Power-up the expansion board


Hit 'Enter' to interrupt the boot sequence
Type:
nand erase 240000 20000
reset
Hit 'Enter' to interrupt the boot sequence
Type:
setenv defaultdisplay lcd43; saveenv;
reset


7. Get the image
== SPI communication and image processing ==


Let the Overo boot properly
In the current stage we achieved full duplex SPI communication between the Overo and the STM32. This is great because we can do advanced image processing in the Overo with some help from OpenCV while retrieving attitude information from the autopilot and sending back to the latter the vision results.
Touch the screen and calibrate it as indicated
In the serial command line do:
overo login: root
export DISPLAY=:0.0
mplayer tv:// -tv driver=v4l2:device=/dev/video0 -x 480 -y 272 -vo x11


The camera image should appear in the LCD display
SPI sample code: [https://github.com/gonber/tudelftPaparazzi/blob/obstacleAvoidance/sw/airborne/arch/stm32/modules/overo_stm_spi_duplex/overo_stm_spi_duplex.c autopilot1], [https://github.com/gonber/tudelftPaparazzi/blob/obstacleAvoidance/sw/airborne/arch/stm32/modules/overo_stm_spi_duplex/overo_stm_spi_duplex.h autopilot2],
[https://github.com/gonber/paparazzi/blob/obstacleAvoidance/overo_cam/overo_stm_spi_duplex.c overo1],
[https://github.com/gonber/paparazzi/blob/obstacleAvoidance/overo_cam/overo_stm_spi_duplex.h overo2].


Based on: http://wiki.gumstix.org/index.php?title=Caspa_camera_boards
[[Category:Software]] [[Category:Developer_Documentation]]

Latest revision as of 05:44, 12 October 2011

This page describes the work to fully integrate a Caspa FS camera on a Lisa/L board. Any advices/suggestions/contributions are welcome.

Final Goal

The final goal is to have a Caspa FS camera connected to the Overo chip on a Lisa/L board. The Overo chip should be able to communicate with the STM32 via SPI. The link shall be used to transmit the result of the image processing computed by the Overo. However this should be flexible enough to let some room for the developer to decide which processing to do and which kind of data to send. Digital video streaming to the groundstation is also interesting.


Caspa camera on an Overo expansion board

As a first step a simple connection between the camera and the Overo was tried using an Overo expansion board, i.e. not the the Lisa/L board.

Hardware components

Step-by-step

Create a bootable MicroSD card if you do not have one

Follow this and use LABEL1 as 'mmcblk0p1' and LABEL2 as 'mmcblk0p2'.

Load a pre-built standard image
sudo chown [user_name] /media/mmcblk0p1
sudo chown [user_name] /media/mmcblk0p2
wget http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/omap3-desktop-nand-image-overo-booted.tar.bz2
tar -xjf omap3-desktop-nand-image-overo-booted.tar.bz2 -C /media/mmcblk0p2    // ignore errors
wget http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/MLO
wget http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/u-boot.bin
wget http://cumulus.gumstix.org/images/angstrom/factory/2011-03-25-1619/uImage
cp MLO /media/mmcblk0p1
cp u-boot.bin /media/mmcblk0p1
cp uImage /media/mmcblk0p1

When populating mmcblk0p1 it is important to copy the MLO first otherwise it will not be found by the Overo booting mechanism

Replace some files to get the camera modules working
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
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
Attach the camera to the Overo board

Insert the white ribbon cable contact-side-up into the Caspa connector and contact side down into the Overo connector.

Insert MicroSD card in the Overo board
Set environment variables
  • Connect the expansion board to the host machine via USB B (Console)
  • On the host machine do:
[sudo apt-get install ckermit]
kermit -l /dev/ttyUSB0
C-Kermit>set flow-control none
C-Kermit>set carrier-watch off
C-Kermit>set speed 115200
/dev/ttyUSB0, 115200 bps
C-Kermit>connect
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.

You have now a console connection to the Overo

  • Power-up the expansion board
  • Hit 'Enter' to interrupt the boot sequence
  • Type in the console:
nand erase 240000 20000
reset

This makes the Overo to read the environment variables defined by the kernel in the MicroSD. You just have to do this once after setting up the card.

  • Hit 'Enter' to interrupt the boot sequence again
  • Type in the console:
setenv defaultdisplay lcd43; saveenv;
reset

You just have to do this once after setting up the card.

Get the image
  • Let the Overo boot properly
  • Touch the screen and calibrate it as indicated. You just have to do this once after setting up the card.
  • Type in the console:
overo login: root
export DISPLAY=:0.0
mplayer tv:// -tv driver=v4l2:device=/dev/video0 -x 480 -y 272 -vo x11	

The camera image should appear on the LCD display.

Based on Gumstix wiki.

WiFi digital video streaming

Here we show how to achieve WiFi digital video streaming with the Lisa/L board. This setup can be used as a parallel system to the autopilot running in the STM32. However, as connection from the Overo to the STM32 is envisaged we prepare the Overo kernel for SPI support.

Hardware components

Step-by-step

The general idea is to build a Linux kernel and a filesystem image for the Overo board which supports both the Caspa camera (sensor mt9v032) and SPI. Aside from this we use the DSP for encoding the image and WiFi for streaming to the groundstation.

It helps if you have notions of Bitbake & OpenEmbedded and git. Otherwise you can try doing it in a mindless way and it should also work. For that follow only the steps marked with a (*).

Get the Overo toolchain
$ cd ~
$ mkdir overo-oe
$ cd overo-oe
$ git clone git://gitorious.org/gumstix-oe/mainline.git org.openembedded.dev
$ cd org.openembedded.dev
$ git checkout --track -b overo4lisa-2011.03 origin/overo-2011.03
$ cd ~/overo-oe
$ git clone git://git.openembedded.net/bitbake bitbake
$ cd bitbake
$ git checkout 1.10.2
$ cd ~/overo-oe
$ cp -r org.openembedded.dev/contrib/gumstix/build .
$ source build/profile

This last command is required whenever you want to use bitbake. More info here.

Changes to the original repository

In org.openembedded.dev/conf/machine/overo.conf edit the lines:

'SERIAL_CONSOLE = "115200 ttyO2' to 'SERIAL_CONSOLE = "115200 ttyS2'
'PREFERRED_PROVIDER_virtual/kernel = "linux-omap3"' to 'PREFERRED_PROVIDER_virtual/kernel = "linux-omap3-caspapx"'

This will make kernel 2.6.34 to be compiled instead of 2.6.39 which has no support for the camera at the time of writing.

Now we need to give the right configuration before compiling the kernel. Here you can choose to do it yourself:

$ bitbake -c menuconfig linux-omap3-caspapx
$ cp ~/overo-oe/tmp/work/overo-angstrom-linux-gnueabi/linux-omap3-caspapx-2.6.34-r101/git/.config ~/overo-oe/org.openembedded.dev/recipes/linux/linux-omap3-caspapx/overo/defconfig

Add support to the mt9v032 sensor, disable touchscreens and LCD displays (which use the same I/O lines as SPI) and add support to SPI.

Or you can use the same configuration as I did:

$ wget https://raw.github.com/gist/1094791/a97f9a16556d3986ba1ceabd2ab9d4898b75244f/linux-omap3-caspapx-kernelConfig
$ cp linux-omap3-caspapx-kernelConfig ~/overo-oe/org.openembedded.dev/recipes/linux/linux-omap3-caspapx/overo/defconfig

Notice in the configuration file the line 'CONFIG_SOC_CAMERA_MT9V032=m'. This means that the mt9v032 sensor driver will be added to the kernel as a module. This is a better approach because then you can load and unload it for changing operational configurations like auto exposure features.

For SPI support we have to patch de kernel. Do:

$ wget https://raw.github.com/gist/1109520/5fd3137aca87e2b8557534a53b2cee2c428bc5cb/spidev_enable.patch ~/overo-oe/org.openembedded.dev/recipes/linux/linux-omap3-caspapx/spidev_enable.patch
$ wget https://raw.github.com/gist/1109520/bc00de1dc37b249f4fe109fe0696c9d371724825/linux-omap3-caspapx_2.6.34_mod.bb ~/overo-oe/org.openembedded.dev/recipes/linux/linux-omap3-caspapx_2.6.34.bb

This will result in two SPI devices being listed under /dev, spidev1.0 and spidev1.1. In the Lisa/L board we use spidev1.1 for communication with the STM32.

Then, I modified the original filesystem image recipe so that every necessary components are included. Do:

$ wget https://raw.github.com/gist/1094809/bf6ce898134fe4ef96bfc0ba7ecac7577583d2b8/omap3-overo4lisa-image.bb
$ cp omap3-overo4lisa-image.bb ~/overo-oe/org.openembedded.dev/recipes/images/omap3-overo4lisa-image.bb

Finally, follow the step 'Building task-gstreamer-ti' in jumpnowtek but do not run the last 2 commands.

Compiling the kernel
$ bitbake -c clean linux-omap3-caspapx
$ bitbake linux-omap3-caspapx
$ bitbake x-load
$ bitbake u-boot-omap3
Building the filesystem image
$ bitbake omap3-overo4lisa-image
Load a bootable microSD card

See Create a bootable MicroSD card if you do not have one.

$ cd ~/overo-oe/tmp/deploy/glibc/images/overo
$ cp MLO-overo-1.44+r20+gitr24b8b7f41a83540433024854736518876257672c-r20 /media/mmcblk0p1/MLO
$ cp u-boot-overo-2010.9+r1+git1e4e5ef0469050f014aee1204dae8a9ab6053e49-r1.bin /media/mmcblk0p1/u-boot.bin
$ cp uImage-2.6.34-r101-overo.bin /media/mmcblk0p1/uImage
$ tar -xvf Angstrom-omap3-overo4lisa-image-glibc-ipk-2011.03-overo.rootfs.tar.bz2 -C /media/mmcblk0p2
$ tar -xf modules-2.6.34-r101-overo.tgz -C /media/mmcblk0p2

File names might change a bit. Change the commands accordingly.

In /media/mmcblk0p2/etc/inittab edit the line:

'S:2345:respawn:/sbin/getty 115200 ttyO2' to 'S:2345:respawn:/sbin/getty 115200 ttyS2'

This is due to an incompatibility among kernel versions. The earlier ones use the ttyS2 console while the newer use ttyO2. Not editing this line prevents us from using the console.

Load a bootable microSD card with a prebuilt kernel and filesystem (*)

ToDo

Setup WiFi connection (*)

In /media/mmcblk0p2/etc/network/interfaces add the lines:

auto wlan0
iface wlan0 inet static
 wireless_mode ad-hoc
 wireless_channel 1
 wireless_essid caspa
 address 192.168.0.202
 netmask 255.255.255.0

Setup (p.e via NetworkManager) a similar network in the groundstation side and give to this the address '192.168.0.200'. Of course other configurations are possible.

Edit u-Boot parameters (*)
  • Put the microSD card in the Overo board.
  • Connect the expansion board to the host machine via USB B (Console)
  • On the host machine do:
[sudo apt-get install ckermit]
kermit -l /dev/ttyUSB0
C-Kermit>set flow-control none
C-Kermit>set carrier-watch off
C-Kermit>set speed 115200
/dev/ttyUSB0, 115200 bps
C-Kermit>connect

You have now a console connection to the Overo.

  • Power-up the expansion board
  • Hit 'Enter' to interrupt the boot sequence
  • Type in the console:
nand erase 240000 20000
reset
  • Interrupt again the boot sequence
  • Follow the step 'U-Boot Kernel Parameters' in jumpnowtek (Gumstix procedure)
  • Finally type:
reset
Streaming (*)

Now the Overo is ready to start streaming. Set up the connection in the groundstation with NetworkManager. A blue LED should light up in the Overo board indicating that it is wireless connected. Use the following:

$ wget https://raw.github.com/gist/1094865/efc9578a0fa23784636d0ef02d9281e8b490dcca/videostreaming.sh
$ sudo chmod +x videostreaming.sh
$ ./videostreaming.sh

This connection was tested in open field with a simple laptop without external antenna. Ranges of 75m are possible. However the image quality in bright lighting conditions is low for all distances.

Based on jumpnowtek.

Troubleshooting

  • Gumstix ships two types of this camera. One with IR filter (version VL - PCB30009C) and one without (version FS - PCB30009). However the board might be mislabeled and so the only way to know your version is to unmount the lenses and check for the IR filter.
  • If you are OK with disabling the auto exposure driver feature this can increase a lot the image quality and reliability. For changing driver parameters you have to add mt9v032 sensor support to the kernel as a module and not as a built-in feature. Then:
$ rmmod mt9v032
$ insmod /lib/modules/2.6.34/kernel/drivers/media/video/mt9v032.ko auto_exp=0

For checking all the possible parameters do:

$ modinfo mt9v032

Inflight testing

Caution! During our first tests the high usage of the WiFi link for streaming resulted in loss of RC. Luckily the autopilot took over until we could issue a shutdown command to the Overo board. After that we changed the WiFi configurations to stick to channel 1 but this was not tested yet and we still do not know if it solves the problem.

Frame retrieval in C code

The next logical step is to manipulate camera images in C code. For that we will be using OpenCV. This framework includes a full range of image processing tools and algorithms.

Cross compiling

For enabling cross compilation (compilation of Overo programs in the development machine) do:

$ cd ~/overo-oe
$ bitbake opencv

This compiles the OpenCV library for inclusion in our C programs. A sample program that retrieves a frame and saves it as a .JPG file and its Makefile can be downloaded by doing:

$ wget https://raw.github.com/gist/1108913/43893c3a266741077523eb72d8234978e0659119/helloImage.c 
$ wget https://raw.github.com/gist/1108913/9670763f37466a1232a5a026d18e3d347d4eae1f/Makefile

If the network connection is enabled you can get a capture in your development machine by doing:

$ make helloImage install
$ ssh root@192.168.0.202 './helloImage'
$ scp root@192.168.0.202:~/cap.jpg cap.jpg


SPI communication and image processing

In the current stage we achieved full duplex SPI communication between the Overo and the STM32. This is great because we can do advanced image processing in the Overo with some help from OpenCV while retrieving attitude information from the autopilot and sending back to the latter the vision results.

SPI sample code: autopilot1, autopilot2, overo1, overo2.