Posts

Cross compiling libEXIF for ARM on Ubutnu

libexif is a software library that allows you to add EXIF tags to JPEG images, for example when saving JPEG images via libJPEG.

The following is a log of the steps taken to cross compile libexif on ubuntu for an ARM IoT device, you will need the arm-linux-gnueabi tool-chain installed on your build machine:

1.) Download the latest libexif source code from:

http://sourceforge.net/projects/libexif/files/latest/download?source=files

2.) uzip & untar the software:

3.) Execute the following from bash or similar:

This should put the output files into /home/me/build_exif/_install ready for copying onto your ARM device.

Integrating Intercom to cloud App keeps me out of trouble… (ARM NEON)

I have been busy over the last few days integrating Intercom into a client’s cloud app. I have integrated quite a few SaaS systems of late (and written not a few REST interfaces myself) and I am quite enjoying this integration as the data model is good and the REST interface is reasonably easy to use!

So far so good, and at least it keeps me out of trouble, the specific trouble I have in mind is to attempt to implement a visual programming front-end for the ARM NEON SIMD instructions using the very exciting noFlo Javascript library!!

The ARM NEON instructions are very powerful SIMD instructions that are very useful for optimising image processing and computer vision tasks on ARM devices. They are however quite difficult to use as each instruction has so many variants for the different input and output element types. I reckon it could be a problem well suited to visual/graph flow programming and as far as I can see the most capable people at those races are those in the noFlo team – I am getting seriously excited about their work!

Anyway back to Intercom for the moment!

Cross compiling libpng for ARM Linux with Neon and Zlib

libpng is the standard software library for creating .png image files. It can be built for arm with NEON SIMD support. Cross compiling it for ARM is reasonably straight forward. Its only dependency is zlib which configure can have problems finding.

Before building libpng you will first need to compile zlib.

Then download the libpng source from here, un-zip it etc. and then run confgure as follows:

In the above command replace:

a.) the path to your zlib include files (probably inside the install directory the the zlib build installed to)
b.) the path to your zlib lib files
c.) The path to the directory into which you want all of the output files installed
d.) change the compiler names (if different from arm-linux-gnueabi-gcc etc.)

Once configure completes you make & install:

Now copy the files from the output directory to your ARM device.

Cross compiling libjpeg-turbo targeting ARM for software jpeg compression

In a quest to get faster software jpeg compression on ARM I cross compiled libjpeg-turbo 1.3.0 and pitted it against standard libjpeg (libjpeg-turbo can be used as a drop in replacement for libjpeg). For 24bit rbg images of size 4096×2000, libjpeg-turbo was about twice as fast as libjpeg. Here’s how I compiled libjpeg-turbo:

First get the source:

Then un-tar it and cd into the main source directory. Then configure for ARM:

And make:

The output files will be put under the directory that you specified when you configured, copy them onto your ARM device as appropriate.

Build / Cross Compile lighttpd for ARM Linux with pcre

This is a record of how I built lighttpd with pcre for ARM. Most examples of cross compiling lighttpd for ARM do not include pcre, but to get the best out of lighttpd you really do need pcre built in. So we first need to get and cross compile pcre and then lighttpd.

Build pcre for ARM

In this example I assume that you create the build directories in you home directory, e.g. /home/youruser/ , you will need to change this in the following commands to match your actual directory set-up.

This should build pcre and install the output files into the following directory:

/home/youruser/build_lighttpd/build_pcre/_install

Change this path to suit your own needs.

Build lighttpd for ARM

Now that we have build pcre we can build lighttpd as follows, there is a bit of trickery involved for getting it to build with pcre, but happily this article showed me the way (thanks)!

Again remember to change: /home/youruser/ in each case.

If the build succeded, all the files that you need to install lighttpd on your target ARM device should be under: /home/youruser/build_lighttpd/_install

Here is an article which talks about how to manually install lighttpd.

But at a very minimum you need to:

(a) Download and edit the config file – lighttpd.conf
(b) Copy the pcre libs to /usr/lib or similar – libpcre.so.0 , libpcre.so.0.0.1
(c) Copy on the lighttpd binary from: /home/youruser/build_lighttpd/_install/sbin
(d) Copy on the lib folder from /home/youruser/build_lighttpd/_install/lib
(e) Run lighttpd specifying the paths to config file and lib folder, for example:

lighttpd -D -f /etc/lighttpd/lighttpd.conf -m /usr/lib

Thanks to the following articles for the build info!

http://fengh2000.blogspot.ie/2009/06/how-to-cross-compile-lighttpd-with-pcre.html

http://stackoverflow.com/questions/12079498/lighttpd-refernces-wrong-lib-location

Building / Cross Compiling OpenCV for Linux ARM

This article outlines the steps necessary for building OpenCV for a Linux ARM target. OpenCV is an open-source, cross-platform computer vision and machine vision library.

 

I cross compiled OpenCV for a Xilinx Zinq ARM system yesterday by more-or-less following the steps outlined in the above document – I had to change a few things to get the build to work. I am documenting the exact steps that I took in case anybody is having trouble (probably future me!).

 

I started with a fairly clean Ubuntu install on a virtual machine (it already had git installed) , first I installed some build tools, feel free to skip any that you already have:

Then I installed the GNU ARM tool-chain:

This installed version 4.7 of the compilers while the build process calls for version 4.6, to get around this I modified the cmake platform file slightly, see below.

 

Create a build directory, cd into it and get the OpenCV source from github:

 

To fix the version problem I modified the compiler version in the platform file (this may not be the most correct way to do this but it worked for me!):

 

I edited this file:

 

./opencv/platforms/linux/arm-gnueabi.toolchain.cmake

 

I changed the GCC_COMPILER_VERSION variable’s value from 4.6 to 4.7 to match my installed compiler. I had to edit the file as I wasn’t able to override these variables from the command line.

 

Now create a sub-directory called build and cd into it:

And configure the build:

This should complete without errors if you have the compiler that it is looking for installed etc.

 

Now run ‘make’ and ‘make install’:

Make will take a few minutes to run, make install should copy the output files to a subdirectory called ‘install’.

 

All being well you should now have all the include and lib files that you need to build an OpenCV app for your ARM device.

 

Cross compiling libjpeg for Linux on ARM

I am taking this opportunity to document a cross compilation procedure for libjpeg targeting ARM Linux mostly so that I won’t have to go searching for it again in the future!

First create a directory and cd to it: 

Now get the source and un-tar it:

Configure the build, specifying your C compiler and cross compilation host, then make:

Here, I am using the xilinx build of the compiler, hence the reference to xilinx in the host and CC parameters, if I wasn’t using the xilinx tools the above configure command may have looked more like this:

Now make install, specifying a directory for the output:

If all goes well the output of the build process should be written to the _install directory, copy the .so files to the appropriate directory on your target device (e.g. /usr/local/lib)