[417fcc73] | 1 | @c |
---|
[df631170] | 2 | @c COPYRIGHT (c) 1988-2010. |
---|
[417fcc73] | 3 | @c On-Line Applications Research Corporation (OAR). |
---|
| 4 | @c All rights reserved. |
---|
| 5 | @c |
---|
| 6 | @c $Id$ |
---|
| 7 | @c |
---|
| 8 | |
---|
[6113b3a] | 9 | @chapter Building RTEMS |
---|
[417fcc73] | 10 | |
---|
[6449498] | 11 | @section Obtain the RTEMS Source Code |
---|
[417fcc73] | 12 | |
---|
[df631170] | 13 | This section provides pointers to the RTEMS source code and example |
---|
| 14 | programs. These files should be placed in your @code{archive} directory. |
---|
| 15 | The set of tarballs which comprise an RTEMS release is placed in a |
---|
[e184e3d] | 16 | directory whose name is the release on the ftp site. The RTEMS ftp site |
---|
[df631170] | 17 | is accessible via both the ftp and http protocols at the following URLs: |
---|
[e184e3d] | 18 | |
---|
[df631170] | 19 | @itemize @bullet |
---|
| 20 | @item @uref{http://www.rtems.org/ftp/pub/rtems,http://www.rtems.org/ftp/pub/rtems} |
---|
| 21 | @item @uref{ftp://www.rtems.org/pub/rtems,ftp://www.rtems.org/pub/rtems} |
---|
| 22 | @end itemize |
---|
[417fcc73] | 23 | |
---|
[df631170] | 24 | Associated with each RTEMS Release is a set of example programs. |
---|
| 25 | Prior to the 4.10 Release Series, these examples were in a "Class |
---|
| 26 | Examples" and an "Examples" collection. Beginning with the 4.10 Release |
---|
| 27 | Series, these examples collections were merged and other examples added. |
---|
| 28 | This new collection is called "Examples V2". It is contained in the file |
---|
| 29 | @code{examples-v2-<VERSION>.tar.bz2>} within the RTEMS release directory. |
---|
[6449498] | 30 | |
---|
| 31 | @c |
---|
| 32 | @c Unarchive the RTEMS Source |
---|
| 33 | @c |
---|
| 34 | |
---|
| 35 | @section Unarchive the RTEMS Source |
---|
| 36 | |
---|
| 37 | Use the following command sequence to unpack the RTEMS source into the |
---|
[e184e3d] | 38 | tools directory: |
---|
[1732414] | 39 | |
---|
| 40 | @example |
---|
[6449498] | 41 | cd tools |
---|
[df631170] | 42 | tar xjf ../archive/rtems-@value{RTEMSAPI}.<VERSION>.tar.bz2 |
---|
[1732414] | 43 | @end example |
---|
| 44 | |
---|
[df631170] | 45 | This creates the directory rtems-@value{RTEMSAPI}.<VERSION> |
---|
[1732414] | 46 | |
---|
[e184e3d] | 47 | @section Obtaining the RTEMS Source from CVS |
---|
| 48 | |
---|
| 49 | Instead of downloading release tarballs you may choose to check out the current |
---|
| 50 | RTEMS source from CVS. For details on accessing RTEMS CVS repository consult |
---|
| 51 | @uref{http://www.rtems.org/wiki/index.php/RTEMS_CVS_Repository, http://www.rtems.org/wiki/index.php/RTEMS_CVS_Repository}. The steps required |
---|
| 52 | to obtain the source code from CVS are usually like the following: |
---|
| 53 | @example |
---|
| 54 | $ cvs -d :pserver:anoncvs@@www.rtems.com:/usr1/CVS login |
---|
| 55 | Logging in to :pserver:anoncvs@@www.rtems.com:2401/usr1/CVS |
---|
| 56 | CVS password: |
---|
| 57 | $ cvs -d :pserver:anoncvs@@www.rtems.com:/usr1/CVS -z 9 co -P rtems # for the main RTEMS source |
---|
| 58 | $ cvs -d :pserver:anoncvs@@www.rtems.com:/usr1/CVS -z 9 co -P examples-v2 # for examples |
---|
| 59 | @end example |
---|
| 60 | |
---|
[57a736ff] | 61 | @section Add <INSTALL_POINT>/bin to Executable PATH |
---|
[417fcc73] | 62 | |
---|
[bdec2709] | 63 | In order to compile RTEMS, you must have the cross compilation toolset |
---|
[34ffa99] | 64 | in your search path. It is important to have the RTEMS toolset first |
---|
| 65 | in your path to ensure that you are using the intended version of all |
---|
[df631170] | 66 | tools. The following command prepends the directory where |
---|
| 67 | the tools were installed in a previous step. If you are using |
---|
| 68 | binaries provided by the RTEMS Project, the <INSTALL_POINT> will be |
---|
| 69 | @code{/opt/rtems-@value{RTEMSAPI}} |
---|
[417fcc73] | 70 | |
---|
| 71 | @example |
---|
[da8c85d] | 72 | export PATH=<INSTALL_POINT>/bin:$@{PATH@} |
---|
[417fcc73] | 73 | @end example |
---|
| 74 | |
---|
[df631170] | 75 | @b{NOTE:} The above command is in Bourne shell (@code{sh}) syntax and should |
---|
| 76 | work with the Korn (@code{ksh}) and GNU Bourne Again Shell (@code{bash}). |
---|
| 77 | It will not work with the C Shell (@code{csh}) or derivatives of the |
---|
| 78 | C Shell. |
---|
[c1c5ab9] | 79 | |
---|
| 80 | @section Verifying the Operation of the Cross Toolset |
---|
| 81 | |
---|
[e184e3d] | 82 | In order to ensure that the cross-compiler is invoking the correct |
---|
[c1c5ab9] | 83 | subprograms (like @code{as} and @code{ld}), one can test assemble |
---|
[e184e3d] | 84 | a small program. When in verbose mode, @code{gcc} prints out information |
---|
[6449498] | 85 | showing where it found the subprograms it invokes. In a temporary |
---|
| 86 | working directory, place the following function in a file named @code{f.c}: |
---|
[c1c5ab9] | 87 | |
---|
| 88 | @example |
---|
| 89 | int f( int x ) |
---|
[6cede6e] | 90 | @{ |
---|
[c1c5ab9] | 91 | return x + 1; |
---|
[6cede6e] | 92 | @} |
---|
[c1c5ab9] | 93 | @end example |
---|
| 94 | |
---|
| 95 | Then assemble the file using a command similar to the following: |
---|
| 96 | |
---|
| 97 | @example |
---|
[df631170] | 98 | m68k-rtems@value{RTEMSAPI}-gcc -v -S f.c |
---|
[c1c5ab9] | 99 | @end example |
---|
| 100 | |
---|
[df631170] | 101 | Where @code{m68k} should be changed to match the target architecture |
---|
| 102 | of your cross compiler. The result of this command will be a sequence |
---|
| 103 | of output showing where the cross-compiler searched for and found |
---|
| 104 | its subcomponents. Verify that these paths correspond to your |
---|
| 105 | <INSTALL_POINT>. |
---|
[c1c5ab9] | 106 | |
---|
[6449498] | 107 | Look at the created file @code{f.s} and verify that it is in fact |
---|
| 108 | for your target processor. |
---|
[bdec2709] | 109 | |
---|
[6449498] | 110 | Then try to compile the file @code{f.c} directly to object code |
---|
| 111 | using a command like the following: |
---|
[3fccbb34] | 112 | |
---|
| 113 | @example |
---|
[df631170] | 114 | m68k-rtems@code{RTEMSAPI}-gcc -v -c f.c |
---|
[3fccbb34] | 115 | @end example |
---|
| 116 | |
---|
[df631170] | 117 | If this produces messages that indicate the assembly code is not valid, |
---|
| 118 | then it is likely that you have fallen victim to one of the problems |
---|
| 119 | described in @ref{Error Message Indicates Invalid Option to Assembler} |
---|
| 120 | Please do not feel bad about this and do not give up, one of the most |
---|
| 121 | common installation errors is for the cross-compiler not to be able |
---|
| 122 | to find the cross assembler and default to using the native @code{as}. |
---|
| 123 | This can result in very confusing error messages. |
---|
[6449498] | 124 | |
---|
| 125 | @section Building RTEMS for a Specific Target and BSP |
---|
| 126 | |
---|
[e184e3d] | 127 | This section describes how to configure and build RTEMS |
---|
| 128 | so that it is specifically tailored for your BSP (Board Support Package) |
---|
| 129 | and the CPU model it uses. There is currently only one supported |
---|
[4a675a5c] | 130 | method to compile and install RTEMS: |
---|
[3fccbb34] | 131 | |
---|
| 132 | @itemize @bullet |
---|
[6449498] | 133 | @item direct invocation of @code{configure} and @code{make} |
---|
[3fccbb34] | 134 | @end itemize |
---|
| 135 | |
---|
[6449498] | 136 | Direct invocation of @code{configure} and @code{make} provides more control |
---|
[e184e3d] | 137 | and easier recovery from problems when building. |
---|
[3fccbb34] | 138 | |
---|
[6449498] | 139 | This section describes how to build RTEMS. |
---|
[adee5979] | 140 | |
---|
[3fccbb34] | 141 | @subsection Using the RTEMS configure Script Directly |
---|
| 142 | |
---|
[6113b3a] | 143 | Make a build directory under tools and build the RTEMS product in this |
---|
[df631170] | 144 | directory. The @code{../rtems-@value{RTEMSAPI}.<VERSION>/configure} |
---|
| 145 | command has numerous command line arguments. These arguments are |
---|
| 146 | discussed in detail in documentation that comes with the RTEMS |
---|
| 147 | distribution. A full list of these arguments can be obtained by running |
---|
| 148 | @code{../rtems-@value{RTEMSAPI}.<VERSION>/configure --help} If you |
---|
| 149 | followed the procedure described in the section @ref{Unarchive the |
---|
[e184e3d] | 150 | RTEMS Source} or @ref{Obtaining the RTEMS Source from CVS}, these configuration options can be found in the file |
---|
| 151 | rtems-@value{RTEMSAPI}.<VERSION>/README.configure. |
---|
[417fcc73] | 152 | |
---|
[6449498] | 153 | @b{NOTE}: The GNAT/RTEMS run-time implementation is based on the POSIX |
---|
[df631170] | 154 | API and the GNAT/RTEMS run-time cannot be compiled with networking |
---|
| 155 | disabled. Your application does not have to use networking but it must |
---|
| 156 | be enabled. Thus the RTEMS configuration for a GNAT/RTEMS environment |
---|
| 157 | MUST include the @code{--enable-posix --enable-networking} flag. |
---|
[adee5979] | 158 | |
---|
[bdec2709] | 159 | The following shows the command sequence required to configure, |
---|
[3fccbb34] | 160 | compile, and install RTEMS with the POSIX API, FreeBSD TCP/IP, |
---|
[e184e3d] | 161 | and C++ support disabled. RTEMS will be built to target |
---|
[bdec2709] | 162 | the @code{BOARD_SUPPORT_PACKAGE} board. |
---|
[417fcc73] | 163 | |
---|
| 164 | @example |
---|
[6113b3a] | 165 | mkdir build-rtems |
---|
| 166 | cd build-rtems |
---|
[df631170] | 167 | ../rtems-@value{RTEMSAPI}.VERSION/configure --target=<TARGET_CONFIGURATION> \ |
---|
[bf31efd] | 168 | --disable-posix --disable-networking --disable-cxx \ |
---|
[df631170] | 169 | --enable-rtemsbsp=<BSP>\ |
---|
[bdec2709] | 170 | --prefix=<INSTALL_POINT> |
---|
[e184e3d] | 171 | make all |
---|
| 172 | make install |
---|
[417fcc73] | 173 | @end example |
---|
| 174 | |
---|
[df631170] | 175 | <TARGET> is of the form <CPU>-rtems@value{RTEMSAPI} and the list of |
---|
| 176 | currently supported <TARGET> configuration's and <BSP>'s can be found in |
---|
| 177 | @code{tools/RTEMS-@value{RTEMSAPI}.<VERSION>/README.configure}. |
---|
[417fcc73] | 178 | |
---|
[df631170] | 179 | <INSTALL_POINT> is typically the installation point for the tools and |
---|
| 180 | defaults to @code{/opt/rtems-@value{RTEMSAPI}}. |
---|
[417fcc73] | 181 | |
---|
[df631170] | 182 | BSP is a supported BSP for the selected CPU family. |
---|
| 183 | The list of supported BSPs may be found in the file |
---|
| 184 | @code{tools/rtems-@value{RTEMSAPI}.<VERSION>/README.configure} in the |
---|
| 185 | RTEMS source tree. If the BSP parameter is not specified, then all |
---|
| 186 | supported BSPs for the selected CPU family will be built. |
---|
[6449498] | 187 | |
---|
[df631170] | 188 | @b{NOTE:} The POSIX API and networking must be enabled to use GNAT/RTEMS. |
---|
[6449498] | 189 | |
---|
[4a675a5c] | 190 | @b{NOTE:} The @code{make} utility used should be GNU make. |
---|