Compile Manually

Version 15 (Ilario Gelmetti, 10/27/2015 04:10 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 15 Ilario Gelmetti
*Download OpenWrt 14.07*. Using trunk version of OpenWRT is currently *not* supported.
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 15 Ilario Gelmetti
src-git lime https://github.com/libre-mesh/lime-packages.git;sandbox/hotfix/luci-lib-ip
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 15 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 could release duplicated leases...).
58 1 Gioacchino Mazzurco
59 1 Gioacchino Mazzurco
Exit from "Network" and *enter in "LiMe" section, select what you want*, exit.
60 15 Ilario Gelmetti
61 15 Ilario Gelmetti
* Suggested base modules: lime-system, lime-proto-wan, lime-hwd-openwrt-wan, lime-debug, lime-webui
62 15 Ilario Gelmetti
63 15 Ilario Gelmetti
* Suggested modules for batman-adv based networks: lime-proto-batadv, batman-adv-auto-gw-mode, dnsmasq-lease-share
64 15 Ilario Gelmetti
65 15 Ilario Gelmetti
* Suggested modules for bmx6 based networks: lime-proto-bmx6, bmx6-auto-gw-mode, lime-proto-anygw
66 15 Ilario Gelmetti
67 15 Ilario Gelmetti
* Suggested modules for babeld based networks: still under development
68 15 Ilario Gelmetti
69 15 Ilario Gelmetti
* Suggested modules for olsr based networks: still under testing
70 15 Ilario Gelmetti
71 15 Ilario Gelmetti
* Suggested modules for networks containig nodes using [[Ground routing|ground routing]]: lime-hwd-ground-routing
72 15 Ilario Gelmetti
73 15 Ilario Gelmetti
* Suggested modules for networks with [[Network Architecture|architecture on two levels]]: both set for batman-adv based network and bmx6 based network
74 1 Gioacchino Mazzurco
75 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.
76 1 Gioacchino Mazzurco
77 12 Ilario Gelmetti
Launch the *compilation*. 
78 1 Gioacchino Mazzurco
79 1 Gioacchino Mazzurco
<pre>
80 12 Ilario Gelmetti
make
81 1 Gioacchino Mazzurco
</pre>
82 1 Gioacchino Mazzurco
83 12 Ilario Gelmetti
The produced firmware image files are in bin/ directory.
84 1 Gioacchino Mazzurco
85 12 Ilario Gelmetti
Flash on your devices, optionally [[Configuration|change the default configuration]], and enjoy!
86 12 Ilario Gelmetti
87 12 Ilario Gelmetti
h3. Updating a previous compilation of Libre-Mesh
88 12 Ilario Gelmetti
89 12 Ilario Gelmetti
Enter the base directory of the previous compiled image, for example
90 12 Ilario Gelmetti
91 1 Gioacchino Mazzurco
<pre>
92 12 Ilario Gelmetti
cd ~/openwrt
93 1 Gioacchino Mazzurco
</pre>
94 1 Gioacchino Mazzurco
95 12 Ilario Gelmetti
Update the OpenWrt source code.
96 1 Gioacchino Mazzurco
97 1 Gioacchino Mazzurco
<pre>
98 12 Ilario Gelmetti
git pull
99 1 Gioacchino Mazzurco
</pre>
100 1 Gioacchino Mazzurco
101 12 Ilario Gelmetti
Update the Libre-Mesh package source code.
102 1 Gioacchino Mazzurco
103 12 Ilario Gelmetti
<pre>
104 12 Ilario Gelmetti
scripts/feeds update -a
105 12 Ilario Gelmetti
scripts/feeds install -a
106 12 Ilario Gelmetti
</pre>
107 1 Gioacchino Mazzurco
108 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. 
109 12 Ilario Gelmetti
110 12 Ilario Gelmetti
<pre>
111 12 Ilario Gelmetti
make -j 3
112 12 Ilario Gelmetti
</pre>
113 12 Ilario Gelmetti
114 12 Ilario Gelmetti
If you encounter some errors try compiling without the -j option or cleaning completely the installation environment
115 12 Ilario Gelmetti
116 12 Ilario Gelmetti
<pre>
117 12 Ilario Gelmetti
make clean
118 12 Ilario Gelmetti
make dirclean
119 12 Ilario Gelmetti
rm -rf feeds/*
120 12 Ilario Gelmetti
</pre>
121 12 Ilario Gelmetti
122 12 Ilario Gelmetti
and restart from the top of this section about updating.
123 12 Ilario Gelmetti
124 12 Ilario Gelmetti
125 12 Ilario Gelmetti
126 12 Ilario Gelmetti
127 5 Ilario Gelmetti
h2. Using lime-build
128 5 Ilario Gelmetti
129 5 Ilario Gelmetti
*Resources needed:*
130 5 Ilario Gelmetti
131 5 Ilario Gelmetti
Probably a Linux based operating system.
132 5 Ilario Gelmetti
133 5 Ilario Gelmetti
Some tools for the compilation process, on Debian:
134 5 Ilario Gelmetti
135 5 Ilario Gelmetti
<pre>
136 5 Ilario Gelmetti
apt-get install git build-essential libncurses5-dev zlib1g-dev gawk subversion
137 5 Ilario Gelmetti
</pre>
138 5 Ilario Gelmetti
139 5 Ilario Gelmetti
About 9 GB of disk space.
140 5 Ilario Gelmetti
141 5 Ilario Gelmetti
About 3 hours of compilation time.
142 5 Ilario Gelmetti
143 5 Ilario Gelmetti
*Download* the *lime-build* source:
144 5 Ilario Gelmetti
145 5 Ilario Gelmetti
<pre>
146 5 Ilario Gelmetti
git clone https://github.com/libre-mesh/lime-build.git
147 5 Ilario Gelmetti
</pre>
148 5 Ilario Gelmetti
149 5 Ilario Gelmetti
Have a look at the list of devices supported by lime-build:
150 5 Ilario Gelmetti
151 6 Ilario Gelmetti
<pre>
152 5 Ilario Gelmetti
make list_targets
153 5 Ilario Gelmetti
</pre>
154 6 Ilario Gelmetti
155 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".
156 5 Ilario Gelmetti
157 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:
158 5 Ilario Gelmetti
159 5 Ilario Gelmetti
<pre>
160 5 Ilario Gelmetti
make J=3 T=nsm5 build
161 5 Ilario Gelmetti
</pre>
162 5 Ilario Gelmetti
163 5 Ilario Gelmetti
You'll find the compiled images in the directory images.
164 5 Ilario Gelmetti
165 5 Ilario Gelmetti
Other options for lime-build are documented here: https://github.com/libre-mesh/lime-build/blob/master/README.md