Project

General

Profile

Environment » History » Version 21

Roger Pueyo Centelles, 01/04/2014 11:31 PM

1 18 Jorge L. Florit
http://qmp.cat/Development
2 18 Jorge L. Florit
TO DO: mantain this page in the main site. Only tricks or hack articles recommended in the wiki.
3 18 Jorge L. Florit
4 18 Jorge L. Florit
5 18 Jorge L. Florit
6 12 Victor Oncins
h1. Development Environment
7 1 Pau Escrich
8 14 Pau Escrich
h3. Get the needed software
9 14 Pau Escrich
10 15 Simó Albert i Beltran
First of all you should take a look on the system requirements:
11 15 Simó Albert i Beltran
12 2 Pau Escrich
In a Debian based distributions (like Ubuntu), a set of packages are needed, you should install them:
13 6 Pau Escrich
14 6 Pau Escrich
<pre>
15 17 Jorge L. Florit
sudo aptitude install \
16 10 Simó Albert i Beltran
git subversion zlib1g-dev gawk flex unzip bzip2 gettext build-essential \
17 16 Simó Albert i Beltran
libncurses5-dev libncursesw5-dev binutils cpp psmisc docbook-to-man
18 1 Pau Escrich
</pre>
19 17 Jorge L. Florit
20 17 Jorge L. Florit
And if your machine is x86_64 you will need 32 bit development files.
21 17 Jorge L. Florit
In Debian/Ubuntu:
22 17 Jorge L. Florit
<pre>sudo aptitude install gcc-multilib</pre>
23 17 Jorge L. Florit
24 17 Jorge L. Florit
In CentOS/Fedora/RHEL the packets:
25 17 Jorge L. Florit
<pre>gcc.i686, libgcc.i686, and glibc-devel.i686</pre>
26 17 Jorge L. Florit
27 17 Jorge L. Florit
28 17 Jorge L. Florit
29 14 Pau Escrich
30 14 Pau Escrich
h3. Get the code and compile
31 1 Pau Escrich
32 15 Simó Albert i Beltran
* [Recomended] Get the qMp firmware generator using git: <pre>git clone git://qmp.cat/qmpfw.git qmpfw</pre>
33 1 Pau Escrich
34 15 Simó Albert i Beltran
* [Outdated] Or get the code using http: <pre>wget -c -q -O - "http://qmp.cat/gitrevision_download?project_id=7&rev=anonymous" | tar zxvf -</pre>
35 15 Simó Albert i Beltran
36 1 Pau Escrich
* Then enter to source directory: <pre>cd qmpfw</pre>
37 1 Pau Escrich
38 15 Simó Albert i Beltran
* [Advanced] Do a checkout specifying the branch: <pre>make .checkout_qmp QMP_GIT_BRANCH=branch_name</pre>
39 15 Simó Albert i Beltran
40 15 Simó Albert i Beltran
Example for testing branch: <pre>make .checkout_qmp QMP_GIT_BRANCH=testing</pre>
41 14 Pau Escrich
42 14 Pau Escrich
* And compile it specifying the target: <pre>make build T=alix</pre>
43 14 Pau Escrich
44 14 Pau Escrich
You can find available targets by executing: <pre>make list_targets</pre>
45 14 Pau Escrich
46 14 Pau Escrich
If you have more than one core in your computer you can use J=N: <pre>make build T=alix J=4</pre>
47 14 Pau Escrich
48 14 Pau Escrich
After that, you will find the images ready to install in your devices inside directory images/
49 19 Roger Pueyo Centelles
50 19 Roger Pueyo Centelles
51 19 Roger Pueyo Centelles
52 19 Roger Pueyo Centelles
53 19 Roger Pueyo Centelles
h3. Compiling qMp from a "previous git revision":http://dev.qmp.cat/projects/qmp/repository of the source code
54 19 Roger Pueyo Centelles
55 19 Roger Pueyo Centelles
To ensure maximum compatibility between the nodes in a network, all of them should run the same qMp firmware version (or, at least, very similar ones). To compile the firmware from a previous release (for example, "revision 944c45d":http://dev.qmp.cat/projects/qmp/repository/show?branch=master-bugfixes&rev=944c45d, do the following:
56 19 Roger Pueyo Centelles
57 19 Roger Pueyo Centelles
* Get the qMp firmware generator using git: <pre>git clone git://qmp.cat/qmpfw.git qmpfw-r944c45d</pre>
58 19 Roger Pueyo Centelles
59 19 Roger Pueyo Centelles
* Enter the source directory: <pre>cd qmpfw-r944c45d</pre>
60 19 Roger Pueyo Centelles
61 19 Roger Pueyo Centelles
* Do a checkout specifying the revision: <pre>make .checkout_qmp QMP_GIT_BRANCH=%GIT_REVISION%</pre>
62 19 Roger Pueyo Centelles
63 19 Roger Pueyo Centelles
Example for revision 944c45d: <pre>make .checkout_qmp QMP_GIT_BRANCH=944c45d</pre>
64 19 Roger Pueyo Centelles
65 19 Roger Pueyo Centelles
The result is:
66 19 Roger Pueyo Centelles
<pre>
67 19 Roger Pueyo Centelles
git clone git://qmp.cat/qmp.git build/qmp
68 19 Roger Pueyo Centelles
Cloning into 'build/qmp'...
69 19 Roger Pueyo Centelles
remote: Counting objects: 8822, done.
70 19 Roger Pueyo Centelles
remote: Compressing objects: 100% (4160/4160), done.
71 19 Roger Pueyo Centelles
remote: Total 8822 (delta 4060), reused 7827 (delta 3544)
72 19 Roger Pueyo Centelles
Receiving objects: 100% (8822/8822), 2.03 MiB | 670.00 KiB/s, done.
73 19 Roger Pueyo Centelles
Resolving deltas: 100% (4060/4060), done.
74 19 Roger Pueyo Centelles
Checking connectivity... done.
75 19 Roger Pueyo Centelles
cd build/qmp; git checkout 944c45d; cd ..
76 19 Roger Pueyo Centelles
Note: checking out '944c45d'.
77 19 Roger Pueyo Centelles
78 19 Roger Pueyo Centelles
You are in 'detached HEAD' state. You can look around, make experimental
79 19 Roger Pueyo Centelles
changes and commit them, and you can discard any commits you make in this
80 19 Roger Pueyo Centelles
state without impacting any branches by performing another checkout.
81 19 Roger Pueyo Centelles
82 19 Roger Pueyo Centelles
If you want to create a new branch to retain commits you create, you may
83 19 Roger Pueyo Centelles
do so (now or later) by using -b with the checkout command again. Example:
84 19 Roger Pueyo Centelles
85 19 Roger Pueyo Centelles
  git checkout -b new_branch_name
86 19 Roger Pueyo Centelles
87 19 Roger Pueyo Centelles
HEAD is now at 944c45d... Import "Fix typo in RouterStationPro switch configuration".
88 19 Roger Pueyo Centelles
</pre>
89 19 Roger Pueyo Centelles
90 19 Roger Pueyo Centelles
However, git now is not in a branch, but in a detached state:
91 19 Roger Pueyo Centelles
92 19 Roger Pueyo Centelles
<pre>
93 19 Roger Pueyo Centelles
git --git-dir=build/qmp/.git branch
94 19 Roger Pueyo Centelles
95 19 Roger Pueyo Centelles
* (detached from 944c45d)
96 19 Roger Pueyo Centelles
  master
97 19 Roger Pueyo Centelles
</pre>
98 19 Roger Pueyo Centelles
99 19 Roger Pueyo Centelles
A new local branch must be created. Otherwise compilation will most surely fail. The new local branch can be named "pladebarris":http://www.guifi.net/raval:
100 19 Roger Pueyo Centelles
101 19 Roger Pueyo Centelles
<pre>
102 19 Roger Pueyo Centelles
git --git-dir=build/qmp/.git checkout -b pladebarris
103 19 Roger Pueyo Centelles
104 19 Roger Pueyo Centelles
[...]
105 19 Roger Pueyo Centelles
Switched to a new branch 'pladebarris'
106 19 Roger Pueyo Centelles
</pre>
107 19 Roger Pueyo Centelles
108 21 Roger Pueyo Centelles
* [Optional] qMp is based on "OpenWrt":http://www.openwrt.org, which is also developed using "revisions":https://dev.openwrt.org/timeline. The qMp firmware build process downloads, by default, the "stable OpenWrt release":http://wiki.openwrt.org/about/history with the latest revision (as of 4th January 2014, "Attitude Adjustment":https://dev.openwrt.org/browser/branches/attitude_adjustment "revision 39154":https://dev.openwrt.org/log/branches/attitude_adjustment?rev=39154. It might be possible that an old revision of qMp would not work with the latest OpenWrt revision. If, for any reason, the qMp firmware must be built from a previous OpenWrt revision, the Makefile file must be edited:
109 21 Roger Pueyo Centelles
110 21 Roger Pueyo Centelles
Uncomment the OWRT_SVN_REV variable and specify the desired OpenWrt revision, for example "r36842":https://dev.openwrt.org/log/branches/attitude_adjustment?rev=36842
111 21 Roger Pueyo Centelles
<pre>
112 21 Roger Pueyo Centelles
OWRT_SVN_REV = 36842
113 21 Roger Pueyo Centelles
</pre>
114 21 Roger Pueyo Centelles
115 21 Roger Pueyo Centelles
Then add the OpenWrt revision declaration in every _svn co $(OWRT_SVN)..._ or _svn co ${OWRT_PKG_SVN}..._ command inside the Makefile:
116 21 Roger Pueyo Centelles
117 21 Roger Pueyo Centelles
<pre>
118 21 Roger Pueyo Centelles
[...]
119 21 Roger Pueyo Centelles
120 21 Roger Pueyo Centelles
define checkout_src
121 21 Roger Pueyo Centelles
        svn co $(OWRT_SVN) $(BUILD_PATH)
122 21 Roger Pueyo Centelles
[...]
123 21 Roger Pueyo Centelles
124 21 Roger Pueyo Centelles
define checkout_owrt_pkg_override
125 21 Roger Pueyo Centelles
        svn co ${OWRT_PKG_SVN} $(BUILD_DIR)/packages.$(TARGET)
126 21 Roger Pueyo Centelles
127 21 Roger Pueyo Centelles
[...]
128 21 Roger Pueyo Centelles
129 21 Roger Pueyo Centelles
.checkout_owrt_pkg:
130 21 Roger Pueyo Centelles
        svn co ${OWRT_PKG_SVN} $(BUILD_DIR)/packages
131 21 Roger Pueyo Centelles
132 21 Roger Pueyo Centelles
[...]
133 21 Roger Pueyo Centelles
</pre>
134 21 Roger Pueyo Centelles
135 21 Roger Pueyo Centelles
for
136 21 Roger Pueyo Centelles
137 21 Roger Pueyo Centelles
<pre>
138 21 Roger Pueyo Centelles
[...]
139 21 Roger Pueyo Centelles
140 21 Roger Pueyo Centelles
define checkout_src
141 21 Roger Pueyo Centelles
        svn co --revision=$(OWRT_SVN_REV) $(OWRT_SVN) $(BUILD_PATH)
142 21 Roger Pueyo Centelles
[...]
143 21 Roger Pueyo Centelles
144 21 Roger Pueyo Centelles
define checkout_owrt_pkg_override
145 21 Roger Pueyo Centelles
        svn co --revision=$(OWRT_SVN_REV) ${OWRT_PKG_SVN} $(BUILD_DIR)/packages.$(TARGET)
146 21 Roger Pueyo Centelles
147 21 Roger Pueyo Centelles
[...]
148 21 Roger Pueyo Centelles
149 21 Roger Pueyo Centelles
.checkout_owrt_pkg:
150 21 Roger Pueyo Centelles
        svn co --revision=$(OWRT_SVN_REV) ${OWRT_PKG_SVN} $(BUILD_DIR)/packages
151 21 Roger Pueyo Centelles
152 21 Roger Pueyo Centelles
[...]
153 21 Roger Pueyo Centelles
</pre>
154 20 Roger Pueyo Centelles
155 19 Roger Pueyo Centelles
* And compile it specifying the target: <pre>make build T=nsm5</pre>
156 19 Roger Pueyo Centelles
157 19 Roger Pueyo Centelles
After that, you will find the images ready to install in your devices inside directory images/