RaspberryPISourceInstall

Version 18 (coder, 08/01/2016 23:40)

1 5 coder
h1. RaspberryPiSourceInstall
2 1 coder
3 18 coder
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. To compile directly on the Pi, install libSDL as explained below and then follow the [[UbuntuSourceInstall]] directions, passing <code>--enable-rpi --enable-egl</code> to configure.
4 1 coder
5 13 coder
Note that Raspberry Pi support is still beta - we're working on fixing all remaining issues.
6 1 coder
7 5 coder
h2. Install dependencies on the Pi
8 1 coder
9 5 coder
*_On the Pi_*, install the needed packages:
10 1 coder
11 1 coder
<pre>
12 1 coder
<code>$ sudo apt-get install git automake autoconf libtool libxml2-dev \
13 1 coder
libpango1.0-dev librsvg2-dev libgdk-pixbuf2.0-dev libavcodec-dev libavformat-dev \
14 18 coder
libswscale-dev libavresample-dev python-dev libboost-python-dev libboost-thread-dev g++ \
15 1 coder
libxxf86vm-dev libdc1394-22-dev linux-libc-dev
16 1 coder
</code></pre>
17 18 coder
18 18 coder
h2. Install libSDL
19 18 coder
20 18 coder
<pre>
21 18 coder
<code>$ sudo apt-get install libfreeimage-dev libopenal-dev libsndfile-dev libudev-dev \
22 18 coder
libasound2-dev libjpeg8-dev libtiff5-dev libwebp-dev
23 18 coder
</code></pre>
24 18 coder
25 18 coder
Add the following line to @/etc/apt/sources.list@:
26 18 coder
27 18 coder
<pre>
28 18 coder
<code>deb http://http.debian.net/debian wheezy-backports main
29 18 coder
</code></pre>
30 18 coder
31 18 coder
Then:
32 18 coder
33 18 coder
<pre>
34 18 coder
<code>$ sudo apt-get -t wheezy-backports install libevdev-dev
35 18 coder
</code></pre>
36 18 coder
37 18 coder
Say 'Y' to the 'Install without verification' prompt.
38 18 coder
39 18 coder
Download libsdl from libsdl.org, unpack the tarball. Then build and install libSDL:
40 18 coder
41 18 coder
<pre>
42 18 coder
<code>$ ./configure --host=armv7l-raspberry-linux-gnueabihf --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl
43 18 coder
$ make -j5
44 18 coder
$ sudo make install
45 18 coder
</code></pre>
46 18 coder
47 1 coder
48 1 coder
h2. Set up the Cross-compile Toolchain
49 1 coder
50 11 coder
This work is done *_on the Linux machine_*.
51 1 coder
52 11 coder
This is the directory structure we'll need:
53 11 coder
54 7 coder
<pre>
55 7 coder
rpi
56 1 coder
    libavg        - the libavg source tree
57 1 coder
    root          - copy of the PI filesystem
58 1 coder
    rpi-tools     - the toolchain (compiler, linker, etc.) used to cross-compile
59 1 coder
    staging       - the compiled version of libavg that will be copied to the PI
60 1 coder
</pre>
61 1 coder
62 11 coder
Tell the build system where the directory hierarchy is:
63 1 coder
64 11 coder
<pre>
65 11 coder
$ export AVG_RPI_ROOT=.....
66 11 coder
</pre>
67 1 coder
68 11 coder
Download the crosscompile tools to rpi-tools:
69 1 coder
70 6 coder
<pre>
71 1 coder
<code>$ cd rpi
72 16 coder
$ git clone git://github.com/raspberrypi/tools.git rpi-tools
73 7 coder
</code></pre>
74 1 coder
75 1 coder
Copy /usr, /lib, and /opt/vc directory trees from the Pi (replace $PI with the IP address of the Pi):
76 1 coder
77 1 coder
<pre>
78 1 coder
<code>$ mkdir root
79 1 coder
$ cd root
80 1 coder
$ rsync -rl --delete-after --safe-links pi@$PI:/{lib,usr} .
81 14 coder
$ rsync -rl --delete-after --safe-links pi@$PI:/opt/vc opt
82 7 coder
</code></pre>
83 1 coder
84 1 coder
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:
85 1 coder
86 1 coder
_root/usr/lib/arm-linux-gnueabihf/libpthread.so_:
87 1 coder
88 6 coder
<pre>
89 1 coder
<code>OUTPUT_FORMAT(elf32-littlearm)
90 1 coder
GROUP ( libpthread.so.0 libpthread_nonshared.a )
91 7 coder
</code></pre>
92 1 coder
93 1 coder
_root/usr/lib/arm-linux-gnueabihf/libc.so_:
94 1 coder
95 1 coder
<pre>
96 6 coder
<code>OUTPUT_FORMAT(elf32-littlearm)
97 1 coder
GROUP ( libc.so.6 libc_nonshared.a  AS_NEEDED ( ld-linux-armhf.so.3 ) )
98 7 coder
</code></pre>
99 1 coder
100 1 coder
Fix some symlinks:
101 1 coder
102 1 coder
<pre>
103 1 coder
<code>$ cd root/usr/lib/arm-linux-gnueabihf/
104 1 coder
$ ln -s ../../../lib/arm-linux-gnueabihf/libm.so.6 libm.so
105 7 coder
$ ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 libdl.so
106 1 coder
</code></pre>
107 1 coder
108 1 coder
Put the toolchain into the path ($RPI is the absolute path to your rpi directory):
109 1 coder
110 6 coder
<pre>
111 11 coder
<code>$ export PATH=$PATH:$AVG_RPI_ROOT/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
112 7 coder
</code></pre>
113 1 coder
114 1 coder
h2. Build libavg
115 1 coder
116 8 coder
Tell configure which architecture to build for. For Raspbian on the Pi 2:
117 8 coder
118 8 coder
<pre>
119 8 coder
<code>$ export ARCHFLAGS="-mcpu=cortex-a7 -mfpu=neon-vfpv4"
120 8 coder
</code></pre>
121 8 coder
122 8 coder
and for the older Pi:
123 8 coder
124 8 coder
<pre>
125 8 coder
<code>$ export ARCHFLAGS="-march=armv6 -mfloat-abi=hard -mfpu=vfp"
126 8 coder
</code></pre>
127 8 coder
128 8 coder
for other distros, run <code>gcc -mcpu=native -march=native -Q --help=target</code> on the Pi
129 8 coder
to find out what to set ARCHFLAGS to.
130 8 coder
131 15 coder
Once you've set the architecture, check out libavg and build:
132 1 coder
133 1 coder
<pre>
134 15 coder
<code>$ cd rpi
135 15 coder
$ git clone https://github.com/libavg/libavg.git
136 15 coder
$ cd libavg
137 15 coder
$ ./bootstrap
138 10 coder
$ ./rpi-configure
139 11 coder
$ DESTDIR=$AVG_RPI_ROOT/staging make -j6
140 11 coder
$ DESTDIR=$AVG_RPI_ROOT/staging make install
141 1 coder
</code></pre>
142 5 coder
143 1 coder
h2. Install on the Pi
144 1 coder
145 1 coder
Copy the compiled libavg to the Pi:
146 1 coder
147 6 coder
<pre>
148 12 coder
<code>$ cd ../staging
149 1 coder
$ rsync -au usr pi@$IP:/home/pi/Desktop
150 7 coder
</code></pre>
151 1 coder
152 11 coder
Back *_on the Pi_*, copy libavg from the desktop to its final destination:
153 6 coder
154 1 coder
<pre>
155 1 coder
<code>$ sudo cp -R ~/Desktop/usr/* /usr
156 7 coder
</code></pre>
157 1 coder
158 1 coder
h2. Run the tests
159 1 coder
160 6 coder
<pre>
161 17 coder
<code>$ cd /usr/local/lib/python2.7/dist-packages/libavg/test/
162 1 coder
$ python Test.py
163 7 coder
</code></pre>
164 1 coder
165 5 coder
That's it! libavg should now be running on your Pi.