]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - doc/html/user-guide/programming-with-ecos.html
Initial revision
[karo-tx-redboot.git] / doc / html / user-guide / programming-with-ecos.html
1 <!-- 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 >Programming With eCos</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="Programming With eCos"
26 HREF="user-guide-programming.html"><LINK
27 REL="NEXT"
28 TITLE="Configuring and Building eCos from Source"
29 HREF="configuring-and-building-ecos-from-source.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="user-guide-programming.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="configuring-and-building-ecos-from-source.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="PROGRAMMING-WITH-ECOS">Chapter 10. Programming With <SPAN
85 CLASS="PRODUCTNAME"
86 >eCos</SPAN
87 ></H1
88 ><P
89 >The following chapters of this manual comprise a simple tutorial
90 for configuring and building <SPAN
91 CLASS="PRODUCTNAME"
92 >eCos</SPAN
93 >, building and running <SPAN
94 CLASS="PRODUCTNAME"
95 >eCos</SPAN
96 > tests,
97 and finally building three stand-alone example programs which use
98 the  <SPAN
99 CLASS="PRODUCTNAME"
100 >eCos</SPAN
101 > API to perform some simple tasks.</P
102 ><P
103 >You will need a properly installed <SPAN
104 CLASS="PRODUCTNAME"
105 >eCos</SPAN
106 > system, with the correct
107 versions of the GNU toolchain. On Windows
108 you will be using the bash command line interpreter that comes with
109 Cygwin, with the environment variables set as described in the
110 toolchain documentation.</P
111 ><DIV
112 CLASS="SECT1"
113 ><H1
114 CLASS="SECT1"
115 ><A
116 NAME="DEVELOPMENT-PROCESS">The Development Process</H1
117 ><P
118 >Most development projects using <SPAN
119 CLASS="PRODUCTNAME"
120 >eCos</SPAN
121 > would contain some (or
122 most) of  the following:</P
123 ><DIV
124 CLASS="SECT2"
125 ><H2
126 CLASS="SECT2"
127 ><A
128 NAME="AEN471"><SPAN
129 CLASS="PRODUCTNAME"
130 >eCos</SPAN
131 > Configuration</H2
132 ><P
133 ><SPAN
134 CLASS="PRODUCTNAME"
135 >eCos</SPAN
136 > is configured to provide the desired API (the inclusion
137 of libc, uitron, and the disabling of certain undesired funtions,
138 etc.), and semantics (selecting scheduler, mutex behavior, etc.).
139 See <A
140 HREF="configuring-and-building-ecos-from-source.html"
141 >Chapter 11</A
142 >.</P
143 ><P
144 >It would normally make sense to enable <SPAN
145 CLASS="PRODUCTNAME"
146 >eCos</SPAN
147 > assertion checking
148 at this time as well, to catch as many programming errors during
149 the development phase as possible.</P
150 ><P
151 >Note that it should not be necessary to spend much time on
152 <SPAN
153 CLASS="PRODUCTNAME"
154 >eCos</SPAN
155 > configuration initially. It may be important to perform fine
156 tuning to reduce the memory footprint and to improve performance
157 later when the product reaches a testable state.</P
158 ></DIV
159 ><DIV
160 CLASS="SECT2"
161 ><H2
162 CLASS="SECT2"
163 ><A
164 NAME="AEN481">Integrity check of the <SPAN
165 CLASS="PRODUCTNAME"
166 >eCos</SPAN
167 > configuration</H2
168 ><P
169 >While we strive to thoroughly test <SPAN
170 CLASS="PRODUCTNAME"
171 >eCos</SPAN
172 >, the vast number
173 of configuration permutations mean that the particular configuration
174 parameters used for your project may not have been tested. Therefore,
175 we advise running the <SPAN
176 CLASS="PRODUCTNAME"
177 >eCos</SPAN
178 > tests after the project's
179 <SPAN
180 CLASS="PRODUCTNAME"
181 >eCos</SPAN
182 > configuration has been determined. See <A
183 HREF="running-an-ecos-test-case.html"
184 >Chapter 12</A
185 >.</P
186 ><P
187 >Obviously, this should be repeated if the configuration changes
188 later on in the development process.</P
189 ></DIV
190 ><DIV
191 CLASS="SECT2"
192 ><H2
193 CLASS="SECT2"
194 ><A
195 NAME="AEN490">Application Development - Target Neutral Part</H2
196 ><P
197 >While your project is probably targeting a specific architecture
198 and platform, possibly custom hardware, it may be possible to perform
199 part of the application development using simulated or synthetic
200 targets.</P
201 ><P
202 >There are three good reasons for doing this:</P
203 ><P
204 ></P
205 ><UL
206 ><LI
207 ><P
208 >It may be possible by this means to perform application
209 development in parallel with the design/implementation
210 of the target hardware, thus providing more time for developing
211 and testing functionality, and reducing time-to-market.</P
212 ></LI
213 ><LI
214 ><P
215 >The build-run-debug-cycle may be faster when the application
216 does not have to be downloaded to a target via a serial interface.
217 Debugging is also likely to be more responsive when you do not have to
218 to communicate with the remote GDB stubs in RedBoot via serial. It
219 also removes the need for manually or automatically resetting the
220 target hardware.</P
221 ></LI
222 ><LI
223 ><P
224 >New hardware can often be buggy. Comparing the behaviour of the
225 program on the hardware and in the simulator or synthetic target may
226 allow you to identify where the problems lie.</P
227 ></LI
228 ></UL
229 ><P
230 >This approach is possible because all targets (including
231 simulators and synthetic ones) provide the same basic API: that
232 is, kernel, libc, libm, uitron, infra, and to some extent, HAL and
233 IO.</P
234 ><P
235 >Synthetic targets are especially suitable as they allow you
236 to construct simulations of elaborate devices by interaction with
237 the host system, where an IO device API can hide the details from
238 the application. When switching to hardware later in the development
239 cycle, the IO driver is properly implemented.</P
240 ><P
241 >Simulators can also do this, but it all depends on the
242 design and capabilities of the simulator you use. Some, like
243 <A
244 HREF="http://sources.redhat.com/sid"
245 TARGET="_top"
246 >SID</A
247 > or
248 <A
249 HREF="http://bochs.sourceforge.net/"
250 TARGET="_top"
251 >Bochs</A
252 > provide
253 complete hardware emulation, while others just support enough of the
254 instruction set to run compiled code.</P
255 ><P
256 >Therefore, select a simulator or synthetic target and use
257 it for as long as possible for application development. That is,
258 configure for the selected target, build <SPAN
259 CLASS="PRODUCTNAME"
260 >eCos</SPAN
261 >, build the application
262 and link with <SPAN
263 CLASS="PRODUCTNAME"
264 >eCos</SPAN
265 >, run and debug. Repeat the latter two steps until
266 you are happy with it.</P
267 ><P
268 >Obviously, at some time you will have to switch to the intended
269 target hardware, for example when adding target specific feature
270 support, for memory footprint/performance characterization,
271 and for final tuning of <SPAN
272 CLASS="PRODUCTNAME"
273 >eCos</SPAN
274 > and the application.</P
275 ></DIV
276 ><DIV
277 CLASS="SECT2"
278 ><H2
279 CLASS="SECT2"
280 ><A
281 NAME="AEN511">Application Development - Target Specific Part</H2
282 ><P
283 >Repeat the build-run-debug-cycle while performing final tuning
284 and debugging of application. Remember to disable <SPAN
285 CLASS="PRODUCTNAME"
286 >eCos</SPAN
287 > assertion
288 checking if you are testing any performance-related aspects, it can
289 make a big difference.</P
290 ><P
291 >It may be useful to switch between this and the previous step
292 repeatedly through the development process; use the simulator/synthetic
293 target for actual development, and use the target hardware to continually
294 check memory footprint and performance. There should be little cost
295 in switching between the two targets when using two separate build
296 trees. </P
297 ></DIV
298 ></DIV
299 ></DIV
300 ><DIV
301 CLASS="NAVFOOTER"
302 ><HR
303 ALIGN="LEFT"
304 WIDTH="100%"><TABLE
305 SUMMARY="Footer navigation table"
306 WIDTH="100%"
307 BORDER="0"
308 CELLPADDING="0"
309 CELLSPACING="0"
310 ><TR
311 ><TD
312 WIDTH="33%"
313 ALIGN="left"
314 VALIGN="top"
315 ><A
316 HREF="user-guide-programming.html"
317 ACCESSKEY="P"
318 >Prev</A
319 ></TD
320 ><TD
321 WIDTH="34%"
322 ALIGN="center"
323 VALIGN="top"
324 ><A
325 HREF="ecos-user-guide.html"
326 ACCESSKEY="H"
327 >Home</A
328 ></TD
329 ><TD
330 WIDTH="33%"
331 ALIGN="right"
332 VALIGN="top"
333 ><A
334 HREF="configuring-and-building-ecos-from-source.html"
335 ACCESSKEY="N"
336 >Next</A
337 ></TD
338 ></TR
339 ><TR
340 ><TD
341 WIDTH="33%"
342 ALIGN="left"
343 VALIGN="top"
344 >Programming With <SPAN
345 CLASS="PRODUCTNAME"
346 >eCos</SPAN
347 ></TD
348 ><TD
349 WIDTH="34%"
350 ALIGN="center"
351 VALIGN="top"
352 ><A
353 HREF="user-guide-programming.html"
354 ACCESSKEY="U"
355 >Up</A
356 ></TD
357 ><TD
358 WIDTH="33%"
359 ALIGN="right"
360 VALIGN="top"
361 >Configuring and Building <SPAN
362 CLASS="PRODUCTNAME"
363 >eCos</SPAN
364 > from Source</TD
365 ></TR
366 ></TABLE
367 ></DIV
368 ></BODY
369 ></HTML
370 >