1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-2002. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Building the Sample Applications |
---|
10 | |
---|
11 | The RTEMS distribution includes a number of sample C, C++, |
---|
12 | Ada, and networking applications. This chapter will provide |
---|
13 | an overview of those sample applications. |
---|
14 | |
---|
15 | @c |
---|
16 | @c Set the Environment Variable RTEMS_MAKEFILE_PATH |
---|
17 | @c |
---|
18 | @section Set the Environment Variable RTEMS_MAKEFILE_PATH |
---|
19 | |
---|
20 | The sample application sets use the RTEMS Application Makefiles. |
---|
21 | This requires that the environment variable |
---|
22 | @code{RTEMS_MAKEFILE_PATH} point to the appropriate directory containing |
---|
23 | the installed RTEMS image built to target your particular CPU and |
---|
24 | board support package combination. |
---|
25 | |
---|
26 | @example |
---|
27 | export RTEMS_MAKEFILE_PATH=<INSTALLATION_POINT>/<BOARD_SUPPORT_PACKAGE> |
---|
28 | @end example |
---|
29 | |
---|
30 | Where <INSTALLATION_POINT> and <BOARD_SUPPORT_PACKAGE> are those used when |
---|
31 | configuring and installing RTEMS. |
---|
32 | |
---|
33 | NOTE: In release 4.0, BSPs were installed at |
---|
34 | @code{<INSTALLATION_POINT>/rtems/<BOARD_SUPPORT_PACKAGE>}. This |
---|
35 | was changed to be more in compliance with GNU standards. |
---|
36 | |
---|
37 | NOTE: GNU make is the preferred @code{make} utility. Other @code{make} |
---|
38 | implementations may work but all testing is done with GNU make. |
---|
39 | |
---|
40 | If no errors are detected during the sample application build, it is |
---|
41 | reasonable to assume that the build of the GNU Cross Compiler Tools |
---|
42 | for RTEMS and RTEMS itself for the selected host and target |
---|
43 | combination was done properly. |
---|
44 | |
---|
45 | @c |
---|
46 | @c Executing the Sample Applications |
---|
47 | @c |
---|
48 | @section Executing the Sample Applications |
---|
49 | |
---|
50 | How each sample application executable is downloaded |
---|
51 | to your target board and executed is very dependent |
---|
52 | on the board you are using. The following is a list of |
---|
53 | commonly used BSPs classified by their RTEMS CPU family and pointers |
---|
54 | to instructions on how to use them. [NOTE: All file names should be |
---|
55 | prepended with @value{RTEMSUNTAR}/c/src/lib/libbsp.] |
---|
56 | |
---|
57 | @need 1000 |
---|
58 | @table @b |
---|
59 | |
---|
60 | @item arm/edp7312 |
---|
61 | The arm/edp7312 BSP is for the ARM7-based Cogent EDP7312 board. |
---|
62 | |
---|
63 | @item c4x/c4xsim |
---|
64 | The c4x/c4xsim BSP is designed to execute on any member of |
---|
65 | the Texas Instruments C3x/C4x DSP family using only on-CPU |
---|
66 | peripherals for the console and timers. |
---|
67 | |
---|
68 | @item i386/pc386 |
---|
69 | See @code{i386/pc386/HOWTO} |
---|
70 | |
---|
71 | @item i386/pc486 |
---|
72 | The i386/pc386 BSP specially compiled for an i486-class CPU. |
---|
73 | |
---|
74 | @item i386/pc586 |
---|
75 | The i386/pc386 BSP specially compiled for a Pentium-class CPU. |
---|
76 | |
---|
77 | @item i386/pc686 |
---|
78 | The i386/pc386 BSP specially compiled for a Pentium II. |
---|
79 | |
---|
80 | @item i386/pck6 |
---|
81 | The i386/pc386 BSP specially compiled for an AMD K6. |
---|
82 | |
---|
83 | @item m68k/gen68360 |
---|
84 | This BSP is for a MC68360 CPU. See @code{m68k/gen68360/README} for details. |
---|
85 | |
---|
86 | @item m68k/mvme162 |
---|
87 | See @code{m68k/mvme162/README}. |
---|
88 | |
---|
89 | @item m68k/mvme167 |
---|
90 | See @code{m68k/mvme167/README}. |
---|
91 | |
---|
92 | @item mips/jmr3904 |
---|
93 | This is a BSP for the Toshiba TX3904 evaluation board |
---|
94 | simulator included with @code{mipstx39-rtems-gdb}. The |
---|
95 | BSP is located in @code{mips/jmr3904}. |
---|
96 | The TX3904 is a MIPS R3000 class CPU with serial ports and timers |
---|
97 | integrated with the processor. This BSP can be used with |
---|
98 | either real hardware or with the simulator included with |
---|
99 | @code{mipstx39-rtems-gdb}. An application can be run on the simulator |
---|
100 | by executing the following commands upon entering @code{mipstx39-rtems-gdb}: |
---|
101 | |
---|
102 | @example |
---|
103 | target sim --board=jmr3904 |
---|
104 | load |
---|
105 | run |
---|
106 | @end example |
---|
107 | |
---|
108 | @item powerpc/mcp750 |
---|
109 | See @code{powerpc/motorola_shared/README}. |
---|
110 | |
---|
111 | @item powerpc/mvme230x |
---|
112 | See @code{powerpc/motorola_shared/README.MVME2300}. |
---|
113 | |
---|
114 | @item powerpc/psim |
---|
115 | This is a BSP for the PowerPC simulator included with @code{powerpc-rtems-gdb}. |
---|
116 | The simulator is complicated to initialize by hand. The user is referred |
---|
117 | to the script @code{powerpc/psim/tools/psim}. |
---|
118 | |
---|
119 | @item sparc/erc32 |
---|
120 | The ERC32 is a radiation hardened SPARC V7. This BSP can be used with |
---|
121 | either real ERC32 hardware or with the simulator included with |
---|
122 | @code{sparc-rtems-gdb}. An application can be run on the simulator |
---|
123 | by executing the following commands upon entering @code{sparc-rtems-gdb}: |
---|
124 | |
---|
125 | @example |
---|
126 | target sim |
---|
127 | load |
---|
128 | run |
---|
129 | @end example |
---|
130 | |
---|
131 | @end table |
---|
132 | |
---|
133 | RTEMS has many more BSPs and new BSPs for commercial boards and CPUs |
---|
134 | with on-CPU peripherals are generally welcomed. |
---|
135 | |
---|
136 | @c |
---|
137 | @c C/C++ Sample Applications |
---|
138 | @c |
---|
139 | @section C/C++ Sample Applications |
---|
140 | |
---|
141 | The C/C++ sample application set includes a number of simple applications. |
---|
142 | Some demonstrate some basic functionality in RTEMS such as writing |
---|
143 | a file, closing it, and reading it back while others can serve as |
---|
144 | starting points for RTEMS applications or libraries. Start by |
---|
145 | unarchiving them so you can peruse them. Use a command similar to |
---|
146 | the following to unarchive the sample applications: |
---|
147 | |
---|
148 | @example |
---|
149 | cd tools |
---|
150 | tar xjf ../archive/examples-VERSION.tgz |
---|
151 | @end example |
---|
152 | |
---|
153 | The sample applications most likely to be of interest to you are: |
---|
154 | |
---|
155 | @itemize @bullet |
---|
156 | @item hello_world_c - C Hello World application with a simple |
---|
157 | RTEMS configuration and an entry point not called @code{main()}. |
---|
158 | |
---|
159 | @item simple_main - Very simple program starting at @code{main()} |
---|
160 | and shutting down RTEMS via @code{exit()} without any other operations. |
---|
161 | It uses the default configuration inside RTEMS which is only |
---|
162 | intended to satisfy @code{autoconf} probes and extremely simple |
---|
163 | console-based applications. |
---|
164 | |
---|
165 | @item libcpp - Simple C++ library for RTEMS showing how to build an |
---|
166 | application library written in C++. |
---|
167 | |
---|
168 | @item psx_sched_report - POSIX Scheduler Reporter is a program |
---|
169 | that prints out some scheduler attributes of the RTEMS POSIX API. |
---|
170 | |
---|
171 | @end itemize |
---|
172 | |
---|
173 | Each tests is found in a separate subdirectory and built using the |
---|
174 | same command sequence. The @code{hello_world_c} sample will be used |
---|
175 | as an example. |
---|
176 | |
---|
177 | @c |
---|
178 | @c Build the C Hello World Application |
---|
179 | @c |
---|
180 | @subheading Build the C Hello World Application |
---|
181 | |
---|
182 | Use the following command to start the build of the sample hello |
---|
183 | world application: |
---|
184 | |
---|
185 | @example |
---|
186 | cd hello_world_c |
---|
187 | make |
---|
188 | @end example |
---|
189 | |
---|
190 | |
---|
191 | If the sample application has successfully been built, then the application |
---|
192 | executable is placed in the following directory: |
---|
193 | |
---|
194 | @example |
---|
195 | hello_world_c/o-optimize/<filename>.exe |
---|
196 | @end example |
---|
197 | |
---|
198 | The other C/C++ sample applications are built using a similar procedure. |
---|
199 | |
---|
200 | @c |
---|
201 | @c Ada Sample Applications |
---|
202 | @c |
---|
203 | @section Ada Sample Applications |
---|
204 | |
---|
205 | The Ada sample application set primarily includes a |
---|
206 | a simple Hello World Ada program which can be used |
---|
207 | as a starting point for GNAT/RTEMS applications. |
---|
208 | Use the following command to unarchive the Ada sample |
---|
209 | applications: |
---|
210 | |
---|
211 | @example |
---|
212 | cd tools |
---|
213 | tar xzf ../archive/hello_world_ada.tgz |
---|
214 | @end example |
---|
215 | |
---|
216 | @subheading Create a BSP Specific Makefile |
---|
217 | |
---|
218 | Currently, the procedure for building and linking an Ada application |
---|
219 | is a bit more difficult than a C or C++ application. This is certainly |
---|
220 | an opportunity for a volunteer project. |
---|
221 | |
---|
222 | At this time, there is a |
---|
223 | |
---|
224 | Provided are example Makefiles for multiple BSPs. Copy one of these to |
---|
225 | the file Makefile.<BOARD_SUPPORT_PACKAGE> and edit it as appropriate for |
---|
226 | your local configuration. |
---|
227 | |
---|
228 | Use the <INSTALLATION_POINT> and <BOARD_SUPPORT_PACKAGE> specified when |
---|
229 | configuring and installing RTEMS. |
---|
230 | |
---|
231 | @section Build the Sample Application |
---|
232 | |
---|
233 | Use the following command to start the build of the sample application: |
---|
234 | |
---|
235 | @example |
---|
236 | cd tools/hello_world_ada |
---|
237 | make -f Makefile.<BOARD_SUPPORT_PACKAGE> |
---|
238 | @end example |
---|
239 | |
---|
240 | NOTE: GNU make is the preferred @code{make} utility. Other @code{make} |
---|
241 | implementations may work but all testing is done with GNU make. |
---|
242 | |
---|
243 | If the BSP specific modifications to the Makefile were correct and |
---|
244 | no errors are detected during the sample application build, it is |
---|
245 | reasonable to assume that the build of the GNAT/RTEMS Cross Compiler Tools |
---|
246 | for RTEMS and RTEMS itself for the selected host and target |
---|
247 | combination was done properly. |
---|
248 | |
---|
249 | @section Application Executable |
---|
250 | |
---|
251 | If the sample application has successfully been build, then the application |
---|
252 | executable is placed in the following directory: |
---|
253 | |
---|
254 | @example |
---|
255 | tools/hello_world_ada/o-optimize/<filename>.exe |
---|
256 | @end example |
---|
257 | |
---|
258 | How this executable is downloaded to the target board is very dependent |
---|
259 | on the BOARD_SUPPORT_PACKAGE selected. |
---|
260 | ---------------------------------------------------- |
---|
261 | |
---|
262 | @c |
---|
263 | @c More Information on RTEMS Application Makefiles |
---|
264 | @c |
---|
265 | @section More Information on RTEMS Application Makefiles |
---|
266 | |
---|
267 | The hello world sample application is a simple example of an |
---|
268 | RTEMS application that uses the RTEMS Application Makefile |
---|
269 | system. This Makefile system simplifies building |
---|
270 | RTEMS applications by providing Makefile templates and |
---|
271 | capturing the configuration information used to build |
---|
272 | RTEMS specific to your BSP. Building an RTEMS application |
---|
273 | for different BSPs is as simple as switching the |
---|
274 | setting of @code{RTEMS_MAKEFILE_PATH}. This Makefile |
---|
275 | system is described in the file @code{make/README}. |
---|