Compile Manually

Version 12 (Ilario Gelmetti, 08/15/2015 08:44 pm)

1 1 Gioacchino Mazzurco
h1. Compile Manually
2 2 Ilario Gelmetti
3 12 Ilario Gelmetti
Libre-Mesh firmware can be built via OpenWRT build root or via lime-build tool, here both methods are described.
4 12 Ilario Gelmetti
5 5 Ilario Gelmetti
h2. Starting from a new compilation of OpenWrt
6 2 Ilario Gelmetti
7 2 Ilario Gelmetti
*Resources needed:*
8 2 Ilario Gelmetti
9 2 Ilario Gelmetti
Probably a Linux based operating system.
10 2 Ilario Gelmetti
11 2 Ilario Gelmetti
Some tools for the compilation process, on Debian:
12 2 Ilario Gelmetti
13 4 Gioacchino Mazzurco
<pre>
14 4 Gioacchino Mazzurco
apt-get install git build-essential libncurses5-dev zlib1g-dev gawk subversion
15 4 Gioacchino Mazzurco
</pre>
16 2 Ilario Gelmetti
17 2 Ilario Gelmetti
About 9 GB of disk space.
18 2 Ilario Gelmetti
19 2 Ilario Gelmetti
About 3 hours of compilation time.
20 1 Gioacchino Mazzurco
21 12 Ilario Gelmetti
*Download OpenWrt 14.07*. Using trunk version of OpenWRT is *not* supported currently.
22 1 Gioacchino Mazzurco
23 4 Gioacchino Mazzurco
<pre>
24 4 Gioacchino Mazzurco
git clone git://git.openwrt.org/14.07/openwrt.git
25 1 Gioacchino Mazzurco
</pre>
26 1 Gioacchino Mazzurco
27 12 Ilario Gelmetti
*Add our repositories* to the list of the default ones.
28 4 Gioacchino Mazzurco
29 4 Gioacchino Mazzurco
<pre>
30 4 Gioacchino Mazzurco
cd openwrt
31 2 Ilario Gelmetti
cp feeds.conf.default feeds.conf
32 2 Ilario Gelmetti
echo "src-git libremap git://github.com/libremap/libremap-agent-openwrt.git" >> feeds.conf
33 4 Gioacchino Mazzurco
echo "src-git lime https://github.com/libre-mesh/lime-packages.git" >> feeds.conf
34 4 Gioacchino Mazzurco
</pre>
35 1 Gioacchino Mazzurco
36 2 Ilario Gelmetti
If you want to use a specific branch of lime-packages specify it adding ;nameofthebranch at the end of the last line. For example:
37 1 Gioacchino Mazzurco
38 1 Gioacchino Mazzurco
<pre>
39 1 Gioacchino Mazzurco
src-git lime https://github.com/libre-mesh/lime-packages.git;develop
40 1 Gioacchino Mazzurco
</pre>
41 1 Gioacchino Mazzurco
42 1 Gioacchino Mazzurco
Download all these packages and put sources in the right place.
43 1 Gioacchino Mazzurco
44 1 Gioacchino Mazzurco
<pre>
45 1 Gioacchino Mazzurco
scripts/feeds update -a
46 1 Gioacchino Mazzurco
scripts/feeds install -a
47 1 Gioacchino Mazzurco
</pre>
48 1 Gioacchino Mazzurco
49 1 Gioacchino Mazzurco
Then enter the OpenWrt *configuration* menu.
50 1 Gioacchino Mazzurco
51 1 Gioacchino Mazzurco
<pre>
52 1 Gioacchino Mazzurco
make menuconfig
53 1 Gioacchino Mazzurco
</pre>
54 1 Gioacchino Mazzurco
55 1 Gioacchino Mazzurco
Go in "Base system" and *deselect "dnsmasq"* (this is the IPv4 version which conflicts with Libre-Mesh, the IPv6 version will be automatically selected).
56 1 Gioacchino Mazzurco
57 1 Gioacchino Mazzurco
Exit from "Base system" end *enter in "LiMe", select what you want* (for example everything or everything except reghack and lime-full), exit.
58 1 Gioacchino Mazzurco
59 1 Gioacchino Mazzurco
If you need to compile images only for one type of devices you could specify the type in the menu "Target system" and "Target profile", otherwise keep the default and images for each profile will be produced. Exit and save.
60 1 Gioacchino Mazzurco
61 12 Ilario Gelmetti
Launch the *compilation*. 
62 1 Gioacchino Mazzurco
63 1 Gioacchino Mazzurco
<pre>
64 12 Ilario Gelmetti
make
65 1 Gioacchino Mazzurco
</pre>
66 1 Gioacchino Mazzurco
67 12 Ilario Gelmetti
The produced firmware image files are in bin/ directory.
68 1 Gioacchino Mazzurco
69 12 Ilario Gelmetti
Flash on your devices, optionally [[Configuration|change the default configuration]], and enjoy!
70 12 Ilario Gelmetti
71 12 Ilario Gelmetti
h3. Updating a previous compilation of Libre-Mesh
72 12 Ilario Gelmetti
73 12 Ilario Gelmetti
Enter the base directory of the previous compiled image, for example
74 12 Ilario Gelmetti
75 1 Gioacchino Mazzurco
<pre>
76 12 Ilario Gelmetti
cd ~/openwrt
77 1 Gioacchino Mazzurco
</pre>
78 1 Gioacchino Mazzurco
79 12 Ilario Gelmetti
Update the OpenWrt source code.
80 1 Gioacchino Mazzurco
81 1 Gioacchino Mazzurco
<pre>
82 12 Ilario Gelmetti
git pull
83 1 Gioacchino Mazzurco
</pre>
84 1 Gioacchino Mazzurco
85 12 Ilario Gelmetti
Update the Libre-Mesh package source code.
86 1 Gioacchino Mazzurco
87 12 Ilario Gelmetti
<pre>
88 12 Ilario Gelmetti
scripts/feeds update -a
89 12 Ilario Gelmetti
scripts/feeds install -a
90 12 Ilario Gelmetti
</pre>
91 1 Gioacchino Mazzurco
92 12 Ilario Gelmetti
Launch the compilation. The make -j [number] makes the compiler use multiple cores. If you have more than 2 cores, change to the appropriate number. 
93 12 Ilario Gelmetti
94 12 Ilario Gelmetti
<pre>
95 12 Ilario Gelmetti
make -j 3
96 12 Ilario Gelmetti
</pre>
97 12 Ilario Gelmetti
98 12 Ilario Gelmetti
If you encounter some errors try compiling without the -j option or cleaning completely the installation environment
99 12 Ilario Gelmetti
100 12 Ilario Gelmetti
<pre>
101 12 Ilario Gelmetti
make clean
102 12 Ilario Gelmetti
make dirclean
103 12 Ilario Gelmetti
rm -rf feeds/*
104 12 Ilario Gelmetti
</pre>
105 12 Ilario Gelmetti
106 12 Ilario Gelmetti
and restart from the top of this section about updating.
107 12 Ilario Gelmetti
108 12 Ilario Gelmetti
109 12 Ilario Gelmetti
110 12 Ilario Gelmetti
111 5 Ilario Gelmetti
h2. Using lime-build
112 5 Ilario Gelmetti
113 5 Ilario Gelmetti
*Resources needed:*
114 5 Ilario Gelmetti
115 5 Ilario Gelmetti
Probably a Linux based operating system.
116 5 Ilario Gelmetti
117 5 Ilario Gelmetti
Some tools for the compilation process, on Debian:
118 5 Ilario Gelmetti
119 5 Ilario Gelmetti
<pre>
120 5 Ilario Gelmetti
apt-get install git build-essential libncurses5-dev zlib1g-dev gawk subversion
121 5 Ilario Gelmetti
</pre>
122 5 Ilario Gelmetti
123 5 Ilario Gelmetti
About 9 GB of disk space.
124 5 Ilario Gelmetti
125 5 Ilario Gelmetti
About 3 hours of compilation time.
126 5 Ilario Gelmetti
127 5 Ilario Gelmetti
*Download* the *lime-build* source:
128 5 Ilario Gelmetti
129 5 Ilario Gelmetti
<pre>
130 5 Ilario Gelmetti
git clone https://github.com/libre-mesh/lime-build.git
131 5 Ilario Gelmetti
</pre>
132 5 Ilario Gelmetti
133 5 Ilario Gelmetti
Have a look at the list of devices supported by lime-build:
134 5 Ilario Gelmetti
135 6 Ilario Gelmetti
<pre>
136 5 Ilario Gelmetti
make list_targets
137 5 Ilario Gelmetti
</pre>
138 6 Ilario Gelmetti
139 5 Ilario Gelmetti
if you see your device you can continue with this guide, otherwise you have to use the instructions in the section "Starting from a new compilation of OpenWrt".
140 5 Ilario Gelmetti
141 6 Ilario Gelmetti
*Compile* specifying the *target device* in T= and roughly the number of CPU cores plus one in J=. That is, for compiling on a dual core computer the image for Ubiquiti NanoStation M5:
142 5 Ilario Gelmetti
143 5 Ilario Gelmetti
<pre>
144 5 Ilario Gelmetti
make J=3 T=nsm5 build
145 5 Ilario Gelmetti
</pre>
146 5 Ilario Gelmetti
147 5 Ilario Gelmetti
You'll find the compiled images in the directory images.
148 5 Ilario Gelmetti
149 5 Ilario Gelmetti
Other options for lime-build are documented here: https://github.com/libre-mesh/lime-build/blob/master/README.md