1 | @c |
---|
2 | @c COPYRIGHT (c) 1989-2007. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Sample Applications |
---|
10 | |
---|
11 | @section Introduction |
---|
12 | |
---|
13 | The RTEMS source distribution includes a set of sample applications |
---|
14 | that are located in the @code{$@{RTEMS_ROOT@}/testsuites/samples/} |
---|
15 | directory. These applications are intended to illustrate the |
---|
16 | basic format of RTEMS single and multiple processor |
---|
17 | applications and the use of some features. In addition, these |
---|
18 | relatively simple applications can be used to test locally |
---|
19 | developed board support packages and device drivers as they |
---|
20 | exercise a critical subset of RTEMS functionality that is often |
---|
21 | broken in new BSPs. |
---|
22 | |
---|
23 | Some of the following sample applications will be covered in |
---|
24 | more detail in subsequent sections: |
---|
25 | |
---|
26 | @table @b |
---|
27 | @item Hello World |
---|
28 | The RTEMS Hello World test is provided in |
---|
29 | the subdirectory @code{$@{RTEMS_ROOT@}/testsuites/samples/hello/}. |
---|
30 | This test is helpful when testing new RTEMS development environment. |
---|
31 | |
---|
32 | @item Clock Tick |
---|
33 | The @code{$@{RTEMS_ROOT@}/testsuites/samples/ticker/} |
---|
34 | subdirectory provides a test for verification of clock chip |
---|
35 | device drivers of BSPs. |
---|
36 | |
---|
37 | @item Base Single Processor |
---|
38 | A simple single processor test similar to those in the |
---|
39 | single processor test suite is provided in |
---|
40 | @code{$@{RTEMS_ROOT@}/testsuites/samples/base_sp/}. |
---|
41 | |
---|
42 | @item Base Multiple Processor |
---|
43 | A simple two node multiprocessor test capable of testing an newly |
---|
44 | developed MPCI layer is provided in |
---|
45 | @code{$@{RTEMS_ROOT@}/testsuites/samples/base_mp/}. |
---|
46 | |
---|
47 | @item Capture |
---|
48 | The RTEMS Capture test is provided in |
---|
49 | the subdirectory @code{$@{RTEMS_ROOT@}/testsuites/samples/capture/}. |
---|
50 | This is an interactive test which demonstrates the capabilities |
---|
51 | of the RTEMS Capture Engine. It includes a few test threads |
---|
52 | which generate interesting execution patterns. Look at the |
---|
53 | file @code{$@{RTEMS_ROOT@}/testsuites/samples/capture/capture.scn} |
---|
54 | for a sample session. |
---|
55 | |
---|
56 | @item Constructor/Destructor C++ Test |
---|
57 | The @code{$@{RTEMS_ROOT@}/testsuites/samples/cdtest/} |
---|
58 | subdirectory provides a simple C++ application using |
---|
59 | constructors and destructors. It is only built when |
---|
60 | C++ is enabled and its primary purpose is to demonstrate |
---|
61 | that global constructors and destructors work. Since this |
---|
62 | requires that the linker script for your BSP be correct, this is |
---|
63 | an important test. |
---|
64 | |
---|
65 | @item File IO |
---|
66 | The RTEMS File IO test is provided in |
---|
67 | the subdirectory @code{$@{RTEMS_ROOT@}/testsuites/samples/fileio/}. |
---|
68 | This is an interactive test which allows the user to interact with |
---|
69 | an ATA/IDE device. It will read the partition table and allow the |
---|
70 | user to dynamically mount one of the FAT32 partitions it finds. |
---|
71 | Commands are also provided to write and read files on the disk. |
---|
72 | |
---|
73 | @item IO Stream |
---|
74 | The RTEMS IO Stream test is provided in |
---|
75 | the subdirectory @code{$@{RTEMS_ROOT@}/testsuites/samples/iostream/}. |
---|
76 | This test is a simple C++ application which demonstrates that |
---|
77 | C++ iostreams are functional. This requires that the RTEMS C++ |
---|
78 | run-time support is functioning properly. This test is only |
---|
79 | build when C++ is enabled. |
---|
80 | |
---|
81 | @item Network Loopback Test |
---|
82 | The @code{$@{RTEMS_ROOT@}/testsuites/samples/loopback/} |
---|
83 | directory contains a sample test that demonstrates the use of |
---|
84 | sockets and the loopback network device. It does not require |
---|
85 | the presence of network hardware in order to run. |
---|
86 | It is only built if RTEMS was configured with networking enabled. |
---|
87 | |
---|
88 | @item Minimum Size Test |
---|
89 | The directory |
---|
90 | @code{$@{RTEMS_ROOT@}/testsuites/samples/minimum/} |
---|
91 | contains a simple RTEMS program that results in a non-functional |
---|
92 | executable. It is intended to show the size of a minimum footprint |
---|
93 | application based upon the current RTEMS configuration. |
---|
94 | |
---|
95 | @item Nanoseconds |
---|
96 | The RTEMS Nanoseconds test is provided in |
---|
97 | the subdirectory @code{$@{RTEMS_ROOT@}/testsuites/samples/nsecs/}. |
---|
98 | This test demonstrates that the BSP has support for nanosecond |
---|
99 | timestamp granularity. It prints the time of day and uptime multiple |
---|
100 | times as quickly as possible. It should be possible from the output |
---|
101 | to determine if your BSP has nanosecond accurate clock support |
---|
102 | and it is functional. |
---|
103 | |
---|
104 | @item Paranoia Floating Point Test |
---|
105 | The directory @code{$@{RTEMS_ROOT@}/testsuites/samples/paranoia/} |
---|
106 | contains the public domain floating point and math library test. |
---|
107 | |
---|
108 | @item Point-to-Point Protocol Daemon |
---|
109 | The RTEMS Point-to-Point Protocol Daemon test is provided in |
---|
110 | the subdirectory @code{$@{RTEMS_ROOT@}/testsuites/samples/pppd/}. |
---|
111 | This test primarily serves as the baseline for a user application |
---|
112 | using the PPP protocol. |
---|
113 | |
---|
114 | @item Unlimited Object Allocation |
---|
115 | The @code{$@{RTEMS_ROOT@}/testsuites/samples/unlimited/} |
---|
116 | directory contains a sample test that demonstrates the use of the |
---|
117 | @i{unlimited} object allocation configuration option to RTEMS. |
---|
118 | |
---|
119 | @end table |
---|
120 | |
---|
121 | The sample tests are written using the Classic API so the reader |
---|
122 | should be familiar with the terms used and |
---|
123 | material presented in the @b{RTEMS Applications Users Guide}. |
---|
124 | |
---|
125 | @c |
---|
126 | @c |
---|
127 | @c |
---|
128 | @section Hello World |
---|
129 | |
---|
130 | This sample application is in the following directory: |
---|
131 | |
---|
132 | @example |
---|
133 | $@{RTEMS_ROOT@}/testsuites/samples/hello/ |
---|
134 | @end example |
---|
135 | |
---|
136 | It provides a rudimentary test of the BSP start up |
---|
137 | code and the console output routine. The C version of this |
---|
138 | sample application uses the printf function from the RTEMS |
---|
139 | Standard C Library to output messages. The Ada version of this |
---|
140 | sample uses the TEXT_IO package to output the hello messages. |
---|
141 | The following messages are printed: |
---|
142 | |
---|
143 | @example |
---|
144 | @group |
---|
145 | *** HELLO WORLD TEST *** |
---|
146 | Hello World |
---|
147 | *** END OF HELLO WORLD TEST *** |
---|
148 | @end group |
---|
149 | @end example |
---|
150 | |
---|
151 | These messages are printed from the application's |
---|
152 | single initialization task. If the above messages are not |
---|
153 | printed correctly, then either the BSP start up code or the |
---|
154 | console output routine is not operating properly. |
---|
155 | |
---|
156 | @c |
---|
157 | @c |
---|
158 | @c |
---|
159 | @section Clock Tick |
---|
160 | |
---|
161 | This sample application is in the following directory: |
---|
162 | |
---|
163 | @example |
---|
164 | $@{RTEMS_ROOT@}/testsuites/samples/ticker/ |
---|
165 | @end example |
---|
166 | |
---|
167 | This application is designed as a simple test of the |
---|
168 | clock tick device driver. In addition, this application also |
---|
169 | tests the printf function from the RTEMS Standard C Library by |
---|
170 | using it to output the following messages: |
---|
171 | |
---|
172 | @example |
---|
173 | @group |
---|
174 | *** CLOCK TICK TEST *** |
---|
175 | TA1 - tm_get - 09:00:00 12/31/1988 |
---|
176 | TA2 - tm_get - 09:00:00 12/31/1988 |
---|
177 | TA3 - tm_get - 09:00:00 12/31/1988 |
---|
178 | TA1 - tm_get - 09:00:05 12/31/1988 |
---|
179 | TA1 - tm_get - 09:00:10 12/31/1988 |
---|
180 | TA2 - tm_get - 09:00:10 12/31/1988 |
---|
181 | TA1 - tm_get - 09:00:15 12/31/1988 |
---|
182 | TA3 - tm_get - 09:00:15 12/31/1988 |
---|
183 | TA1 - tm_get - 09:00:20 12/31/1988 |
---|
184 | TA2 - tm_get - 09:00:20 12/31/1988 |
---|
185 | TA1 - tm_get - 09:00:25 12/31/1988 |
---|
186 | TA1 - tm_get - 09:00:30 12/31/1988 |
---|
187 | TA2 - tm_get - 09:00:30 12/31/1988 |
---|
188 | TA3 - tm_get - 09:00:30 12/31/1988 |
---|
189 | *** END OF CLOCK TICK TEST *** |
---|
190 | @end group |
---|
191 | @end example |
---|
192 | |
---|
193 | The clock tick sample application utilizes a single |
---|
194 | initialization task and three copies of the single application |
---|
195 | task. The initialization task prints the test herald, sets the |
---|
196 | time and date, and creates and starts the three application |
---|
197 | tasks before deleting itself. The three application tasks |
---|
198 | generate the rest of the output. Every five seconds, one or |
---|
199 | more of the tasks will print the current time obtained via the |
---|
200 | tm_get directive. The first task, TA1, executes every five |
---|
201 | seconds, the second task, TA2, every ten seconds, and the third |
---|
202 | task, TA3, every fifteen seconds. If the time printed does not |
---|
203 | match the above output, then the clock device driver is not |
---|
204 | operating properly. |
---|
205 | |
---|
206 | @c |
---|
207 | @c |
---|
208 | @c |
---|
209 | @section Base Single Processor Application |
---|
210 | |
---|
211 | This sample application is in the following directory: |
---|
212 | |
---|
213 | @example |
---|
214 | $@{RTEMS_ROOT@}/testsuites/samples/base_sp/ |
---|
215 | @end example |
---|
216 | |
---|
217 | It provides a framework from which a single processor |
---|
218 | RTEMS application can be developed. The use of the task argument |
---|
219 | is illustrated. This sample application uses the printf |
---|
220 | function from the RTEMS Standard C Library or TEXT_IO functions |
---|
221 | when using the Ada version to output the following messages: |
---|
222 | |
---|
223 | @example |
---|
224 | @group |
---|
225 | *** SAMPLE SINGLE PROCESSOR APPLICATION *** |
---|
226 | Creating and starting an application task |
---|
227 | Application task was invoked with argument (0) and has id of 0x10002 |
---|
228 | *** END OF SAMPLE SINGLE PROCESSOR APPLICATION *** |
---|
229 | @end group |
---|
230 | @end example |
---|
231 | |
---|
232 | The first two messages are printed from the |
---|
233 | application's single initialization task. The final messages |
---|
234 | are printed from the single application task. |
---|
235 | |
---|
236 | @c |
---|
237 | @c |
---|
238 | @c |
---|
239 | @section Base Multiple Processor Application |
---|
240 | |
---|
241 | This sample application is in the following directory: |
---|
242 | |
---|
243 | @example |
---|
244 | $@{RTEMS_ROOT@}/testsuites/samples/base_mp/ |
---|
245 | @end example |
---|
246 | |
---|
247 | It provides a framework from which a multiprocessor |
---|
248 | RTEMS application can be developed. This directory has a |
---|
249 | subdirectory for each node in the multiprocessor system. The |
---|
250 | task argument is used to distinguish the node on which the |
---|
251 | application task is executed. The first node will print the |
---|
252 | following messages: |
---|
253 | |
---|
254 | @example |
---|
255 | @group |
---|
256 | *** SAMPLE MULTIPROCESSOR APPLICATION *** |
---|
257 | Creating and starting an application task |
---|
258 | This task was invoked with the node argument (1) |
---|
259 | This task has the id of 0x10002 |
---|
260 | *** END OF SAMPLE MULTIPROCESSOR APPLICATION *** |
---|
261 | @end group |
---|
262 | @end example |
---|
263 | |
---|
264 | The second node will print the following messages: |
---|
265 | |
---|
266 | @example |
---|
267 | @group |
---|
268 | *** SAMPLE MULTIPROCESSOR APPLICATION *** |
---|
269 | Creating and starting an application task |
---|
270 | This task was invoked with the node argument (2) |
---|
271 | This task has the id of 0x20002 |
---|
272 | *** END OF SAMPLE MULTIPROCESSOR APPLICATION *** |
---|
273 | @end group |
---|
274 | @end example |
---|
275 | |
---|
276 | The herald is printed from the application's single |
---|
277 | initialization task on each node. The final messages are |
---|
278 | printed from the single application task on each node. |
---|
279 | |
---|
280 | In this sample application, all source code is shared |
---|
281 | between the nodes except for the node dependent configuration |
---|
282 | files. These files contains the definition of the node number |
---|
283 | used in the initialization of the RTEMS Multiprocessor |
---|
284 | Configuration Table. This file is not shared because the node |
---|
285 | number field in the RTEMS Multiprocessor Configuration Table |
---|
286 | must be unique on each node. |
---|
287 | |
---|
288 | @c |
---|
289 | @c |
---|
290 | @c |
---|
291 | @section Constructor/Destructor C++ Application |
---|
292 | |
---|
293 | This sample application is in the following directory: |
---|
294 | |
---|
295 | @example |
---|
296 | $@{RTEMS_ROOT@}/testsuites/samples/cdtest/ |
---|
297 | @end example |
---|
298 | |
---|
299 | This sample application demonstrates that RTEMS is |
---|
300 | compatible with C++ applications. It uses constructors, |
---|
301 | destructor, and I/O stream output in testing these various |
---|
302 | capabilities. The board support package responsible for this |
---|
303 | application must support a C++ environment. |
---|
304 | |
---|
305 | This sample application uses the printf function from |
---|
306 | the RTEMS Standard C Library to output the following messages: |
---|
307 | |
---|
308 | @example |
---|
309 | @group |
---|
310 | Hey I'M in base class constructor number 1 for 0x400010cc. |
---|
311 | Hey I'M in base class constructor number 2 for 0x400010d4. |
---|
312 | Hey I'M in derived class constructor number 3 for 0x400010d4. |
---|
313 | *** CONSTRUCTOR/DESTRUCTOR TEST *** |
---|
314 | Hey I'M in base class constructor number 4 for 0x4009ee08. |
---|
315 | Hey I'M in base class constructor number 5 for 0x4009ee10. |
---|
316 | Hey I'M in base class constructor number 6 for 0x4009ee18. |
---|
317 | Hey I'M in base class constructor number 7 for 0x4009ee20. |
---|
318 | Hey I'M in derived class constructor number 8 for 0x4009ee20. |
---|
319 | Testing a C++ I/O stream |
---|
320 | Hey I'M in derived class constructor number 8 for 0x4009ee20. |
---|
321 | Derived class - Instantiation order 8 |
---|
322 | Hey I'M in base class constructor number 7 for 0x4009ee20. |
---|
323 | Instantiation order 8 |
---|
324 | Hey I'M in base class constructor number 6 for 0x4009ee18. |
---|
325 | Instantiation order 6 |
---|
326 | Hey I'M in base class constructor number 5 for 0x4009ee10. |
---|
327 | Instantiation order 5 |
---|
328 | Hey I'M in base class constructor number 4 for 0x4009ee08. |
---|
329 | Instantiation order 5 |
---|
330 | *** END OF CONSTRUCTOR/DESTRUCTOR TEST *** |
---|
331 | Hey I'M in base class constructor number 3 for 0x400010d4. |
---|
332 | Hey I'M in base class constructor number 2 for 0x400010d4. |
---|
333 | Hey I'M in base class constructor number 1 for 0x400010cc. |
---|
334 | @end group |
---|
335 | @end example |
---|
336 | |
---|
337 | @c |
---|
338 | @c |
---|
339 | @c |
---|
340 | @section Minimum Size Test |
---|
341 | |
---|
342 | This sample application is in the following directory: |
---|
343 | |
---|
344 | @example |
---|
345 | $@{RTEMS_ROOT@}/testsuites/samples/minimum/ |
---|
346 | @end example |
---|
347 | |
---|
348 | This sample application is designed to produce the |
---|
349 | minimum code space required for any RTEMS application |
---|
350 | based upon the current RTEMS configuration and |
---|
351 | BSP. In many situations, the bulk of this executable |
---|
352 | consists of hardware and RTEMS initialization, basic |
---|
353 | infrastructure such as malloc(), and RTEMS and |
---|
354 | hardware shutdown support. |
---|
355 | |
---|
356 | @c |
---|
357 | @c |
---|
358 | @c |
---|
359 | @section Nanosecond Granularity Application |
---|
360 | |
---|
361 | This sample application is in the following directory: |
---|
362 | |
---|
363 | @example |
---|
364 | $@{RTEMS_ROOT@}/testsuites/samples/nsecs/ |
---|
365 | @end example |
---|
366 | |
---|
367 | This sample application exercises the Clock Driver |
---|
368 | for this BSP and demonstrates its ability to generate |
---|
369 | accurate timestamps. This application does this by |
---|
370 | exercising the time subsystem in three ways: |
---|
371 | |
---|
372 | @itemize @bullet |
---|
373 | @item Obtain Time of Day Twice Back to Back |
---|
374 | @item Obtain System Up Time Twice Back to Back |
---|
375 | @item Use System Up Time to Measure Loops |
---|
376 | @end itemize |
---|
377 | |
---|
378 | The following is an example of what the output of this |
---|
379 | test may appear like: |
---|
380 | |
---|
381 | @example |
---|
382 | *** NANOSECOND CLOCK TEST *** |
---|
383 | 10 iterations of getting TOD |
---|
384 | Start: Sat Mar 24 11:15:00 2007:540000 |
---|
385 | Stop : Sat Mar 24 11:15:00 2007:549000 --> 0:9000 |
---|
386 | Start: Sat Mar 24 11:15:00 2007:3974000 |
---|
387 | Stop : Sat Mar 24 11:15:00 2007:3983000 --> 0:9000 |
---|
388 | Start: Sat Mar 24 11:15:00 2007:7510000 |
---|
389 | Stop : Sat Mar 24 11:15:00 2007:7519000 --> 0:9000 |
---|
390 | Start: Sat Mar 24 11:15:00 2007:11054000 |
---|
391 | Stop : Sat Mar 24 11:15:00 2007:11063000 --> 0:9000 |
---|
392 | Start: Sat Mar 24 11:15:00 2007:14638000 |
---|
393 | Stop : Sat Mar 24 11:15:00 2007:14647000 --> 0:9000 |
---|
394 | Start: Sat Mar 24 11:15:00 2007:18301000 |
---|
395 | Stop : Sat Mar 24 11:15:00 2007:18310000 --> 0:9000 |
---|
396 | Start: Sat Mar 24 11:15:00 2007:21901000 |
---|
397 | Stop : Sat Mar 24 11:15:00 2007:21910000 --> 0:9000 |
---|
398 | Start: Sat Mar 24 11:15:00 2007:25526000 |
---|
399 | Stop : Sat Mar 24 11:15:00 2007:25535000 --> 0:9000 |
---|
400 | Start: Sat Mar 24 11:15:00 2007:29196000 |
---|
401 | Stop : Sat Mar 24 11:15:00 2007:29206000 --> 0:10000 |
---|
402 | Start: Sat Mar 24 11:15:00 2007:32826000 |
---|
403 | Stop : Sat Mar 24 11:15:00 2007:32835000 --> 0:9000 |
---|
404 | |
---|
405 | 10 iterations of getting Uptime |
---|
406 | 0:38977000 0:38986000 --> 0:9000 |
---|
407 | 0:40324000 0:40332000 --> 0:8000 |
---|
408 | 0:41636000 0:41645000 --> 0:9000 |
---|
409 | 0:42949000 0:42958000 --> 0:9000 |
---|
410 | 0:44295000 0:44304000 --> 0:9000 |
---|
411 | 0:45608000 0:45617000 --> 0:9000 |
---|
412 | 0:46921000 0:46930000 --> 0:9000 |
---|
413 | 0:48282000 0:48291000 --> 0:9000 |
---|
414 | 0:49595000 0:49603000 --> 0:8000 |
---|
415 | 0:50908000 0:50917000 --> 0:9000 |
---|
416 | |
---|
417 | 10 iterations of getting Uptime with different loop values |
---|
418 | loop of 10000 0:119488000 0:119704000 --> 0:216000 |
---|
419 | loop of 20000 0:124028000 0:124463000 --> 0:435000 |
---|
420 | loop of 30000 0:128567000 0:129220000 --> 0:653000 |
---|
421 | loop of 40000 0:133097000 0:133964000 --> 0:867000 |
---|
422 | loop of 50000 0:137643000 0:138728000 --> 0:1085000 |
---|
423 | loop of 60000 0:142265000 0:143572000 --> 0:1307000 |
---|
424 | loop of 70000 0:146894000 0:148416000 --> 0:1522000 |
---|
425 | loop of 80000 0:151519000 0:153260000 --> 0:1741000 |
---|
426 | loop of 90000 0:156145000 0:158099000 --> 0:1954000 |
---|
427 | loop of 100000 0:160770000 0:162942000 --> 0:2172000 |
---|
428 | *** END OF NANOSECOND CLOCK TEST *** |
---|
429 | @end example |
---|
430 | |
---|
431 | @c |
---|
432 | @c |
---|
433 | @c |
---|
434 | @section Paranoia Floating Point Application |
---|
435 | |
---|
436 | This sample application is in the following directory: |
---|
437 | |
---|
438 | @example |
---|
439 | $@{RTEMS_ROOT@}/testsuites/samples/paranoia/ |
---|
440 | @end example |
---|
441 | |
---|
442 | This sample application uses a public domain floating |
---|
443 | point and math library test to verify these capabilities of the |
---|
444 | RTEMS executive. Deviations between actual and expected results |
---|
445 | are reported to the screen. This is a very extensive test which |
---|
446 | tests all mathematical and number conversion functions. |
---|
447 | Paranoia is also very large and requires a long period of time |
---|
448 | to run. Problems which commonly prevent this test from |
---|
449 | executing to completion include stack overflow and FPU exception |
---|
450 | handlers not installed. |
---|
451 | |
---|
452 | @c |
---|
453 | @c |
---|
454 | @c |
---|
455 | @section Network Loopback Test |
---|
456 | |
---|
457 | This sample application is in the following directory: |
---|
458 | |
---|
459 | @example |
---|
460 | $@{RTEMS_ROOT@}/testsuites/samples/loopback/ |
---|
461 | @end example |
---|
462 | |
---|
463 | This sample application uses the network loopback device to |
---|
464 | demonstrate the use of the RTEMS TCP/IP stack. This sample |
---|
465 | test illustrates the basic configuration and initialization |
---|
466 | of the TCP/IP stack as well as simple socket usage. |
---|
467 | |
---|