-
Notifications
You must be signed in to change notification settings - Fork 6
/
README.html
396 lines (285 loc) · 13.3 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<p>This file shall briefly describe the ways how to handle the snapshot.</p>
<p>We would really like that you read all of the README before asking
questions, although this file might be longer than you (and we) want.
Thanks a lot in advance.</p>
<h1>Host system requirements</h1>
<p>The host system shall be a x86 32bit or 64bit based system with a recent
Linux distribution installed and at least 2GB of free disk space.</p>
<p>All necessary tools required by the build are available from the provided
packages of the Linux distributions, including cross compilers. But
there are also other cross compiler packages available (see below).
You might want to run <code>make check_build_tools</code> in the src/l4
directory to verify the common tools are installed.</p>
<p>You are free to use any Linux distribution you like, or even BSDs or any of
its derivatives. But then you should know the game. Especially tool
versions should be recent, as installed on the listed distributions below.</p>
<p>We are confident that the snapshot works on the following distributions:</p>
<ul>
<li>Debian 9 or later</li>
<li>Ubuntu 16.10 or later</li>
</ul>
<h1>Cross Compilers</h1>
<h2>Cross Compiling for ARM</h2>
<p>For compiling software for the ARM targets on an x86 host a cross
compiler is needed.</p>
<p>For ARM:</p>
<p>Two popular prebuilt cross compilers exist. You can also check
http://elinux.org/ARMCompilers for more info:</p>
<ul>
<li><p>Arm cross-compilers:</p>
<p><a href="https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a">https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a</a></p>
<p>Note that the Arm cross compilers build for hard floating point, so
builds with those compilers will only work on appropriate targets.
This compiler will not work for ARMv5/ARM9 targets.</p></li>
<li><p>Codesourcery / Mentor cross-compilers:
See <a href="https://elinux.org/ARMCompilers">https://elinux.org/ARMCompilers</a> to
get an arm-2014.05 version. Alternatively go via
<a href="https://sourcery.mentor.com/GNUToolchain/">https://sourcery.mentor.com/GNUToolchain/</a>.</p></li>
<li><p>Distributions:</p>
<p>Linux distributions, such as Debian, also provide cross compilers.</p></li>
<li><p>Alternatively:</p>
<p>You have your own gcc cross compiler with at least version 4.7 installed
that is known to be working.</p></li>
</ul>
<h2>Cross compiling for MIPS</h2>
<p>For compiling software for MIPS on an x86 host a cross compiler is needed.</p>
<p>Download cross compilers from:</p>
<p><a href="https://www.mips.com/develop/tools/codescape-mips-sdk/download-codescape-mips-sdk-essentials/">https://www.mips.com/develop/tools/codescape-mips-sdk/download-codescape-mips-sdk-essentials/</a></p>
<p>Note, when compiling for r2, use the "mti" variant.
When compiling for r6, use the "img" variant.</p>
<p>Other cross compiler builds can also work. Any (positive + negative)
feedback welcome.</p>
<h2>Using the Cross Compiler</h2>
<p>Cross compilers are used via the common <code>CROSS_COMPILE</code> variable.
<code>make setup</code> also asks for a <code>CROSS_COMPILE</code> prefix to be used for
a specific build.</p>
<h1>Building</h1>
<p>In the upper most directory of the archive (the same directory where this
README is located) contains a Makefile. To setup the snapshot issue</p>
<pre><code>make setup
</code></pre>
<p>and to build it issue</p>
<pre><code>make
</code></pre>
<p>in the snapshot directory. Add -j X as appropriate.</p>
<h1>Directory layout</h1>
<ul>
<li><p><code>bin/</code>
Configuration logics for this snapshot.</p></li>
<li><p><code>doc/</code></p>
<p><code>source/</code>
Contains documentation automatically generated from the documented
source code. Overview documentation is also included there.
l4re-doc-full.pdf and l4re-doc-base.pdf: PDF file of the generated code
html: HTML version of the documentation. Can be viewed in any recent
web browser.</p></li>
<li><p><code>obj/</code>
Generated object code will be placed under the obj directory.</p>
<p><code>fiasco/</code>
Fiasco build directories.</p>
<p><code>l4/</code>
L4Re build drectories.</p>
<p><code>l4linux/</code>
L4Linux build directories.</p></li>
<li><p><code>src/</code>
Contains the source code:
<code>fiasco</code>: Fiasco source
<code>l4</code>: L4Re source
<code>l4linux</code>: L4Linux</p></li>
<li><p>files/
Miscellaneous files.</p>
<ul>
<li><code>ramdisk-x86.rd</code>: Ramdisks for (L4)Linux.</li>
<li><code>ramdisk-arm.rd</code>: Ramdisks for (L4)Linux.</li>
<li><code>ramdisk-amd64.rd</code>: Ramdisks for (L4)Linux.</li>
<li><code>ramdisk-armv8-64.rd</code>: Ramdisks for (L4)Linux.</li>
</ul></li>
</ul>
<p>All object directories are built by default.</p>
<h1>Serial Console</h1>
<p>If you happen to use Windows as your workstation OS to connect to your
target machine we recommend using PuTTY (free, open source tool, ask your
favorite search engine) as a terminal emulator. Hyperterm is not
recommended because it is basically unable to display all the output
properly.</p>
<p>On Linux hosts the situation is much more relaxed, minicom and PuTTY are
known to work, as probably any other solution.</p>
<h1>QEMU</h1>
<p>To run the built system under QEMU, go to an appropriate
<code>obj/l4</code>-directory of your choice, such as <code>obj/l4/x86</code>, and run:</p>
<pre><code>make qemu
</code></pre>
<p>This will display a dialog menu to let you choose an entry to boot. For
example, choose 'hello' and you should see the system starting and finally
see "Hello World" scroll by periodically.</p>
<h1>Configuring yourself</h1>
<p>The <code>make setup</code> step configures predefined setups for both the
L4Re microkernel (Fiasco) and the L4Re user-level software, and
connects both together so the images for the target system can be
built.</p>
<p>Of course, you can also do this yourself for your specific targets.</p>
<p>Generally, the microkernel is built for a very specific target, i.e. it is
build for a SoC, such as ARM's Zedboard based on the Xilinx Zynq platform,
or the MIPS Baikal-T.</p>
<p>In contrast, L4Re is built for the architecture and possibly
sub-architecture (CPU variant). Again referring to the Zedboard and
Baikal-T, L4Re would be compiled for the ARMv7-A ARM CPU variant and
MIPS32r2 variant respectively.</p>
<h2>Configure the L4Re microkernel aka Fiasco </h2>
<p>Within the snapshot layout build directories for Fiasco are created under
<code>obj/fiasco</code>. To create a build directory, go to <code>src/fiasco</code> and do:</p>
<pre><code>$ cd src/fiasco
$ make B=../../obj/fiasco/builddir
Creating build directory "../../obj/fiasco/builddir"...
done.
</code></pre>
<p>This will have created a build directory, go there and configure it
according to your requirements:</p>
<pre><code>$ cd ../../obj/fiasco/builddir
$ make config
</code></pre>
<p><code>make config</code> will open up a configuration menu. Configure Fiasco as
required. Finally save the configuration and build:</p>
<pre><code>$ make -j4
</code></pre>
<p>When successful, this will create a file <code>fiasco</code> in the build directory.</p>
<h2>Configure L4Re User-Level Infrastructure</h2>
<p>Within the snapshot layout build directories for the L4Re user-level
infrastructure are under <code>obj/l4</code>. To create a build directory, go to
<code>src/l4</code> and do:</p>
<pre><code>$ cd src/l4
$ make B=../../obj/l4/builddir
</code></pre>
<p>This will have created a build directory, go there and configure
it according to your requirements:</p>
<pre><code>$ cd ../../obj/l4/builddir
$ make config
</code></pre>
<p><code>make config</code> will open up a configuration menu. Configure as
required. Finally save the configuration build:</p>
<pre><code>$ make -j4
</code></pre>
<p>Building will compile all the components of L4Re, however, it will not build
an image that you can load on the target.</p>
<h2>Pulling it together</h2>
<p>For creating images to load on the target, the image building step
needs to know where all the files can be found to include in the image.
The image contains all the executable program files of the setup to build,
including the Fiasco kernel, but also other files that are necessary
to run the setup, such as configuration files, ramdisks, or data files.</p>
<p>The image building step is integrated in the l4re build system. All
relevant configuration settings for building an image are
taken from <code>src/l4/conf/Makeconf.boot</code>. A template is available
as <code>src/l4/conf/Makeconf.boot.example</code>, and it is encouraged that you
copy that file to <code>src/l4/conf/Makeconf.boot</code>.</p>
<p>The most relevant variable in that file is <code>MODULE_SEARCH_PATH</code> which
defines where the image building process shall look for files. This variable
has absolute paths separated with either spaces or colons (':').
For the examples to work, we need to add the path to the Fiasco
build directory as you have chosen in the above building step.
Change the line accordingly.</p>
<p>When done, you can proceed to build an image. Go to the l4 build directory
and create an image. You can create ELF, uimage and raw images, chose
whichever one you need for your target's boot loader.</p>
<pre><code>$ obj/l4/builddir
$ make uimage PLATFORM_TYPE=rv_vexpress
</code></pre>
<p>This will present you a menu of selectable setups and will finally
build the image. You can avoid some typing by using shortcuts:</p>
<pre><code>$ make uimage E=hello PT=rv_vexpress
</code></pre>
<p>The built image can be found in the <code>images</code> sub-directory, e.g. as
<code>images/bootstrap_hello.uimage</code>.</p>
<p>Use that uimage file to load it on the target using u-boot.</p>
<h2>Setup Configuration, and more</h2>
<p>The configuration file to configure the contents of images and generally
the entries to boot is</p>
<pre><code>src/l4/conf/modules.list
</code></pre>
<p>It contains <code>entry</code> sections with modules for each entries listed.
When using non-absolute paths, the image building will you the
<code>MODULE_SEARCH_PATH</code> to find those files. You can also use absolute paths.</p>
<p>The Makeconf.boot file is a <code>make</code> file, allowing for individual
configuration according to your needs. You may use available variables such
as <code>PLATFORM_TYPE</code>, <code>BUILD_ARCH</code>, and <code>QEMU_OPTIONS</code> to construct
configurations as required by different targets and architectures.</p>
<p>The Makeconf.boot file can also be stored in a build directory under the
<code>conf/</code> sub-directory.</p>
<h1>Adding your own code</h1>
<p>Your own code should be placed outside the snapshot directory. This allows
that the snapshot can be replaced with a more recent version without
needing to take care about your own files and directories.</p>
<p>Software components are usually put into so-called packages, and each
package has a structure like this:</p>
<pre><code>pkgname/
doc/ - Documentation for the package
include/ - Public headers for the package
lib/ - Library code
src/
server/ - Program code
src/
</code></pre>
<p>This is just a recommended structure, it is not required to be like that.
What is built is defined in the Makefiles in each directory.</p>
<p>A typical Makefile looks like this:</p>
<pre><code>PKGDIR ?= .
L4DIR ?= path/to/your/l4dir
# Statements specific to the used role
include $(L4DIR)/mk/<role>.mk
</code></pre>
<p>Role might be:
* <code>subdir</code>: Descent to further subdirectories
* <code>lib</code>: Build a library
* <code>prog</code>: Build a program
* <code>include</code>: Process include files</p>
<p>The directory <code>l4/mk/tmpl</code> contains a template package directory layout
structure and shows how a package might look like. It also contains
examples on what to do in the Makefiles.</p>
<p>A very basic example might go like this:</p>
<pre><code>$ mkdir /tmp/myfirstpkg
$ cd /tmp/myfirstpkg
$ editor Makefile
$ cat Makefile
PKGDIR ?= .
L4DIR ?= /path/to/snapshot/src/l4
TARGET = myfirstprogram
SRC_C = main.c
include $(L4DIR)/mk/prog.mk
$ editor main.c
$ cat main.c
#include <stdio.h>
int main(void)
{
printf("Hello!\n");
return 0;
}
$ make O=/path/to/snapshot/obj/l4/arm-rv-arm9
...
$ ls /path/to/snapshot/obj/l4/arm-rv-arm9/bin/arm_rv/l4f/myfirstprogram
/path/to/snapshot/obj/l4/arm-rv-arm9/bin/arm_rv/l4f/myfirstprogram
$
</code></pre>
<h2>Tips and tricks</h2>
<p>If you're just building for one build directory you can do the
following to avoid the <code>O=...</code> argument on every make call.</p>
<p>Put <code>O=/path/to/the/build-dir</code> into L4DIR/Makeconf.local</p>
<p>Also, you can just issue 'make' in the build directories directly.</p>
<h2>Setup for multiple packages</h2>
<p>Create a directory structure like this:</p>
<pre><code>dir/
dir/pkg1
dir/pkg2
dir/pkg3
</code></pre>
<p>Put this Makefile into dir/Makefile:</p>
<pre><code>PKGDIR = .
L4DIR ?= /path/to/your/l4dir/l4
TARGET = $(wildcard [a-zA-Z]*)
include $(L4DIR)/mk/subdir.mk
</code></pre>
<p>This will build all sub packages from within this directory. Make sure
to define L4DIR properly in every Makefile in the packages (or
alternatively, include a file which defines it, but this file has to be
absolute as well).
In the package directories you can have the normal Makefiles as in
<code>l4/pkg/pkgname</code>.</p>