RaspberryPISourceInstall
Version 11 (coder, 03/05/2015 11:39) → Version 12/27 (coder, 03/05/2015 11:50)
h1. RaspberryPiSourceInstall
This page explains how to install the libavg developer version from github on a Raspberry Pi by cross-compiling. The process involves compiling libavg on a separate Linux machine. The benefit of this is that compiling on the Pi 2 takes around an hour, while cross-compiling takes a few minutes (The original Pi would finish in 4-6 hours or fail with an out of memory condition). The downside is that it's a bit harder to set up.
Alternatively, you can compile directly on the Pi by following the [[UbuntuSourceInstall]] directions and pass <code>--enable-rpi --enable-egl</code> to configure.
h2. Install dependencies on the Pi
*_On the Pi_*, install the needed packages:
<pre>
<code>$ sudo apt-get install git automake autoconf libtool libxml2-dev \
libpango1.0-dev librsvg2-dev libgdk-pixbuf2.0-dev libavcodec-dev libavformat-dev \
libswscale-dev libavresample-dev python-dev libboost-python-dev libboost-thread-dev g++ libSDL-dev \
libxxf86vm-dev libdc1394-22-dev linux-libc-dev
</code></pre>
h2. Set up the Cross-compile Toolchain
This work is done *_on the Linux machine_*.
This is the directory structure we'll need:
<pre>
rpi
libavg - the libavg source tree
root - copy of the PI filesystem
rpi-tools - the toolchain (compiler, linker, etc.) used to cross-compile
staging - the compiled version of libavg that will be copied to the PI
</pre>
Tell the build system where the directory hierarchy is:
<pre>
$ export AVG_RPI_ROOT=.....
</pre>
Download the crosscompile tools to rpi-tools:
<pre>
<code>$ cd rpi
$ git clone git://github.com/raspberrypi/tools.git
</code></pre>
Copy /usr, /lib, and /opt/vc directory trees from the Pi (replace $PI with the IP address of the Pi):
<pre>
<code>$ mkdir root
$ cd root
$ rsync -rl --delete-after --safe-links pi@$PI:/{lib,usr} .
$ rsync -rl --delete-after --safe-links pi@192.168.2.PI:/opt/vc opt
</code></pre>
Then, fix some system libraries so they don't contain references to absolute directories. Open the files in a text editor and change them. They are:
_root/usr/lib/arm-linux-gnueabihf/libpthread.so_:
<pre>
<code>OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libpthread.so.0 libpthread_nonshared.a )
</code></pre>
_root/usr/lib/arm-linux-gnueabihf/libc.so_:
<pre>
<code>OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-armhf.so.3 ) )
</code></pre>
Fix some symlinks:
<pre>
<code>$ cd root/usr/lib/arm-linux-gnueabihf/
$ ln -s ../../../lib/arm-linux-gnueabihf/libm.so.6 libm.so
$ ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 libdl.so
</code></pre>
Put the toolchain into the path ($RPI is the absolute path to your rpi directory):
<pre>
<code>$ export PATH=$PATH:$AVG_RPI_ROOT/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
</code></pre>
h2. Build libavg
Tell configure which architecture to build for. For Raspbian on the Pi 2:
<pre>
<code>$ export ARCHFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4"
</code></pre>
and for the older Pi:
<pre>
<code>$ export ARCHFLAGS="-march=armv6 -mfloat-abi=hard -mfpu=vfp"
</code></pre>
for other distros, run <code>gcc -mcpu=native -march=native -Q --help=target</code> on the Pi
to find out what to set ARCHFLAGS to.
Once you've set the architecture, build:
<pre>
<code>$ ./bootstrap
$ ./rpi-configure
$ DESTDIR=$AVG_RPI_ROOT/staging make -j6
$ DESTDIR=$AVG_RPI_ROOT/staging make install
</code></pre>
h2. Install on the Pi
Copy the compiled libavg to the Pi:
<pre>
<code>$ cd ../staging staging
$ rsync -au usr pi@$IP:/home/pi/Desktop
</code></pre>
Back *_on the Pi_*, copy libavg from the desktop to its final destination:
<pre>
<code>$ sudo cp -R ~/Desktop/usr/* /usr
</code></pre>
h2. Run the tests
<pre>
<code>$ cd /usr/local/share/python-libavg/test/
$ python Test.py
</code></pre>
That's it! libavg should now be running on your Pi.
This page explains how to install the libavg developer version from github on a Raspberry Pi by cross-compiling. The process involves compiling libavg on a separate Linux machine. The benefit of this is that compiling on the Pi 2 takes around an hour, while cross-compiling takes a few minutes (The original Pi would finish in 4-6 hours or fail with an out of memory condition). The downside is that it's a bit harder to set up.
Alternatively, you can compile directly on the Pi by following the [[UbuntuSourceInstall]] directions and pass <code>--enable-rpi --enable-egl</code> to configure.
h2. Install dependencies on the Pi
*_On the Pi_*, install the needed packages:
<pre>
<code>$ sudo apt-get install git automake autoconf libtool libxml2-dev \
libpango1.0-dev librsvg2-dev libgdk-pixbuf2.0-dev libavcodec-dev libavformat-dev \
libswscale-dev libavresample-dev python-dev libboost-python-dev libboost-thread-dev g++ libSDL-dev \
libxxf86vm-dev libdc1394-22-dev linux-libc-dev
</code></pre>
h2. Set up the Cross-compile Toolchain
This work is done *_on the Linux machine_*.
This is the directory structure we'll need:
<pre>
rpi
libavg - the libavg source tree
root - copy of the PI filesystem
rpi-tools - the toolchain (compiler, linker, etc.) used to cross-compile
staging - the compiled version of libavg that will be copied to the PI
</pre>
Tell the build system where the directory hierarchy is:
<pre>
$ export AVG_RPI_ROOT=.....
</pre>
Download the crosscompile tools to rpi-tools:
<pre>
<code>$ cd rpi
$ git clone git://github.com/raspberrypi/tools.git
</code></pre>
Copy /usr, /lib, and /opt/vc directory trees from the Pi (replace $PI with the IP address of the Pi):
<pre>
<code>$ mkdir root
$ cd root
$ rsync -rl --delete-after --safe-links pi@$PI:/{lib,usr} .
$ rsync -rl --delete-after --safe-links pi@192.168.2.PI:/opt/vc opt
</code></pre>
Then, fix some system libraries so they don't contain references to absolute directories. Open the files in a text editor and change them. They are:
_root/usr/lib/arm-linux-gnueabihf/libpthread.so_:
<pre>
<code>OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libpthread.so.0 libpthread_nonshared.a )
</code></pre>
_root/usr/lib/arm-linux-gnueabihf/libc.so_:
<pre>
<code>OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-armhf.so.3 ) )
</code></pre>
Fix some symlinks:
<pre>
<code>$ cd root/usr/lib/arm-linux-gnueabihf/
$ ln -s ../../../lib/arm-linux-gnueabihf/libm.so.6 libm.so
$ ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 libdl.so
</code></pre>
Put the toolchain into the path ($RPI is the absolute path to your rpi directory):
<pre>
<code>$ export PATH=$PATH:$AVG_RPI_ROOT/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
</code></pre>
h2. Build libavg
Tell configure which architecture to build for. For Raspbian on the Pi 2:
<pre>
<code>$ export ARCHFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4"
</code></pre>
and for the older Pi:
<pre>
<code>$ export ARCHFLAGS="-march=armv6 -mfloat-abi=hard -mfpu=vfp"
</code></pre>
for other distros, run <code>gcc -mcpu=native -march=native -Q --help=target</code> on the Pi
to find out what to set ARCHFLAGS to.
Once you've set the architecture, build:
<pre>
<code>$ ./bootstrap
$ ./rpi-configure
$ DESTDIR=$AVG_RPI_ROOT/staging make -j6
$ DESTDIR=$AVG_RPI_ROOT/staging make install
</code></pre>
h2. Install on the Pi
Copy the compiled libavg to the Pi:
<pre>
<code>$ cd ../staging staging
$ rsync -au usr pi@$IP:/home/pi/Desktop
</code></pre>
Back *_on the Pi_*, copy libavg from the desktop to its final destination:
<pre>
<code>$ sudo cp -R ~/Desktop/usr/* /usr
</code></pre>
h2. Run the tests
<pre>
<code>$ cd /usr/local/share/python-libavg/test/
$ python Test.py
</code></pre>
That's it! libavg should now be running on your Pi.