RaspberryPISourceInstall

Version 21 (coder, 01/02/2016 23:17)

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