Buildroot 2012.02 for Beagleboard-xM with LI-5M03 (mt9p031) camera support

New all-in-one Buildroot ver. 2012.02-mg01.1 released! It includes MLO + U-Boot 2011.12, Linux kernel 3.2.8 (@1GHz) and RootFS with all the necessary packages for working with LI-5M03 (mt9p031) camera module from Leopard Imaging. In order to build the images just run the following commands:

git clone git://github.com/MaxGalemin/buildroot.git
cd ./buildroot
make beagle_xm_full_defconfig
make

After that you’ll find all the images in buildroot/output/images folder:

  1. MLO –  U-Boot SPL first stage bootloader;
  2. u-boot.img – U-Boot 2011.12 binary;
  3. uEnv.txt – simple file with U-Boot parameters;
  4. uImage – Linux kernel 3.2.8 image;
  5. rootfs.tar – Root Filesystem image;

This build requires an external toolchain Codesourcery 2011.09-70 which needs to be installed in the /opt/CodeSourcery folder. However, you can use another toolchain version or folder after proper initialisation in Toolchain menu (Buildroot menuconfig target).

I added Media-ctl and Yavta packages to the current release so you can configure and test your LI-5M02 (mt9p031) Aptina camera module. Also, I included OpenCV 2.3.1, MPlayer, FFmpeg and GStreamer packages, but please note that there is no X11 support in this release so if you need X11 you need to enable it in Buildroot. For full list of packages in current release please see corresponding wiki page: 2012.02-mg01.1.

If you need to add/remove some packets you can easily do this using the next command:

make menuconfig
Package Selection for the target —>

Please note that if you need to remove something you need to untick packet’s name in menuconfig and rebuild the entire RootFS.

Also please note that I added the following compiler flags to the configuration for Beagleboard-xM:

-mfpu=neon -ftree-vectorize -mfloat-abi=softfp

Installation

All the files can be found in buildroot/output/images folder. Just copy MLOu-boot.imguEnv.txt and uImage to the FAT partition of your SD card and untar everything from rootfs.tar to the second ext3 partition. That’s all, your Beagleboard-xM is ready to go.

Precompiled images

If you don’t have enough time for downloading/building everything or if you want just to test your board you can always use my precompiled images (rootfs.tar.gz – basic RootFS, rootfs_full.tar.gz – RootFS with all default packages):

P.S. If you find some issues feel free to add ticket to the Issues. And please note that it’s just a project I’m using for building all the files for my BB-xM. It’s not a clone or official/unofficial mirror, it’s just a personal project just for fun.

P.P.S. In order to build a basic minimal configuration (i.e. MLO, U-Boot, Linux kernel and RootFS with Busybox only) please use the following commands:

make beagle_xm_defconfig
make

 

UPDATE (2012.03.09):

Images were updated with patch release ver. 2012.02-mg01.2. For details please see Issue 23: kernel loading problem on beagleboard xM Rev A.

UPDATE (2012.03.13):

Bumped release version 2012.02-mg01.3.

 

SPM01 – Attitude and Heading Reference System module

SPM01 (Secondary Processor Module 01) it’s a small part of my hobby robotics project, an AHRS module based on LPC11C14 microcontroller with gyroscope (L3G4200D) and accelerometer/magnetometer (LSM303DLM) on board.

 

Key features:

  1. CAN Bus interface with 1Mbit maximal speed and full galvanic isolation;
  2. Fully compliant with CANaerospace specification;
  3. +12-36V power supply voltage;
  4. Easy connection to the CAN Bus and power lines using standardised connector MIL-24308/8 (similar to CiA DS102);
  5. Support for multiple AHRS Modules on one CAN Bus (Redundancy) with easy in-the-field configuration options (Redundancy Channel);
  6. Easy programming interface including both JTAG and ISP support;
  7. LED indication of power supply voltage (3.3V), Rx/Tx CAN Bus lines and Heart Beat;
  8. Non-volatile memory for storing programmed parameters (Node ID, CAN speed etc.);
  9. IP66 enclosure protection rating;
  10. -40..+85 operating temperature range;

 

P.S. PCBs were ordered from Itead Studio and I think 35$ (with delivery) for 10 (web site says 8 but for some reason I’ve received 10) electrically tested white PCBs it’s a very good price. Silk layer could be better but I’m happy enough (see place for the LGA-28L package). Definitely the best choice for quick prototyping.

Buildroot 2011.05 (all-in-one) for Beagleboard-xM

If you don’t have enough time for searching all the sources for X-Loader, U-Boot, Linux kernel and Root Filesystem with OpenCV support you can easily build everything using Buildroot 2011.05 (with a couple of additions) from my github repository. It’s really easy, all you need to do is:

git clone git://github.com/MaxGalemin/buildroot.git
cd buildroot
make beagle_xm_full_defconfig
make
After some time you’ll have all the files you need to boot your Beagleboard-xM in buildroot/output/images folder:

1. MLO –  X-Loader ver. 1.51 binary;
2. u-boot.bin – U-Boot ver. 2011.03 binary;
3. uEnv.txt – simple file with U-Boot parameters;
4. uImage – Linux kernel ver. 2.6.39.1 image;
5. rootfs.tar – Root Filesystem image;

Plese note that CodeSourcery 2011.03 needs to be installed in /opt/CodeSourcery folder. You can change folder in menuconfig “Toolchain” menu but it’s really important to use CodeSourcery 2011.03 toolchain as by default Linux kernel is compiled with switched off alignment traps (see my previous posts) and I didn’t make any tests with previous versions of CodeSourcery.

Lets take a look at all this stuff closer:

X-Loader ver. 1.51

I integrated support for X-Loader to the Buildroot so you can easily change configuration in menuconfig (I used X-Loader sources from Arago project repository, git tag v1.51_OMAPPSP_04.02.00.07):

make menuconfig

  Bootloaders —>
    [*] X-Loader —>

X-Loader board name” it’s a default name for Beagleboard configuration so just leave it. You can find three versions of X-Loader (1.46, 1.48 and 1.51) but I added support for 1.51 only (probably I’ll add sove versions later). “X-Loader Extraversion” parameter is just a string you can see after X-Loader version in your console. I added this parameter just for myself to distinguish between different releases of my Buildroot. And “custom patch dir” is a path to the folder with your additional patches for X-Loader (just leave it empty).

U-Boot ver. 2011.03

make menuconfig

  Bootloaders —>
    [*] U-Boot —> 

It’s a standard U-Boot with additional patch for fixing default console name (ttyO2). Also I added “U-Boot Extraversion” for additional subversion string and “Generate default uEnv.txt” for generating default uEnv.txt (surprise!) with only one “mpurate=1000″ parameter.

Linux kernel 2.6.39.1

I added support for 2.6.39.1 kernel (with a couple of patches of course). So, basically it’s an official kernel, may be with some issues but you definitely can use it as a base image for your work. Please note that due to “Unaligned access support” enabled by default in new CodeSourcery 2011.03 I switched off “Alignment trap” kernel feature.
Default config for kernel: buildroot/board/beagleboard/xm/linux-2.6.39.1.config
Folder with patches: buildroot/board/beagleboard/xm/kernel-patches/

Root Filesystem

It’s a standard Buildroot rootfs again with a number of fixes:

New packages:

1. OpenCV ver. 2.2 – really good open source computer vision library. I added support for Qt, V4L, GTK2, FFMpeg, GStreamer, JPEG, TIFF, PNG and Python. Location:

Package Selection for the target —>
  Libraries —>
    Graphics —>
      [*] opencv 

2. Monit ver. 5.2.5 – some kind of “watchdog” with a number of very interesting features. The must have for serious SW systems. Location:

Package Selection for the target —>
  Shell and utilities —>
    [*] monit

3. Midnight Commander ver. 4.7.5.2 – just good visual file manager. Location:

Package Selection for the target —>
  Shell and utilities —>
    [*] mc

4. Email ver. 3.1.3 – a very simple console program for sending emails. Location:

Package Selection for the target —>
  Networking applications —>
    [*] email

Fixed packages:

1. Valgrind: added support for ARM version (3.6.1);
2. OProfile: fixed dependencies in case of external toolchain;

For full list of packages in current release please see corresponding wiki page: 2011.05-mg00.

If you need to add/remove some packets you can easily do this using:

make menuconfig

  Package Selection for the target —>

Please note that if you need to remove something you need to untick packet’s name in menuconfig and rebuild all the RootFS (!!!).

Also please note that I added the following compiler flags to the configuration for Beagleboard-xM:

-mfpu=neon -ftree-vectorize -mfloat-abi=softfp

Installation

All the files can be found in buildroot/output/images folder. Just copy MLO, u-boot.bin, uEnv.txt and uImage to the FAT partition of your SD card and untar everything from rootfs.tar to the second ext3 partition. That’s all, your system ready to go…

P.S. If you find some issues feel free to add ticket to the Issues. And please note that it’s a just a project I use to generate all the files for my BB, it’s not a clone of something or official/unofficial mirror, just a personal project for fun.

P.P.S. For basic minimal configuration (i.e. X-Loader, U-Boot, kernel and RootFS with  Busybox only) please use the next commands:

make beagle_xm_defconfig
make

Update: Please note that there is an issue in current Linux kernel with ICMP requests (ping) – #12: Unhandled fault after ICMP echo request.

Linux kernel 2.6.39 + CodeSourcery 2011.03-41 = … Continue.

After some investigation I found that by default Linux kernel uses software handlers (traps) for unaligned memory loads. [1] What does it mean? It means that by default for ARM processors “A bit” in Control Register is set to 1.From “Cortex-A8 Technical Reference Manual” [2]:

[1] | A bit | Banked | Enables strict alignment of data to detect alignment faults in data accesses:
0 = strict alignment fault checking disabled, reset value
1 = strict alignment fault checking enabled.

So at the moment we have default software handling for unaligned memory access faults in kernel and new CodeSourcery 2011.03-41 cross-compiler with “Unaligned access support” feature enabled by default. As I understand, It means that compiler tries to optimize unaligned memory access with assumption that “A bit” in Control Register is unset (reset value) and hardware should handle all unaligned memory loads. But this bit is set by Linux kernel, thus, after memory access optimisation by cross-compiler ARM processor generates alignment faults, which are handled by software traps in kernel.

There are two solutions for this issue. The first one is described in my previous post (“-mno-unaligned-access” parameter). And the second is to disable alignment faults checking in Linux kernel (clear “A bit” in Control Register). I think the second solution is more preferable as hardware unaligned loads support is much faster than software handling. After some investigation I found that alignment traps generation can be controlled using “ALIGNMENT_TRAP” kernel config parameter in “arch/arm/Kconfig”, but this parameter is by default true and it can’t be configured in menuconfig. In order to be able to change it’s value just add “Software alignment trap” text after “bool”:

config ALIGNMENT_TRAP
bool “Software alignment trap”

And unset it in menuconfig:

Kernel Features —>
    [ ] Software alignment trap


After that recompile your kernel. You can check if alignment fault checking is disabled or not in kernel traces:

[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7f

Here “cr=…” is a value of ARM’s Control Register. As you can see “A bit” (bit #1) is set (0x7f = b01111111). After disabling alignment fault checking you should see something like that:

[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7d

Here 0x7d = b01111101 – “A bit” is unset.

P.S. According to kernel documentation disabling alignment fault checking can lead to some unpredictable behavior in some network protocols. At the moment I’m trying to stabilize and test 2.6.39 kernel compiled with CodeSourcery 2011.03-41.

[1] - Linux kernel documentation (“Documentation/unaligned-memory-access.txt”).
[2] – Cortex-A8 Technical Reference Manual.

Linux kernel 2.6.39 + CodeSourcery 2011.03-41 = Alignment exception

Please note that if you are planning to move to new version of CodeSourcery 2011.03-41 for ARM GNU/Linuxthere is an issue with alignment optimisation. I spent a couple of days trying to figure out why 2.6.39 kernel boots if it was compiled with old version of CodeSorcery and it hangs (actually produces unhandled alignment exceptions) after compilation using new CodeSourcery 2011.03. I’m not 100% sure, but it seems that guys from CodeSourcery added “Unaligned access support.” feature which is enabled by default and it leads to alignment exceptions:[ 0.000000] Linux version 2.6.39-rc7 (mgalemin@mgalemin-ThinkPad-R51e) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-41) ) #1 SMP Sun May 15 20:40:04 EST 2011
[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7f
[ 0.000000] CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache

[ 0.000000] Machine: OMAP3 Beagle Board
[ 0.000000] bootconsole [earlycon0] enabled
[ 0.000000] Reserving 12582912 bytes SDRAM for VRAM
[ 0.000000] Memory policy: ECC disabled, Data cache writeback
[ 0.000000] OMAP3630 ES1.0 (l2cache iva sgx neon isp 192mhz_clk )
[ 0.000000] SRAM: Mapped pa 0×40200000 to va 0xfe400000 size: 0×10000
[ 0.000000] Clocking rate (Crystal/Core/MPU): 26.0/332/600 MHz
[ 0.000000] Reprogramming SDRC clock to 332000000 Hz
[ 0.000000] PERCPU: Embedded 7 pages/cpu @c0f6e000 s8160 r8192 d12320 u32768

[ 0.000000] Unhandled fault: alignment exception (0×001) at 0xc0501a19
[ 0.000000] Internal error: : 1 [#1] SMP
[ 0.000000] last sysfs file:
[ 0.000000] Modules linked in:
[ 0.000000] CPU: 0 Not tainted (2.6.39-rc7 #1)
[ 0.000000] PC is at pcpu_dump_alloc_info+0xc/0×248
[ 0.000000] LR is at pcpu_setup_first_chunk+0×438/0x71c
[ 0.000000] pc : [<c010dd2c>] lr : [<c001f978>] psr: 200001d3
[ 0.000000] sp : c058fed8 ip : 00000001 fp : 00008000
[ 0.000000] r10: c0f75000 r9 : c0f75060 r8 : c0f75040
[ 0.000000] r7 : c05a467c r6 : c0f6e000 r5 : 00003020 r4 : c0f6b1e0
[ 0.000000] r3 : c0501a19 r2 : 00000002 r1 : c0f6b1e0 r0 : c0501ce0
[ 0.000000] Flags: nzCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel
[ 0.000000] Control: 10c5387f Table: 80004019 DAC: 00000017
[ 0.000000] Process swapper (pid: 0, stack limit = 0xc058e2f8)
[ 0.000000] Stack: (0xc058fed8 to 0xc0590000)

[ 0.000000] fec0: 00001000 c0047e88
[ 0.000000] fee0: 00000000 00000000 00000004 00000000 00000020 00000000 00000000 c0020ec0
[ 0.000000] ff00: 00000000 00000020 bfffffff 00000004 00003020 c0f6b1e0 00003020 c0f6e000
[ 0.000000] ff20: c05a467c c0f75040 c0f75060 c0f75000 00008000 c001f978 c0f6b1e0 00003020
[ 0.000000] ff40: c0f6e000 c05a3988 c0f75020 00000001 c0f6b1ec c0f6b1e0 c0f6c1e0 c0f6e000
[ 0.000000] ff60: c0f76000 c0f6b1f8 c0f6b1e0 c0f6b1ec 00000001 c00202a4 00002000 00003020
[ 0.000000] ff80: 00008000 00000000 000000ae c0f6b1e0 00001000 00007000 00008000 00001000
[ 0.000000] ffa0: 00000000 c060f760 c0034ac4 c0f6b120 c05a8144 80000000 413fc082 00000000
[ 0.000000] ffc0: 00000000 c0020360 c001f4a4 c001f49c c060f760 c0008888 10c53c7f 0000060a
[ 0.000000] ffe0: 80000100 c0034ac4 10c53c7d c05a38dc c0034ac0 8000803c 00000000 00000000

[ 0.000000] [<c010dd2c>] (pcpu_dump_alloc_info+0xc/0×248) from [<c001f978>] (pcpu_setup_first_chunk+0×438/0x71c)
[ 0.000000] [<c001f978>] (pcpu_setup_first_chunk+0×438/0x71c) from [<c00202a4>] (pcpu_embed_first_chunk+0×648/0x6dc)
[ 0.000000] [<c00202a4>] (pcpu_embed_first_chunk+0×648/0x6dc) from [<c0020360>] (setup_per_cpu_areas+0×28/0xb0)
[ 0.000000] [<c0020360>] (setup_per_cpu_areas+0×28/0xb0) from [<c0008888>] (start_kernel+0xdc/0x2ec)
[ 0.000000] [<c0008888>] (start_kernel+0xdc/0x2ec) from [<8000803c>] (0x8000803c)
[ 0.000000] Code: c0b49838 e59f3220 e92d4ff0 e24dd03c (e5932000)
This particular fault situation can be fixed by fixing size of “empty_str” array in function “pcpu_dump_alloc_info” (file “mm/percpu.c”):

char empty_str[] = “——–”;

Should be replaced with:

char empty_str[16] = “——–”;

From  Getting Started Guide page 38:

Unaligned access support. The compiler now generates more efficient code for accessing packed data structures and for copying small blocks of unaligned data when targeting architectures that permit unaligned word/halfword accesses. This feature can be controlled by the -munaligned-access and -mno-unaligned-access options, and is enabled by default for ARMv6 processors and above, except for ARMv6-M.

So, as a workaround you can compile kernel with additional EXTRA_CFLAGS=-mno-unaligned-access parameter, for example:

make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm EXTRA_CFLAGS=-mno-unaligned-access uImage 

LI-5M03 camera on Beagleboard-xM

LI-5M03 is a 5 MP camera module form Leopard Imaging. If you don’t know, Beagleboard-xM has a camera connector and a number of camera modules from Leopard Imaging can be connected to it. The main advantage of this type of cameras comparing to usual web cameras is speed. Cameras from LI are connected directly to the Camera Image Signal Processor module on DM3730 and, thus, data from camera can be handled much faster that in case of using USB camera driver.Linux kernel for Beagleboard-xM already has drivers for VGA, 2 MP and 3 MP camera modules from LI, but I’m interested in 5 MP module based on MT9P031 image sensor form Aptina. There are two cameras based on this image sensor – LI-5M03 (75$) and LI-5M03CS (79$). The only difference between these cameras is that LI-5M03 already has a lens installed and LI-5M03CS doesn’t have one but only CS mount connector (you can see unprotected image sensor on the picture). Thus, any lens with CS mount (or C mount with C->CS adapter) can be used. I decided to try lens H1214FICS from Computar (1/2″, monofocal, 12mm, f1.4, manual iris). As size of MT9P031 sensor is 1/2.5″ you have to use lens with size not less than 1/2.5″ (1/2″, 2/3″ etc.). Also you can use lenses with digital zoom or/and auto-iris, so for me LI-5M03CS is the best choice (for my project I need to use camera outdoor and I have to use auto-iris lens only). I also purchased camera extension cable (2″)from LI. It’s a bit expensive (35$), but camera module with external lens can be quite heavy and it’s not a good idea to put all the load to the camera connector on Beagleboard-xM, so I’ll make some external base frame to secure the camera + lens construction.

So, we have a camera module but what about drivers? The good news is that guys from Aptina implemented Linux driver (thanks guys!) and you can find it on Aptina’s github repository. However, this driver is for Angstrom kernel, but I merged it into the Jason Kridner’s Beagleboard validation 2.6.32 kernel and made a patch. If you want to add support for LI-5M03/LI-5M03CS please use the next patch:

0001-ARM-OMAP-beagle-add-support-for-MT9P031-Aptina-image-sensor.patch

You can try precompiled kernel image with MT9P031 driver added:

uImage

P.S. If you see some I2C errors in kernel traces like the next one:

i2c_omap i2c_omap.2: Arbitration lost
mt9p031 2-0048: Unable to detect sensor 

You need to add proper I2C lines initialisation (pullups) to the U-Boot. Normal traces should be as following:

mt9p031 2-0048: mt9p031 chip ID 1801

How to build and configure OpenVPN for Beagleboard-xM

1. Make all necessary folders:mkdir lzo openssl openvpn target zlib2. Build zlib and OpenSSL using items 2 and 3 from this post: How to build monit 5.2.1 for Beagleboard-xM

3. Build lzo:

3.1. Download and untar lzo:

cd ./lzo
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gz
tar -xzf ./lzo-2.04.tar.gz
cd ./lzo-2.04/

3.2. Configure lzo:

CC=arm-none-linux-gnueabi-gcc CFLAGS=”-pipe -Os -mtune=cortex-a8 -march=armv7-a -mabi=aapcs-linux -msoft-float” ./configure –target=arm-none-linux –host=arm-none-linux –build=i686-pc-linux –prefix=/usr –exec-prefix=/usr –enable-static=no –enable-shared=yes

3.3. Build and install lzo:

make
make DESTDIR=${PWD}/../../target install

3.4. Remove unnecessary folders:

rm -rf ${PWD}/../../target/usr/include
cd ../..

4. Build OpenVPN:

4.1. Download and untar OpenVPN:

cd openvpn
wget http://openvpn.net/release/openvpn-2.1.3.tar.gz
tar -xzf ./openvpn-2.1.3.tar.gz
cd ./openvpn-2.1.3

4.2. Configure OpenVPN:

CC=arm-none-linux-gnueabi-gcc CFLAGS=”-pipe -Os -mtune=cortex-a8 -march=armv7-a -mabi=aapcs-linux -msoft-float” LDFLAGS=-L${PWD}/../../target/usr/lib ./configure –target=arm-none-linux –host=arm-none-linux –build=i686-pc-linux –prefix=/usr –exec-prefix=/usr –program-prefix=”” –enable-pthread –with-lzo-headers=${PWD}/../../lzo/lzo-2.04/include –with-ssl-headers=${PWD}/../../openssl/openssl-1.0.0a/include

4.3. Build and install OpenVPN:

make
make DESTDIR=${PWD}/../../target install
rm -rf ../../target/usr/share
cd ./easy-rsa/2.0
make DESTDIR=${PWD}/../../../../target/etc/openvpn/easy-rsa install
cd ../../../..

4.4. Copy this init script to the “target/etc/init.d/” folder.

5. Copy all folders from “target” folder to your Root Filesystem on SD card.

6. Boot your Beagleboard and make sure you have “tun” kernel module laoded:

mkdir /dev/net
mknod /dev/net/tun c 10 200

7. Generate server and client keys and certificates:

7.1. Change lines at the end of “/etc/openvpn/easy-rsa/vars” file (country, city, email etc).

7.2. Generate server and client keys (in this example server has name “server” and client – “client”. Please note that for each client you have to generate separate client key with unique name). Make sure you have right time on your Beagleboard-xM or certificates will be invalid (either expired or not valid yet)!

cd /etc/openvpn/easy-rsa
source ./vars
./clean-all
./build-ca
./build-key-server server
./build-key client
./build-dh
openvpn –genkey –secret keys/ta.key

8. Now copy to the OpenVPN server next files to the “/etc/openvpn/easy-rsa/keys” folder from the same folder on your Beagleboard-xM:

ca.crt
server.crt
server.key
dh1024.pem
ta.key

9. Copy next files to the client’s “/etc/openvpn/easy-rsa/keys” folder:

ca.crt
client.crt 
client.key 
ta.key

10. Copy client.conf to the client and server.conf to the server (“/etc/openvpn/” folder).

11. Start OpenVPN on both server and client:

/etc/init.d/openvpn start

12. If you have some problems you can see logs in “/var/log/openvpn.log”. If you can’t find this file you have to update “/etc/init.d/openvpn” script – just add “–log /var/log/openvpn.log” to the line which starts openvpn daemon.

13. If you want to setup static VPN IP addresses for clients you have to uncomment “client-config-dir ccd” line in server.conf, create “/etc/openvpn/ccd” folder and add file for each client (name of the file is the same as name of client) with the next line (client’s IP will be 10.1.1.10):

ifconfig-push 10.1.1.19 10.1.1.10

Please note that in order to use OpenVPN with “tun” network device you have to compile your kernel with support for TUN/TAP device drivers:

Device Drivers —>
    [*] Network device support —> 
        <*> Universal TUN/TAP device driver support 

How to build sample program for capturing image from camera (OpenCV and Qt)

Please find a sample program in C++ for working with OpenCV and Qt below. It’s a very basic implementation (i.e. without proper exceptions handling, CPU load is too high etc.) and it should be used for demo purposes only!For building this program for Beagleboard-xM please use the next command:arm-none-linux-gnueabi-g++ -I<path_to_opencv_include_folder> -I<path_to_qt_include_folder> -L<path_to_opencv_libraries_folder> -L<path_to_qt_libraries_folder> -lQtCore -lQtNetwork -lopencv_core -lopencv_highgui -lopencv_imgproc test.cpp -o test

Run test program with the next command line arguments:

./test -w <image_width> -h <image_height> -t <text> -qws

For example:

./test -w 800 -h 600 -t ‘Hello World!’

Source file:     test.cpp

How to build QT Framework 4.7.2 and OpenCV 2.2 for Beagleboard-xM

For my project I’m using OpenCV library for getting images from camera module (at the moment it’s a cheap Logitech web camera but later I’ll use LI-5M03 from Leopard Imaging). Thus, I don’t need support for ffmpeg or gstreamer. I can just open capture device (V4L on “/dev/video0″), get a frame, do something with this frame and show it in Qt window (by the way, I dont need highgui as well as I use Qt). However, I still can use such OpenCV functions as face recognition or objects detection. For displaying output images I’m using Qt Framework without x window system (i.e. X11) just using Linux framebuffer. If you want to build the same configuration of OpenCV and Qt please follow the next procedure:

OpenCV 2.2 (no ffmpeg/gstreamer)

1. Make all necessary folders and download OpenCV:

 mkdir -p opencv qt rootfs/opt rootfs/usr
 cd opencv/
 wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.2/OpenCV-2.2.0.tar.bz2

2. Unpack OpenCV and apply patches (opencv-2.2-arm-beagleboard-xm-sift-issue.patch and opencv-2.2-arm-beagleboard-xm-cmake.patch):

 tar -xjf ./OpenCV-2.2.0.tar.bz2
 cd ./OpenCV-2.2.0/
 patch -p1 < ../../opencv-2.2-arm-beagleboard-xm-sift-issue.patch
 patch -p1 < ../../opencv-2.2-arm-beagleboard-xm-cmake.patch

3. Configure and build OpenCV:


 mkdir release
 cd release
 cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=${PWD}/../../../rootfs/usr -DCMAKE_TOOLCHAIN_FILE:PATH=${PWD}/../beagleboard.cmake -DWITH_QT=ON -DWITH_FFMPEG=OFF  -DWITH_GSTREAMER=OFF -DWITH_PYTHON=OFF -DWITH_GTK=OFF ..
 make
 make install

4. Now you can remove unnecessary folders (please note that you’ll need headers from “../../../rootfs/usr/include/” folder if you want to build your applications with support for OpenCV):

 rm -rf ../../../rootfs/usr/include/
 rm -rf ../../../rootfs/usr/lib/pkgconfig/
 rm -rf ../../../rootfs/usr/share/opencv/doc/
 rm -f ../../../rootfs/usr/share/opencv/OpenCVConfig.cmake
 cd ../../../

Qt Framework 4.7.2 (framebuffer only)

1. Download Qt:

 cd qt
 wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.2.tar.gz

2. Unpack Qt and apply patch (qt-4.7.2-arm-beagleboard-xm-qmake.patch):

 tar -xzf ./qt-everywhere-opensource-src-4.7.2.tar.gz
 cd ./qt-everywhere-opensource-src-4.7.2/
 patch -p1 < ../../qt-4.7.2-arm-beagleboard-xm-qmake.patch

3. Configure Qt:

 ./configure -nomake tools -nomake examples -nomake demos -nomake docs -nomake translations -opensource -confirm-license -prefix /opt/qt -embedded arm -platform /qws/linux-x86-g++ -xplatform qws/linux-beagle-g++ -depths 16,24,32 -no-mmx -no-3dnow -no-sse -no-sse2 -no-qt3support -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -qt-mouse-pc -qt-mouse-linuxtp -qt-mouse-linuxinput -plugin-mouse-linuxtp -plugin-mouse-pc -fast -no-javascript-jit -no-script -no-scripttools -no-declarative -no-declarative-debug –no-gif -no-libtiff -no-libpng -no-libmng -qt-libjpeg -no-nis -no-iconv -no-pch -no-gtkstyle -no-opengl -no-openvg -no-sm -no-xshape -no-xvideo -no-xsync -no-xinerama -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-mitshm -no-xinput -no-xkb -no-xmlpatterns -no-webkit -no-sql-sqlite -no-sql-sqlite2

4. Build and install Qt:

 make
 make install INSTALL_ROOT=${PWD}/../../rootfs/

5. Remove unnecessary folders (please note that you’ll need headers from “../../rootfs/opt/qt/include/” folder if you want to build your applications with support for Qt):

 rm -rf ../../rootfs/opt/qt/bin/
 rm -rf ../../rootfs/opt/qt/include/
 rm -rf ../../rootfs/opt/qt/mkspecs/
 cd ../..

Now just copy everything from the “rootfs” folder to the Root Filesystem on your SD card and add next line to the “/etc/profile” file (on SD card of course):

 export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):/opt/qt/lib