1 |
27 |
unneback |
<!-- Copyright (C) 2002 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 |
|
|
>Overview</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 Synthetic Target"
|
20 |
|
|
HREF="hal-synth-arch.html"><LINK
|
21 |
|
|
REL="PREVIOUS"
|
22 |
|
|
TITLE="eCos Synthetic Target"
|
23 |
|
|
HREF="hal-synth-arch.html"><LINK
|
24 |
|
|
REL="NEXT"
|
25 |
|
|
TITLE="Installation"
|
26 |
|
|
HREF="synth-install.html"></HEAD
|
27 |
|
|
><BODY
|
28 |
|
|
CLASS="REFENTRY"
|
29 |
|
|
BGCOLOR="#FFFFFF"
|
30 |
|
|
TEXT="#000000"
|
31 |
|
|
LINK="#0000FF"
|
32 |
|
|
VLINK="#840084"
|
33 |
|
|
ALINK="#0000FF"
|
34 |
|
|
><DIV
|
35 |
|
|
CLASS="NAVHEADER"
|
36 |
|
|
><TABLE
|
37 |
|
|
SUMMARY="Header navigation table"
|
38 |
|
|
WIDTH="100%"
|
39 |
|
|
BORDER="0"
|
40 |
|
|
CELLPADDING="0"
|
41 |
|
|
CELLSPACING="0"
|
42 |
|
|
><TR
|
43 |
|
|
><TH
|
44 |
|
|
COLSPAN="3"
|
45 |
|
|
ALIGN="center"
|
46 |
|
|
>eCos Synthetic Target</TH
|
47 |
|
|
></TR
|
48 |
|
|
><TR
|
49 |
|
|
><TD
|
50 |
|
|
WIDTH="10%"
|
51 |
|
|
ALIGN="left"
|
52 |
|
|
VALIGN="bottom"
|
53 |
|
|
><A
|
54 |
|
|
HREF="hal-synth-arch.html"
|
55 |
|
|
ACCESSKEY="P"
|
56 |
|
|
>Prev</A
|
57 |
|
|
></TD
|
58 |
|
|
><TD
|
59 |
|
|
WIDTH="80%"
|
60 |
|
|
ALIGN="center"
|
61 |
|
|
VALIGN="bottom"
|
62 |
|
|
></TD
|
63 |
|
|
><TD
|
64 |
|
|
WIDTH="10%"
|
65 |
|
|
ALIGN="right"
|
66 |
|
|
VALIGN="bottom"
|
67 |
|
|
><A
|
68 |
|
|
HREF="synth-install.html"
|
69 |
|
|
ACCESSKEY="N"
|
70 |
|
|
>Next</A
|
71 |
|
|
></TD
|
72 |
|
|
></TR
|
73 |
|
|
></TABLE
|
74 |
|
|
><HR
|
75 |
|
|
ALIGN="LEFT"
|
76 |
|
|
WIDTH="100%"></DIV
|
77 |
|
|
><H1
|
78 |
|
|
><A
|
79 |
|
|
NAME="SYNTH">Overview</H1
|
80 |
|
|
><DIV
|
81 |
|
|
CLASS="REFNAMEDIV"
|
82 |
|
|
><A
|
83 |
|
|
NAME="AEN6"
|
84 |
|
|
></A
|
85 |
|
|
><H2
|
86 |
|
|
>Name</H2
|
87 |
|
|
>The eCos synthetic target -- Overview</DIV
|
88 |
|
|
><DIV
|
89 |
|
|
CLASS="REFSECT1"
|
90 |
|
|
><A
|
91 |
|
|
NAME="SYNTH-DESCRIPTION"
|
92 |
|
|
></A
|
93 |
|
|
><H2
|
94 |
|
|
>Description</H2
|
95 |
|
|
><P
|
96 |
|
|
>Usually eCos runs on either a custom piece of hardware, specially
|
97 |
|
|
designed to meet the needs of a specific application, or on a
|
98 |
|
|
development board of some sort that is available before the final
|
99 |
|
|
hardware. Such boards have a number of things in common:
|
100 |
|
|
</P
|
101 |
|
|
><P
|
102 |
|
|
></P
|
103 |
|
|
><OL
|
104 |
|
|
TYPE="1"
|
105 |
|
|
><LI
|
106 |
|
|
><P
|
107 |
|
|
>Obviously there has to be at least one processor to do the work. Often
|
108 |
|
|
this will be a 32-bit processor, but it can be smaller or larger.
|
109 |
|
|
Processor speed will vary widely, depending on the expected needs of
|
110 |
|
|
the application. However the exact processor being used tends not to
|
111 |
|
|
matter very much for most of the development process: the use of
|
112 |
|
|
languages such as C or C++ means that the compiler will handle those
|
113 |
|
|
details.
|
114 |
|
|
</P
|
115 |
|
|
></LI
|
116 |
|
|
><LI
|
117 |
|
|
><P
|
118 |
|
|
>There needs to be memory for code and for data. A typical system will
|
119 |
|
|
have two different types of memory. There will be some non-volatile
|
120 |
|
|
memory such as flash, EPROM or masked ROM. There will also be some
|
121 |
|
|
volatile memory such as DRAM or SRAM. Often the code for the final
|
122 |
|
|
application will reside in the non-volatile memory and all of the RAM
|
123 |
|
|
will be available for data. However updating non-volatile memory
|
124 |
|
|
requires a non-trivial amount of effort, so for much of the
|
125 |
|
|
development process it is more convenient to burn suitable firmware,
|
126 |
|
|
for example RedBoot, into the non-volatile memory and then use that to
|
127 |
|
|
load the application being debugged into RAM, alongside the
|
128 |
|
|
application data and a small area reserved for use by the firmware.
|
129 |
|
|
</P
|
130 |
|
|
></LI
|
131 |
|
|
><LI
|
132 |
|
|
><P
|
133 |
|
|
>The platform must provide certain mimimal I/O facilities. Most eCos
|
134 |
|
|
configurations require a clock signal of some sort. There must also be
|
135 |
|
|
some way of outputting diagnostics to the user, often but not always
|
136 |
|
|
via a serial port. Unless special debug hardware is being used, source
|
137 |
|
|
level debugging will require bidirectional communication between a
|
138 |
|
|
host machine and the target hardware, usually via a serial port or an
|
139 |
|
|
ethernet device.
|
140 |
|
|
</P
|
141 |
|
|
></LI
|
142 |
|
|
><LI
|
143 |
|
|
><P
|
144 |
|
|
>All the above is not actually very useful yet because there is no way
|
145 |
|
|
for the embedded device to interact with the rest of the world, except
|
146 |
|
|
by generating diagnostics. Therefore an embedded device will have
|
147 |
|
|
additional I/O hardware. This may be fairly standard hardware such as
|
148 |
|
|
an ethernet or USB interface, or special hardware designed
|
149 |
|
|
specifically for the intended application, or quite often some
|
150 |
|
|
combination. Standard hardware such as ethernet or USB may be
|
151 |
|
|
supported by eCos device drivers and protocol stacks, whereas the
|
152 |
|
|
special hardware will be driven directly by application code.
|
153 |
|
|
</P
|
154 |
|
|
></LI
|
155 |
|
|
></OL
|
156 |
|
|
><P
|
157 |
|
|
>Much of the above can be emulated on a typical PC running Linux.
|
158 |
|
|
Instead of running the embedded application being developed on a
|
159 |
|
|
target board of some sort, it can be run as a Linux process. The
|
160 |
|
|
processor will be the PC's own processor, for example an x86, and the
|
161 |
|
|
memory will be the process' address space. Some I/O facilities can be
|
162 |
|
|
emulated directly through system calls. For example clock hardware can
|
163 |
|
|
be emulated by setting up a <TT
|
164 |
|
|
CLASS="LITERAL"
|
165 |
|
|
>SIGALRM</TT
|
166 |
|
|
> signal, which
|
167 |
|
|
will cause the process to be interrupted at regular intervals. This
|
168 |
|
|
emulation of real hardware will not be particularly accurate, the
|
169 |
|
|
number of cpu cycles available to the eCos application between clock
|
170 |
|
|
ticks will vary widely depending on what else is running on the PC,
|
171 |
|
|
but for much development work it will be good enough.
|
172 |
|
|
</P
|
173 |
|
|
><P
|
174 |
|
|
>Other I/O facilities are provided through an I/O auxiliary process,
|
175 |
|
|
ecosynth, that gets spawned by the eCos application during startup.
|
176 |
|
|
When an eCos device driver wants to perform some I/O operation, for
|
177 |
|
|
example send out an ethernet packet, it sends a request to the I/O
|
178 |
|
|
auxiliary. That is an ordinary Linux application so it has ready
|
179 |
|
|
access to all normal Linux I/O facilities. To emulate a device
|
180 |
|
|
interrupt the I/O auxiliary can raise a <TT
|
181 |
|
|
CLASS="LITERAL"
|
182 |
|
|
>SIGIO</TT
|
183 |
|
|
>
|
184 |
|
|
signal within the eCos application. The HAL's interrupt subsystem
|
185 |
|
|
installs a signal handler for this, which will then invoke the
|
186 |
|
|
standard eCos ISR/DSR mechanisms. The I/O auxiliary is based around
|
187 |
|
|
Tcl scripting, making it easy to extend and customize. It should be
|
188 |
|
|
possible to configure the synthetic target so that its I/O
|
189 |
|
|
functionality is similar to what will be available on the final target
|
190 |
|
|
hardware for the application being developed.
|
191 |
|
|
</P
|
192 |
|
|
><DIV
|
193 |
|
|
CLASS="INFORMALFIGURE"
|
194 |
|
|
><A
|
195 |
|
|
NAME="AEN25"><P
|
196 |
|
|
></P
|
197 |
|
|
><DIV
|
198 |
|
|
CLASS="MEDIAOBJECT"
|
199 |
|
|
><P
|
200 |
|
|
><IMG
|
201 |
|
|
SRC="overview.gif"
|
202 |
|
|
ALIGN="CENTER"></P
|
203 |
|
|
></DIV
|
204 |
|
|
><P
|
205 |
|
|
></P
|
206 |
|
|
></DIV
|
207 |
|
|
><P
|
208 |
|
|
>A key requirement for synthetic target code is that the embedded
|
209 |
|
|
application must not be linked with any of the standard Linux
|
210 |
|
|
libraries such as the GNU C library: that would lead to a confusing
|
211 |
|
|
situation where both eCos and the Linux libraries attempted to provide
|
212 |
|
|
functions such as <TT
|
213 |
|
|
CLASS="FUNCTION"
|
214 |
|
|
>printf</TT
|
215 |
|
|
>. Instead the synthetic
|
216 |
|
|
target support must be implemented directly on top of the Linux
|
217 |
|
|
kernels' system call interface. For example, the kernel provides a
|
218 |
|
|
system call for write operations. The actual function
|
219 |
|
|
<TT
|
220 |
|
|
CLASS="FUNCTION"
|
221 |
|
|
>write</TT
|
222 |
|
|
> is implemented in the system's C library,
|
223 |
|
|
but all it does is move its arguments on to the stack or into certain
|
224 |
|
|
registers and then execute a special trap instruction such as
|
225 |
|
|
<TT
|
226 |
|
|
CLASS="LITERAL"
|
227 |
|
|
>int 0x80</TT
|
228 |
|
|
>. When this instruction is executed
|
229 |
|
|
control transfers into the kernel, which will validate the arguments
|
230 |
|
|
and perform the appropriate operation. Now, a synthetic target
|
231 |
|
|
application cannot be linked with the system's C library. Instead it
|
232 |
|
|
contains a function <TT
|
233 |
|
|
CLASS="FUNCTION"
|
234 |
|
|
>cyg_hal_sys_write</TT
|
235 |
|
|
> which, like
|
236 |
|
|
the C library's <TT
|
237 |
|
|
CLASS="FUNCTION"
|
238 |
|
|
>write</TT
|
239 |
|
|
> function, pushes its
|
240 |
|
|
arguments on to the stack and executes the trap instruction. The Linux
|
241 |
|
|
kernel cannot tell the difference, so it will perform the I/O
|
242 |
|
|
operation requested by the synthetic target. With appropriate
|
243 |
|
|
knowledge of what system calls are available, this makes it possible
|
244 |
|
|
to emulate the required I/O facilities. For example, spawning the
|
245 |
|
|
ecosynth I/O auxiliary involves system calls
|
246 |
|
|
<TT
|
247 |
|
|
CLASS="FUNCTION"
|
248 |
|
|
>cyg_hal_sys_fork</TT
|
249 |
|
|
> and
|
250 |
|
|
<TT
|
251 |
|
|
CLASS="FUNCTION"
|
252 |
|
|
>cyg_hal_sys_execve</TT
|
253 |
|
|
>, and sending a request to the
|
254 |
|
|
auxiliary uses <TT
|
255 |
|
|
CLASS="FUNCTION"
|
256 |
|
|
>cyg_hal_sys_write</TT
|
257 |
|
|
>.
|
258 |
|
|
</P
|
259 |
|
|
><P
|
260 |
|
|
>In many ways developing for the synthetic target is no different from
|
261 |
|
|
developing for real embedded targets. eCos must be configured
|
262 |
|
|
appropriately: selecting a suitable target such as
|
263 |
|
|
<TT
|
264 |
|
|
CLASS="USERINPUT"
|
265 |
|
|
><B
|
266 |
|
|
>i386linux</B
|
267 |
|
|
></TT
|
268 |
|
|
> will cause the configuration system
|
269 |
|
|
to load the appropriate packages for this hardware; this includes an
|
270 |
|
|
architectural HAL package and a platform-specific package; the
|
271 |
|
|
architectural package contains generic code applicable to all Linux
|
272 |
|
|
platforms, whereas the platform package is for specific Linux
|
273 |
|
|
implementations such as the x86 version and contains any
|
274 |
|
|
processor-specific code. Selecting this target will also bring in some
|
275 |
|
|
device driver packages. Other aspects of the configuration such as
|
276 |
|
|
which API's are supported are determined by the template, by adding
|
277 |
|
|
and removing packages, and by fine-grained configuration.
|
278 |
|
|
</P
|
279 |
|
|
><P
|
280 |
|
|
>In other ways developing for the synthetic target can be much easier
|
281 |
|
|
than developing for a real embedded target. For example there is no
|
282 |
|
|
need to worry about building and installing suitable firmware on the
|
283 |
|
|
target hardware, and then downloading and debugging the actual
|
284 |
|
|
application over a serial line or a similar connection. Instead an
|
285 |
|
|
eCos application built for the synthetic target is mostly
|
286 |
|
|
indistinguishable from an ordinary Linux program. It can be run simply
|
287 |
|
|
by typing the name of the executable file at a shell prompt.
|
288 |
|
|
Alternatively you can debug the application using whichever version of
|
289 |
|
|
gdb is provided by your Linux distribution. There is no need to build
|
290 |
|
|
or install special toolchains. Essentially using the synthetic target
|
291 |
|
|
means that the various problems associated with real embedded hardware
|
292 |
|
|
can be bypassed for much of the development process.
|
293 |
|
|
</P
|
294 |
|
|
><P
|
295 |
|
|
>The eCos synthetic target provides emulation, not simulation. It is
|
296 |
|
|
possible to run eCos in suitable architectural simulators but that
|
297 |
|
|
involves a rather different approach to software development. For
|
298 |
|
|
example, when running eCos on the psim PowerPC simulator you need
|
299 |
|
|
appropriate cross-compilation tools that allow you to build PowerPC
|
300 |
|
|
executables. These are then loaded into the simulator which interprets
|
301 |
|
|
every instruction and attempts to simulate what would happen if the
|
302 |
|
|
application were running on real hardware. This involves a lot of
|
303 |
|
|
processing overhead, but depending on the functionality provided by
|
304 |
|
|
the simulator it can give very accurate results. When developing for
|
305 |
|
|
the synthetic target the executable is compiled for the PC's own
|
306 |
|
|
processor and will be executed at full speed, with no need for a
|
307 |
|
|
simulator or special tools. This will be much faster and somewhat
|
308 |
|
|
simpler than using an architectural simulator, but no attempt is made
|
309 |
|
|
to accurately match the behaviour of a real embedded target.
|
310 |
|
|
</P
|
311 |
|
|
></DIV
|
312 |
|
|
><DIV
|
313 |
|
|
CLASS="NAVFOOTER"
|
314 |
|
|
><HR
|
315 |
|
|
ALIGN="LEFT"
|
316 |
|
|
WIDTH="100%"><TABLE
|
317 |
|
|
SUMMARY="Footer navigation table"
|
318 |
|
|
WIDTH="100%"
|
319 |
|
|
BORDER="0"
|
320 |
|
|
CELLPADDING="0"
|
321 |
|
|
CELLSPACING="0"
|
322 |
|
|
><TR
|
323 |
|
|
><TD
|
324 |
|
|
WIDTH="33%"
|
325 |
|
|
ALIGN="left"
|
326 |
|
|
VALIGN="top"
|
327 |
|
|
><A
|
328 |
|
|
HREF="hal-synth-arch.html"
|
329 |
|
|
ACCESSKEY="P"
|
330 |
|
|
>Prev</A
|
331 |
|
|
></TD
|
332 |
|
|
><TD
|
333 |
|
|
WIDTH="34%"
|
334 |
|
|
ALIGN="center"
|
335 |
|
|
VALIGN="top"
|
336 |
|
|
><A
|
337 |
|
|
HREF="hal-synth-arch.html"
|
338 |
|
|
ACCESSKEY="H"
|
339 |
|
|
>Home</A
|
340 |
|
|
></TD
|
341 |
|
|
><TD
|
342 |
|
|
WIDTH="33%"
|
343 |
|
|
ALIGN="right"
|
344 |
|
|
VALIGN="top"
|
345 |
|
|
><A
|
346 |
|
|
HREF="synth-install.html"
|
347 |
|
|
ACCESSKEY="N"
|
348 |
|
|
>Next</A
|
349 |
|
|
></TD
|
350 |
|
|
></TR
|
351 |
|
|
><TR
|
352 |
|
|
><TD
|
353 |
|
|
WIDTH="33%"
|
354 |
|
|
ALIGN="left"
|
355 |
|
|
VALIGN="top"
|
356 |
|
|
>eCos Synthetic Target</TD
|
357 |
|
|
><TD
|
358 |
|
|
WIDTH="34%"
|
359 |
|
|
ALIGN="center"
|
360 |
|
|
VALIGN="top"
|
361 |
|
|
> </TD
|
362 |
|
|
><TD
|
363 |
|
|
WIDTH="33%"
|
364 |
|
|
ALIGN="right"
|
365 |
|
|
VALIGN="top"
|
366 |
|
|
>Installation</TD
|
367 |
|
|
></TR
|
368 |
|
|
></TABLE
|
369 |
|
|
></DIV
|
370 |
|
|
></BODY
|
371 |
|
|
></HTML
|
372 |
|
|
>
|