Compile Manually

Version 14 (Ilario Gelmetti, 10/26/2015 01:58 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 13 Ilario Gelmetti
src-git lime https://github.com/libre-mesh/lime-packages.git;ip_legacy_module
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 13 Ilario Gelmetti
Go in "Base system" and *deselect "dnsmasq"* (this is the IPv4 version which if selected won't support IPv6) then select "dnsmasq-dhcpv6". In the same section *deselect "firewall"* (because some devs say that this can cause problems which are hard to debug).
56 1 Gioacchino Mazzurco
57 14 Ilario Gelmetti
Exit from "Base system" and enter "Network". Then *deselect "odhcpd"* (don't be confused with "odhcp6c" which is needed, seems that "odhcpd" if installed together with dnsmasq-dhcpv6 will release duplicated leases...).
58 13 Ilario Gelmetti
59 13 Ilario Gelmetti
Exit from "Network" and *enter in "LiMe" section, select what you want*, exit.
60 1 Gioacchino Mazzurco
61 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.
62 1 Gioacchino Mazzurco
63 12 Ilario Gelmetti
Launch the *compilation*. 
64 1 Gioacchino Mazzurco
65 1 Gioacchino Mazzurco
<pre>
66 12 Ilario Gelmetti
make
67 1 Gioacchino Mazzurco
</pre>
68 1 Gioacchino Mazzurco
69 12 Ilario Gelmetti
The produced firmware image files are in bin/ directory.
70 1 Gioacchino Mazzurco
71 12 Ilario Gelmetti
Flash on your devices, optionally [[Configuration|change the default configuration]], and enjoy!
72 12 Ilario Gelmetti
73 12 Ilario Gelmetti
h3. Updating a previous compilation of Libre-Mesh
74 12 Ilario Gelmetti
75 12 Ilario Gelmetti
Enter the base directory of the previous compiled image, for example
76 12 Ilario Gelmetti
77 1 Gioacchino Mazzurco
<pre>
78 12 Ilario Gelmetti
cd ~/openwrt
79 1 Gioacchino Mazzurco
</pre>
80 1 Gioacchino Mazzurco
81 12 Ilario Gelmetti
Update the OpenWrt source code.
82 1 Gioacchino Mazzurco
83 1 Gioacchino Mazzurco
<pre>
84 12 Ilario Gelmetti
git pull
85 1 Gioacchino Mazzurco
</pre>
86 1 Gioacchino Mazzurco
87 12 Ilario Gelmetti
Update the Libre-Mesh package source code.
88 1 Gioacchino Mazzurco
89 12 Ilario Gelmetti
<pre>
90 12 Ilario Gelmetti
scripts/feeds update -a
91 12 Ilario Gelmetti
scripts/feeds install -a
92 12 Ilario Gelmetti
</pre>
93 1 Gioacchino Mazzurco
94 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. 
95 12 Ilario Gelmetti
96 12 Ilario Gelmetti
<pre>
97 12 Ilario Gelmetti
make -j 3
98 12 Ilario Gelmetti
</pre>
99 12 Ilario Gelmetti
100 12 Ilario Gelmetti
If you encounter some errors try compiling without the -j option or cleaning completely the installation environment
101 12 Ilario Gelmetti
102 12 Ilario Gelmetti
<pre>
103 12 Ilario Gelmetti
make clean
104 12 Ilario Gelmetti
make dirclean
105 12 Ilario Gelmetti
rm -rf feeds/*
106 12 Ilario Gelmetti
</pre>
107 12 Ilario Gelmetti
108 12 Ilario Gelmetti
and restart from the top of this section about updating.
109 12 Ilario Gelmetti
110 12 Ilario Gelmetti
111 12 Ilario Gelmetti
112 12 Ilario Gelmetti
113 5 Ilario Gelmetti
h2. Using lime-build
114 5 Ilario Gelmetti
115 5 Ilario Gelmetti
*Resources needed:*
116 5 Ilario Gelmetti
117 5 Ilario Gelmetti
Probably a Linux based operating system.
118 5 Ilario Gelmetti
119 5 Ilario Gelmetti
Some tools for the compilation process, on Debian:
120 5 Ilario Gelmetti
121 5 Ilario Gelmetti
<pre>
122 5 Ilario Gelmetti
apt-get install git build-essential libncurses5-dev zlib1g-dev gawk subversion
123 5 Ilario Gelmetti
</pre>
124 5 Ilario Gelmetti
125 5 Ilario Gelmetti
About 9 GB of disk space.
126 5 Ilario Gelmetti
127 5 Ilario Gelmetti
About 3 hours of compilation time.
128 5 Ilario Gelmetti
129 5 Ilario Gelmetti
*Download* the *lime-build* source:
130 5 Ilario Gelmetti
131 5 Ilario Gelmetti
<pre>
132 5 Ilario Gelmetti
git clone https://github.com/libre-mesh/lime-build.git
133 5 Ilario Gelmetti
</pre>
134 5 Ilario Gelmetti
135 5 Ilario Gelmetti
Have a look at the list of devices supported by lime-build:
136 5 Ilario Gelmetti
137 6 Ilario Gelmetti
<pre>
138 5 Ilario Gelmetti
make list_targets
139 5 Ilario Gelmetti
</pre>
140 6 Ilario Gelmetti
141 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".
142 5 Ilario Gelmetti
143 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:
144 5 Ilario Gelmetti
145 5 Ilario Gelmetti
<pre>
146 5 Ilario Gelmetti
make J=3 T=nsm5 build
147 5 Ilario Gelmetti
</pre>
148 5 Ilario Gelmetti
149 5 Ilario Gelmetti
You'll find the compiled images in the directory images.
150 5 Ilario Gelmetti
151 5 Ilario Gelmetti
Other options for lime-build are documented here: https://github.com/libre-mesh/lime-build/blob/master/README.md