OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [user-guide/] [building-and-running-sample-appliations.html] - Blame information for rev 661

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 unneback
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
2
<!-- This material may be distributed only subject to the terms      -->
3
<!-- and conditions set forth in the Open Publication License, v1.0  -->
4
<!-- or later (the latest version is presently available at          -->
5
<!-- http://www.opencontent.org/openpub/).                           -->
6
<!-- Distribution of the work or derivative of the work in any       -->
7
<!-- standard (paper) book form is prohibited unless prior           -->
8
<!-- permission is obtained from the copyright holder.               -->
9
<HTML
10
><HEAD
11
><TITLE
12
>Building and Running Sample Applications</TITLE
13
><meta name="MSSmartTagsPreventParsing" content="TRUE">
14
<META
15
NAME="GENERATOR"
16
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17
"><LINK
18
REL="HOME"
19
TITLE="eCos User Guide"
20
HREF="ecos-user-guide.html"><LINK
21
REL="UP"
22
TITLE="Programming With eCos"
23
HREF="user-guide-programming.html"><LINK
24
REL="PREVIOUS"
25
TITLE="Testing Filters"
26
HREF="testing-filters.html"><LINK
27
REL="NEXT"
28
TITLE="A Sample Program with Two Threads"
29
HREF="sample-twothreads.html"></HEAD
30
><BODY
31
CLASS="CHAPTER"
32
BGCOLOR="#FFFFFF"
33
TEXT="#000000"
34
LINK="#0000FF"
35
VLINK="#840084"
36
ALINK="#0000FF"
37
><DIV
38
CLASS="NAVHEADER"
39
><TABLE
40
SUMMARY="Header navigation table"
41
WIDTH="100%"
42
BORDER="0"
43
CELLPADDING="0"
44
CELLSPACING="0"
45
><TR
46
><TH
47
COLSPAN="3"
48
ALIGN="center"
49
>eCos User Guide</TH
50
></TR
51
><TR
52
><TD
53
WIDTH="10%"
54
ALIGN="left"
55
VALIGN="bottom"
56
><A
57
HREF="testing-filters.html"
58
ACCESSKEY="P"
59
>Prev</A
60
></TD
61
><TD
62
WIDTH="80%"
63
ALIGN="center"
64
VALIGN="bottom"
65
></TD
66
><TD
67
WIDTH="10%"
68
ALIGN="right"
69
VALIGN="bottom"
70
><A
71
HREF="sample-twothreads.html"
72
ACCESSKEY="N"
73
>Next</A
74
></TD
75
></TR
76
></TABLE
77
><HR
78
ALIGN="LEFT"
79
WIDTH="100%"></DIV
80
><DIV
81
CLASS="CHAPTER"
82
><H1
83
><A
84
NAME="BUILDING-AND-RUNNING-SAMPLE-APPLIATIONS">Chapter 13. Building and Running Sample Applications</H1
85
><DIV
86
CLASS="TOC"
87
><DL
88
><DT
89
><B
90
>Table of Contents</B
91
></DT
92
><DT
93
><A
94
HREF="building-and-running-sample-appliations.html#ECOS-HELLO-WORLD"
95
><SPAN
96
CLASS="PRODUCTNAME"
97
>eCos</SPAN
98
> Hello World</A
99
></DT
100
><DT
101
><A
102
HREF="sample-twothreads.html"
103
>A Sample Program with Two Threads</A
104
></DT
105
></DL
106
></DIV
107
><P
108
>The example programs in this tutorial are included, along
109
with a <TT
110
CLASS="FILENAME"
111
>Makefile</TT
112
>, in the <TT
113
CLASS="FILENAME"
114
>examples</TT
115
> directory
116
of the <SPAN
117
CLASS="PRODUCTNAME"
118
>eCos</SPAN
119
> distribution. The first program you will run is a <SPAN
120
CLASS="emphasis"
121
><I
122
CLASS="EMPHASIS"
123
>hello
124
world</I
125
></SPAN
126
>-style application, then you will run a more complex
127
application that demonstrates the creation of threads and the use
128
of cyg_thread_delay(), and finally you will run
129
one that uses clocks and alarm handlers.</P
130
><P
131
>The <TT
132
CLASS="FILENAME"
133
>Makefile</TT
134
> depends on an externally
135
defined variable to find the <SPAN
136
CLASS="PRODUCTNAME"
137
>eCos</SPAN
138
> library and header files. This
139
variable is <TT
140
CLASS="LITERAL"
141
>INSTALL_DIR</TT
142
> and must be set to the
143
pathname of the install directory created in <A
144
HREF="using-configtool-windows-linux.html"
145
>the Section called <I
146
>Configuration Tool on Windows and Linux Quick Start</I
147
> in Chapter 11</A
148
>.</P
149
><P
150
><TT
151
CLASS="LITERAL"
152
>INSTALL_DIR</TT
153
> may be either be set in the shell
154
environment or may be supplied on the command line. To set it in the
155
shell do the following in a <B
156
CLASS="COMMAND"
157
>bash</B
158
> shell:</P
159
><TABLE
160
BORDER="5"
161
BGCOLOR="#E0E0F0"
162
WIDTH="70%"
163
><TR
164
><TD
165
><PRE
166
CLASS="PROGRAMLISTING"
167
>$ export INSTALL_DIR=BASE_DIR/ecos-work/arm_install</PRE
168
></TD
169
></TR
170
></TABLE
171
><P
172
>You can then run <B
173
CLASS="COMMAND"
174
>make</B
175
> without any extra parameters
176
to build the examples.</P
177
><P
178
>Alternatively, if you can do the following:</P
179
><TABLE
180
BORDER="5"
181
BGCOLOR="#E0E0F0"
182
WIDTH="70%"
183
><TR
184
><TD
185
><PRE
186
CLASS="PROGRAMLISTING"
187
>$ make INSTALL_DIR=BASE_DIR/ecos-work/arm_install</PRE
188
></TD
189
></TR
190
></TABLE
191
><DIV
192
CLASS="SECT1"
193
><H1
194
CLASS="SECT1"
195
><A
196
NAME="ECOS-HELLO-WORLD"><SPAN
197
CLASS="PRODUCTNAME"
198
>eCos</SPAN
199
> Hello World</H1
200
><P
201
>The following code is found in the file <TT
202
CLASS="FILENAME"
203
>hello.c</TT
204
>
205
in the <TT
206
CLASS="FILENAME"
207
>examples</TT
208
> directory: </P
209
><DIV
210
CLASS="SECT2"
211
><H2
212
CLASS="SECT2"
213
><A
214
NAME="AEN835"><SPAN
215
CLASS="PRODUCTNAME"
216
>eCos</SPAN
217
> hello world program listing</H2
218
><TABLE
219
BORDER="5"
220
BGCOLOR="#E0E0F0"
221
WIDTH="70%"
222
><TR
223
><TD
224
><PRE
225
CLASS="PROGRAMLISTING"
226
>/* this is a simple hello world program */
227
#include &lt;stdio.h&#62;
228
int main(void)
229
{
230
 printf("Hello, eCos world!\n");
231
 return 0;
232
}</PRE
233
></TD
234
></TR
235
></TABLE
236
><P
237
>To compile this or any other program that is not part of the
238
<SPAN
239
CLASS="PRODUCTNAME"
240
>eCos</SPAN
241
> distribution, you can follow the procedures described below. Type
242
this explicit compilation command (assuming your current working
243
directory is also where you built the <SPAN
244
CLASS="PRODUCTNAME"
245
>eCos</SPAN
246
> kernel):</P
247
><TABLE
248
BORDER="5"
249
BGCOLOR="#E0E0F0"
250
WIDTH="70%"
251
><TR
252
><TD
253
><PRE
254
CLASS="PROGRAMLISTING"
255
>$ <TT
256
CLASS="REPLACEABLE"
257
><I
258
>TARGET-</I
259
></TT
260
>gcc -g -I<TT
261
CLASS="REPLACEABLE"
262
><I
263
>BASE_DIR</I
264
></TT
265
>/ecos-work/install/include hello.c -L<TT
266
CLASS="REPLACEABLE"
267
><I
268
>BASE_DIR</I
269
></TT
270
>/ecos-work/install/lib -Ttarget.ld -nostdlib</PRE
271
></TD
272
></TR
273
></TABLE
274
><P
275
>The compilation command above contains some standard GCC
276
options (for example, <TT
277
CLASS="OPTION"
278
>-g</TT
279
> enables debugging), as well
280
as some mention of paths
281
(<TT
282
CLASS="OPTION"
283
>-I<TT
284
CLASS="REPLACEABLE"
285
><I
286
>BASE_DIR</I
287
></TT
288
>/ecos-work/install/include</TT
289
> allows files
290
like <TT
291
CLASS="FILENAME"
292
>cyg/kernel/kapi.h</TT
293
> to be found, and
294
<TT
295
CLASS="OPTION"
296
>-L<TT
297
CLASS="REPLACEABLE"
298
><I
299
>BASE_DIR</I
300
></TT
301
>/ecos-work/install/lib</TT
302
> allows the linker to
303
find <TT
304
CLASS="OPTION"
305
>-Ttarget.ld</TT
306
>). </P
307
><P
308
>The executable program will be called <TT
309
CLASS="FILENAME"
310
>a.out</TT
311
>. </P
312
><DIV
313
CLASS="NOTE"
314
><BLOCKQUOTE
315
CLASS="NOTE"
316
><P
317
><B
318
>Note: </B
319
>Some target systems require special options to be passed to
320
gcc to compile correctly for that system. Please examine the Makefile
321
in the examples directory to see if this applies to your target.</P
322
></BLOCKQUOTE
323
></DIV
324
><P
325
>You can now run the resulting program using GDB in exactly the
326
same the way you ran the test case before. The procedure will be the
327
same, but this time run
328
<B
329
CLASS="COMMAND"
330
><TT
331
CLASS="REPLACEABLE"
332
><I
333
>TARGET-</I
334
></TT
335
>gdb</B
336
> specifying
337
<TT
338
CLASS="OPTION"
339
>-nw a.out</TT
340
> on the command line:</P
341
><TABLE
342
BORDER="5"
343
BGCOLOR="#E0E0F0"
344
WIDTH="70%"
345
><TR
346
><TD
347
><PRE
348
CLASS="PROGRAMLISTING"
349
>$ <TT
350
CLASS="REPLACEABLE"
351
><I
352
>TARGET-</I
353
></TT
354
>gdb -nw a.out</PRE
355
></TD
356
></TR
357
></TABLE
358
><P
359
>For targets other than the synthetic linux target, you should
360
now run the usual GDB commands described earlier. Once this is done,
361
typing the command "continue" at the (gdb) prompt ("run" for
362
simulators) will allow the program to execute and print the string
363
"Hello, eCos world!" on your screen.</P
364
><P
365
>On the synthetic linux target, you may use the "run" command
366
immediately - you do not need to connect to the target, nor use the
367
"load" command.</P
368
></DIV
369
></DIV
370
></DIV
371
><DIV
372
CLASS="NAVFOOTER"
373
><HR
374
ALIGN="LEFT"
375
WIDTH="100%"><TABLE
376
SUMMARY="Footer navigation table"
377
WIDTH="100%"
378
BORDER="0"
379
CELLPADDING="0"
380
CELLSPACING="0"
381
><TR
382
><TD
383
WIDTH="33%"
384
ALIGN="left"
385
VALIGN="top"
386
><A
387
HREF="testing-filters.html"
388
ACCESSKEY="P"
389
>Prev</A
390
></TD
391
><TD
392
WIDTH="34%"
393
ALIGN="center"
394
VALIGN="top"
395
><A
396
HREF="ecos-user-guide.html"
397
ACCESSKEY="H"
398
>Home</A
399
></TD
400
><TD
401
WIDTH="33%"
402
ALIGN="right"
403
VALIGN="top"
404
><A
405
HREF="sample-twothreads.html"
406
ACCESSKEY="N"
407
>Next</A
408
></TD
409
></TR
410
><TR
411
><TD
412
WIDTH="33%"
413
ALIGN="left"
414
VALIGN="top"
415
>Testing Filters</TD
416
><TD
417
WIDTH="34%"
418
ALIGN="center"
419
VALIGN="top"
420
><A
421
HREF="user-guide-programming.html"
422
ACCESSKEY="U"
423
>Up</A
424
></TD
425
><TD
426
WIDTH="33%"
427
ALIGN="right"
428
VALIGN="top"
429
>A Sample Program with Two Threads</TD
430
></TR
431
></TABLE
432
></DIV
433
></BODY
434
></HTML
435
>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.