source: rtems-docs/rsb/quick-start.rst @ 005f0e8

4.115
Last change on this file since 005f0e8 was 8b64335, checked in by Chris Johns <chrisj@…>, on 11/02/16 at 01:09:54

RSB: Finish reformatting after moving from asciidocs.

  • Property mode set to 100644
File size: 21.3 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. comment COPYRIGHT (c) 2012 - 2016.
4.. comment Chris Johns <chrisj@rtems.org>
5
6Quick Start
7###########
8
9The quick start will show you how to build a set of RTEMS tools for a supported
10architecture. The tools are installed into a build *prefix*. The *prefix* is the
11top of a group of directories containing all the files needed to develop RTEMS
12applications. Building an RTEMS build set will build all that you need. This
13includes autoconf, automake, assemblers, linkers, compilers, debuggers,
14standard libraries and RTEMS itself.
15
16There is no need to become root or the administrator and we recommend you
17avoid doing this. You can build and install the tools anywhere on the
18host's file system you, as a standard user, have read and write access
19too. I recommend you use your home directory and work under the directory
20``~/development/rtems``. The examples shown here will do this.
21
22You can use the build *prefix* to install and maintain different versions of
23the tools. Doing this lets you try a new set of tools while not touching your
24proven working production set of tools. Once you have proven the new tools are
25working rebuild with the *production* prefix switching your development to them.
26
27We recommend you keep your environment to the bare minimum, particularly the
28path variable. Using environment variables has been proven over the years to be
29difficult to manage in production systems.
30
31.. warning::
32
33    The RSB assumes your host is set up and the needed packages are installed
34    and configured to work. If your host has not been set up please refer to
35    :ref:`Hosts` and your host's section for packages you need to install.
36
37.. topic:: Path to use when building applications:
38
39    Do not forget to set the path before you use the tools, for example to
40    build the RTEMS kernel.
41
42    The RSB by default will install (copy) the executables to a directory tree
43    under the *prefix* you supply. To use the tools once finished just set your
44    path to the ``bin`` directory under the *prefix* you use. In the examples
45    that follow the *prefix* is ``$HOME/development/rtems/4.11`` and is set
46    using the ``--prefix`` option so the path you need to configure to build
47    applications can be set with the following in a BASH shell:
48
49    .. code-block:: shell
50
51      $ export PATH=$HOME/development/rtems/4.11/bin:$PATH
52
53    Make sure you place the RTEMS tool path at the front of your path so they
54    are searched first. RTEMS can provide newer versions of some tools your
55    operating system provides and placing the RTEMS tools path at the front
56    means it is searched first and the RTEMS needed versions of the tools are
57    used.
58
59.. note::
60
61    RSB and RTEMS have a matching *git branch* for each version of RTEMS. For
62    example, if you want to build a toolchain for 4.11, then you should
63    checkout the 4.11 branch of the RSB:
64
65    .. code-block:: shell
66
67      $ git checkout -t origin/4.11
68
69    Branches are available for the 4.9, 4.10, and 4.11 versions of RTEMS.
70
71Setup
72~~~~~
73
74Setup a development work space::
75
76    $ cd
77    $ mkdir -p development/rtems/src
78    $ cd development/rtems/src
79
80The RTEMS Source Builder is distributed as source. It is Python code so all you
81need to do is download the release's RSB tarball or clone the code directly
82from the RTEMS GIT repository::
83
84    $ git clone git://git.rtems.org/rtems-source-builder.git
85    $ cd rtems-source-builder
86
87.. topic:: Workspaces
88
89   The examples in the *Quick Start Guide* build and install tools in your
90   *home* directory. Please refer to the RTEMS User Manual for more detail
91   about *Sandboxing* and the *prefix*.
92
93Checking
94~~~~~~~~
95
96The next step is to check if your host is set up correctly. The RTEMS Source
97Builder provides a tool to help::
98
99    $ source-builder/sb-check
100    warning: exe: absolute exe found in path: (__objcopy) /usr/local/bin/objcopy <1>
101    warning: exe: absolute exe found in path: (__objdump) /usr/local/bin/objdump
102    error: exe: not found: (_xz) /usr/local/bin/xz    <2>
103    RTEMS Source Builder environment is not correctly set up
104    $ source-builder/sb-check
105    RTEMS Source Builder environment is ok   <3>
106
107.. topic:: Items:
108
109  1. A tool is in the environment path but it does not match the expected path.
110
111  2. The executable ``xz`` is not found.
112
113  3. The host's environment is set up correct.
114
115The checking tool will output a list of executable files not found if problems
116are detected. Locate those executable files and install them. You may also be
117given a list of warnings about executable files not in the expected location
118however the executable was located somewhere in your environment's path. You
119will need to check each tool to determine if this is an issue. An executable
120not in the standard location may indicate it is not the host operating system's
121standard tool. It maybe ok or it could be buggy, only you can determine this.
122
123The :ref:`Hosts` section lists packages you should install for common host
124operating systems. It maybe worth checking if you have those installed.
125
126Build Sets
127~~~~~~~~~~
128
129The RTEMS tools can be built within the RTEMS Source Builder's source tree. We
130recommend you do this so lets change into the RTEMS directory in the RTEMS
131Source Builder package::
132
133    $ cd rtems
134
135If you are unsure how to specify the build set for the architecture you wish to
136build ask the tool::
137
138    $ ../source-builder/sb-set-builder --list-bsets   <1>
139    RTEMS Source Builder - Set Builder, v4.11.0
140    Examining: config
141    Examining: ../source-builder/config    <2>
142        4.10/rtems-all.bset      <3>
143        4.10/rtems-arm.bset      <4>
144        4.10/rtems-autotools.bset
145        4.10/rtems-avr.bset
146        4.10/rtems-bfin.bset
147        4.10/rtems-h8300.bset
148        4.10/rtems-i386.bset
149        4.10/rtems-lm32.bset
150        4.10/rtems-m32c.bset
151        4.10/rtems-m32r.bset
152        4.10/rtems-m68k.bset
153        4.10/rtems-mips.bset
154        4.10/rtems-nios2.bset
155        4.10/rtems-powerpc.bset
156        4.10/rtems-sh.bset
157        4.10/rtems-sparc.bset
158        4.11/rtems-all.bset
159        4.11/rtems-arm.bset
160        4.11/rtems-autotools.bset
161        4.11/rtems-avr.bset
162        4.11/rtems-bfin.bset
163        4.11/rtems-h8300.bset
164        4.11/rtems-i386.bset
165        4.11/rtems-lm32.bset
166        4.11/rtems-m32c.bset
167        4.11/rtems-m32r.bset
168        4.11/rtems-m68k.bset
169        4.11/rtems-microblaze.bset
170        4.11/rtems-mips.bset
171        4.11/rtems-moxie.bset
172        4.11/rtems-nios2.bset
173        4.11/rtems-powerpc.bset
174        4.11/rtems-sh.bset
175        4.11/rtems-sparc.bset
176        4.11/rtems-sparc64.bset
177        4.11/rtems-v850.bset
178        4.9/rtems-all.bset
179        4.9/rtems-arm.bset
180        4.9/rtems-autotools.bset
181        4.9/rtems-i386.bset
182        4.9/rtems-m68k.bset
183        4.9/rtems-mips.bset
184        4.9/rtems-powerpc.bset
185        4.9/rtems-sparc.bset
186        gnu-tools-4.6.bset
187        rtems-4.10-base.bset    <5>
188        rtems-4.11-base.bset
189        rtems-4.9-base.bset
190        rtems-base.bset         <5>
191
192.. topic:: Items:
193
194  1. Only option required is ``--list-bsets``
195
196  2. The paths inspected. See :ref:`Configuration`.
197
198  3. A build set to build all RTEMS 4.10 supported architectures.
199
200  4. The build set for the ARM architecture on RTEMS 4.10.
201
202  5. Support build set file with common functionality included by other build
203     set files.
204
205Building
206~~~~~~~~
207
208The quick start builds a SPARC tool set::
209
210    $ ../source-builder/sb-set-builder --log=l-sparc.txt \   <1>
211          --prefix=$HOME/development/rtems/4.11 \       <2>
212          4.11/rtems-sparc           <3>
213    Source Builder - Set Builder, v0.2.0
214    Build Set: 4.11/rtems-sparc
215    config: expat-2.1.0-1.cfg        <4>
216    package: expat-2.1.0-x86_64-freebsd9.1-1
217    building: expat-2.1.0-x86_64-freebsd9.1-1
218    config: tools/rtems-binutils-2.22-1.cfg        <5>
219    package: sparc-rtems4.11-binutils-2.22-1
220    building: sparc-rtems4.11-binutils-2.22-1
221    config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg   <6>
222    package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
223    building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
224    config: tools/rtems-gdb-7.5.1-1.cfg      <7>
225    package: sparc-rtems4.11-gdb-7.5.1-1
226    building: sparc-rtems4.11-gdb-7.5.1-1
227    installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11 <8>
228    installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
229    installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
230    installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
231    cleaning: expat-2.1.0-x86_64-freebsd9.1-1     <9>
232    cleaning: sparc-rtems4.11-binutils-2.22-1
233    cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
234    cleaning: sparc-rtems4.11-gdb-7.5.1-1
235    Build Set: Time 0:13:43.616383        <10>
236
237.. topic:: Items
238
239  1. Providing a log file redirects the build output into a file. Logging the
240     build output provides a simple way to report problems.
241
242  2. The prefix is the location on your file system the tools are installed
243     into. Provide a prefix to a location you have read and write access. You
244     can use the prefix to install different versions or builds of tools. Just
245     use the path to the tools you want to use when building RTEMS.
246
247  3. The build set. This is the SPARC build set. First a specifically
248     referenced file is checked for and if not found the ``%{_configdir}`` path
249     is searched. The set builder will first look for files with a ``.bset``
250     extension and then for a configuration file with a ``.cfg`` extension.
251
252  4. The SPARC build set first builds the expat library as it is used in GDB.
253     This is the expat configuration used.
254
255  5. The binutils build configuration.
256
257  6. The GCC and Newlib build configuration.
258
259  7. The GDB build configuration.
260
261  8. Installing the built packages to the install prefix.
262
263  9. All the packages built are cleaned at the end. If the build fails all the
264     needed files are present. You may have to clean up by deleting the build
265     directory if the build fails.
266
267  10. The time to build the package. This lets you see how different host
268      hardware or configurations perform.
269
270Your SPARC RTEMS 4.11 tool set will be installed and ready to build RTEMS and
271RTEMS applications. When the build runs you will notice the tool fetch the
272source code from the internet. These files are cached in directies called
273``source`` and ``patches``. If you run the build again the cached files are
274used. This is what happened in the shown example. Archiving these directories
275archives the source you need to recreate the build.
276
277.. topic:: RTEMS Releases
278
279  The RSB found in a release will automatically build and install RTEMS. If you
280  do not want a released version of the RSB to build RTEMS add
281  ``--without-rtems`` to the command line. The development version requires
282  adding ``--with-rtems`` to build RTEMS. Use this option to create a single
283  command to build the tools and RTEMS.
284
285  The source used in release builds is downloaded from the RTEMS FTP
286  server. This ensures the source is always available for a release.
287
288The installed tools::
289
290    $ ls $HOME/development/rtems/4.11
291    bin         include     lib         libexec     share       sparc-rtems4.11
292    $ ls $HOME/development/rtems/4.11/bin
293    sparc-rtems4.11-addr2line       sparc-rtems4.11-cpp
294    sparc-rtems4.11-gcc-ar          sparc-rtems4.11-gprof
295    sparc-rtems4.11-objdump         sparc-rtems4.11-size
296    sparc-rtems4.11-ar              sparc-rtems4.11-elfedit
297    sparc-rtems4.11-gcc-nm          sparc-rtems4.11-ld
298    sparc-rtems4.11-ranlib          sparc-rtems4.11-strings
299    sparc-rtems4.11-as              sparc-rtems4.11-g++
300    sparc-rtems4.11-gcc-ranlib      sparc-rtems4.11-ld.bfd
301    sparc-rtems4.11-readelf         sparc-rtems4.11-strip
302    sparc-rtems4.11-c++             sparc-rtems4.11-gcc
303    sparc-rtems4.11-gcov            sparc-rtems4.11-nm
304    sparc-rtems4.11-run             xmlwf
305    sparc-rtems4.11-c++filt         sparc-rtems4.11-gcc-4.7.2
306    sparc-rtems4.11-gdb             sparc-rtems4.11-objcopy
307    sparc-rtems4.11-sis
308    $ $HOME/development/rtems/4.11/bin/sparc-rtems4.11-gcc -v
309    Using built-in specs.
310    COLLECT_GCC=/home/chris/development/rtems/4.11/bin/sparc-rtems4.11-gcc
311    COLLECT_LTO_WRAPPER=/usr/home/chris/development/rtems/4.11/bin/../ \
312    libexec/gcc/sparc-rtems4.11/4.7.2/lto-wrapper
313    Target: sparc-rtems4.11                         <1>
314    Configured with: ../gcc-4.7.2/configure         <2>
315    --prefix=/home/chris/development/rtems/4.11
316    --bindir=/home/chris/development/rtems/4.11/bin
317    --exec_prefix=/home/chris/development/rtems/4.11
318    --includedir=/home/chris/development/rtems/4.11/include
319    --libdir=/home/chris/development/rtems/4.11/lib
320    --libexecdir=/home/chris/development/rtems/4.11/libexec
321    --mandir=/home/chris/development/rtems/4.11/share/man
322    --infodir=/home/chris/development/rtems/4.11/share/info
323    --datadir=/home/chris/development/rtems/4.11/share
324    --build=x86_64-freebsd9.1 --host=x86_64-freebsd9.1 --target=sparc-rtems4.11
325    --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --verbose --with-newlib
326    --with-system-zlib --disable-nls --without-included-gettext
327    --disable-win32-registry --enable-version-specific-runtime-libs --disable-lto
328    --enable-threads --enable-plugin --enable-newlib-io-c99-formats
329    --enable-newlib-iconv --enable-languages=c,c++
330    Thread model: rtems             <3>
331    gcc version 4.7.2 20120920      <4>
332     (RTEMS 4.11 RSB cb12e4875c203f794a5cd4b3de36101ff9a88403)-1 newlib 2.0.0) (GCC)
333
334.. topic:: Items
335
336  1. The target the compiler is built for.
337
338  2. The configure options used to build GCC.
339
340  3. The threading model is always RTEMS. This makes using the RTEMS tools for
341     bare metal development more difficult.
342
343  4. The version string. It contains the Git hash of the RTEMS Source Builder
344     you are using. If your local clone has been modifed that state is also
345     recorded in the version string. The hash allows you to track from a GCC
346     executable back to the original source used to build it.
347
348.. note::
349
350   The RTEMS thread model enables specific hooks in GCC so applications built
351   with RTEMS tools need the RTEMS runtime to operate correctly. You can use
352   RTEMS tools to build bare metal component but it is more difficult than with
353   a bare metal tool chain and you need to know what you are doing at a low
354   level. The RTEMS Source Builder can build bare metal tool chains as
355   well. Look in the top level ``bare`` directory.
356
357Distributing and Archiving A Build
358~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
359
360If you wish to create and distribute your build or you want to archive a build
361you can create a tar file. This is a more advanced method for binary packaging
362and installing of tools.
363
364By default the RTEMS Source Builder installs the built packages directly and
365optionally it can also create a *build set tar file* or a *package tar file*
366per package built. The normal and default behaviour is to let the RTEMS Source
367Builder install the tools. The source will be downloaded, built, installed and
368cleaned up.
369
370The tar files are created with the full build prefix present and if you follow
371the examples given in this documentation the path is absolute. This can cause
372problems if you are installing on a host you do not have super user or
373administrator rights on because the prefix path may references part you do not
374have write access too and tar will not extract the files. You can use the
375``--strip-components`` option in tar if your host tar application supports it
376to remove the parts you do not have write access too or you may need to unpack
377the tar file somewhere and copy the file tree from the level you have write
378access from. Embedding the full prefix path in the tar files lets you know what
379the prefix is and is recommended. For example if
380``/home/chris/development/rtems/4.11`` is the prefix used you cannot change
381directory to the root (``/``) and install because the ``/home`` is root access
382only. To install you would:
383
384.. code-block:: shell
385
386    $ cd
387    $ tar --strip-components=3 -xjf rtems-4.11-sparc-rtems4.11-1.tar.bz2
388
389
390A build set tar file is created by adding ``--bset-tar-file`` option to the
391``sb-set-builder`` command::
392
393    $ ../source-builder/sb-set-builder --log=l-sparc.txt \
394             --prefix=$HOME/development/rtems/4.11 \
395             --bset-tar-file \     <1>
396             4.11/rtems-sparc
397    Source Builder - Set Builder, v0.2.0
398    Build Set: 4.11/rtems-sparc
399    config: expat-2.1.0-1.cfg
400    package: expat-2.1.0-x86_64-freebsd9.1-1
401    building: expat-2.1.0-x86_64-freebsd9.1-1
402    config: tools/rtems-binutils-2.22-1.cfg
403    package: sparc-rtems4.11-binutils-2.22-1
404    building: sparc-rtems4.11-binutils-2.22-1
405    config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
406    package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
407    building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
408    config: tools/rtems-gdb-7.5.1-1.cfg
409    package: sparc-rtems4.11-gdb-7.5.1-1
410    building: sparc-rtems4.11-gdb-7.5.1-1
411    installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11 <2>
412    installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
413    installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
414    installing: rtems-4.11-sparc-rtems4.11-1 -> /home/chris/development/rtems/4.11
415    tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2      <3>
416    cleaning: expat-2.1.0-x86_64-freebsd9.1-1
417    cleaning: sparc-rtems4.11-binutils-2.22-1
418    cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
419    cleaning: sparc-rtems4.11-gdb-7.5.1-1
420    Build Set: Time 0:15:25.92873
421
422.. topic:: Items
423
424  1. The option to create a build set tar file.
425
426  2. The installation still happens unless you specify ``--no-install``.
427
428  3. Creating the build set tar file.
429
430You can also suppress installing the files using the ``--no-install``
431option. This is useful if your prefix is not accessiable, for example when
432building Canadian cross compiled tool sets::
433
434    $ ../source-builder/sb-set-builder --log=l-sparc.txt \
435                --prefix=$HOME/development/rtems/4.11 \
436                --bset-tar-file \
437                --no-install \      <1>
438                4.11/rtems-sparc
439    Source Builder - Set Builder, v0.2.0
440    Build Set: 4.11/rtems-sparc
441    config: expat-2.1.0-1.cfg
442    package: expat-2.1.0-x86_64-freebsd9.1-1
443    building: expat-2.1.0-x86_64-freebsd9.1-1
444    config: tools/rtems-binutils-2.22-1.cfg
445    package: sparc-rtems4.11-binutils-2.22-1
446    building: sparc-rtems4.11-binutils-2.22-1
447    config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
448    package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
449    building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
450    config: tools/rtems-gdb-7.5.1-1.cfg
451    package: sparc-rtems4.11-gdb-7.5.1-1
452    building: sparc-rtems4.11-gdb-7.5.1-1
453    tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2    <2>
454    cleaning: expat-2.1.0-x86_64-freebsd9.1-1
455    cleaning: sparc-rtems4.11-binutils-2.22-1
456    cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
457    cleaning: sparc-rtems4.11-gdb-7.5.1-1
458    Build Set: Time 0:14:11.721274
459    $ ls tar
460    rtems-4.11-sparc-rtems4.11-1.tar.bz2
461
462.. topic:: Items
463
464  1. The option to supressing installing the packages.
465
466  2. Create the build set tar.
467
468A package tar file can be created by adding the ``--pkg-tar-files`` to the
469``sb-set-builder`` command. This creates a tar file per package built in the
470build set::
471
472    $ ../source-builder/sb-set-builder --log=l-sparc.txt \
473            --prefix=$HOME/development/rtems/4.11 \
474            --bset-tar-file \
475            --pkg-tar-files \        <1>
476            --no-install 4.11/rtems-sparc
477    Source Builder - Set Builder, v0.2.0
478    Build Set: 4.11/rtems-sparc
479    config: expat-2.1.0-1.cfg
480    package: expat-2.1.0-x86_64-freebsd9.1-1
481    building: expat-2.1.0-x86_64-freebsd9.1-1
482    config: tools/rtems-binutils-2.22-1.cfg
483    package: sparc-rtems4.11-binutils-2.22-1
484    building: sparc-rtems4.11-binutils-2.22-1
485    config: tools/rtems-gcc-4.7.2-newlib-1.20.0-1.cfg
486    package: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
487    building: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
488    config: tools/rtems-gdb-7.5.1-1.cfg
489    package: sparc-rtems4.11-gdb-7.5.1-1
490    building: sparc-rtems4.11-gdb-7.5.1-1
491    tarball: tar/rtems-4.11-sparc-rtems4.11-1.tar.bz2
492    cleaning: expat-2.1.0-x86_64-freebsd9.1-1
493    cleaning: sparc-rtems4.11-binutils-2.22-1
494    cleaning: sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1
495    cleaning: sparc-rtems4.11-gdb-7.5.1-1
496    Build Set: Time 0:14:37.658460
497    $ ls tar
498    expat-2.1.0-x86_64-freebsd9.1-1.tar.bz2           sparc-rtems4.11-binutils-2.22-1.tar.bz2
499    sparc-rtems4.11-gdb-7.5.1-1.tar.bz2 <2>           rtems-4.11-sparc-rtems4.11-1.tar.bz2 <3>
500    sparc-rtems4.11-gcc-4.7.2-newlib-1.20.0-1.tar.bz2
501
502.. topic:: Items
503
504  1. The option to create packages tar files.
505
506  2. The GDB package tar file.
507
508  3. The build set tar file. All the others in a single tar file.
509
510Controlling the Build
511~~~~~~~~~~~~~~~~~~~~~
512
513Build sets can be controlled via the command line to enable and disable various
514features. There is no definitive list of build options that can be listed
515because they are implemented with the configuration scripts. The best way to
516find what is available is to grep the configuration files. for ``with`` and
517``without``.
518
519Following are currentlt available:
520
521``--without-rtems``
522  Do not build RTEMS when building an RTEMS build set.
523
524``--without-cxx``
525  Do not build a C++ compiler.
526
527``--with-objc``
528  Attempt to build a C++ compiler.
529
530``--with-fortran``
531  Attempt to build a Fortran compiler.
Note: See TracBrowser for help on using the repository browser.