1 <!-- 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. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Synthetic Target"
20 HREF="hal-synth-arch.html"><LINK
22 TITLE="eCos Synthetic Target"
23 HREF="hal-synth-arch.html"><LINK
26 HREF="synth-install.html"></HEAD
37 SUMMARY="Header navigation table"
46 >eCos Synthetic Target</TH
54 HREF="hal-synth-arch.html"
68 HREF="synth-install.html"
79 NAME="SYNTH">Overview</H1
87 >The eCos synthetic target -- Overview</DIV
91 NAME="SYNTH-DESCRIPTION"
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:
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
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.
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
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.
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
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.
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
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.
193 CLASS="INFORMALFIGURE"
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
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
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
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
234 >cyg_hal_sys_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
248 >cyg_hal_sys_fork</TT
252 >cyg_hal_sys_execve</TT
253 >, and sending a request to the
256 >cyg_hal_sys_write</TT
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
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.
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.
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.
317 SUMMARY="Footer navigation table"
328 HREF="hal-synth-arch.html"
337 HREF="hal-synth-arch.html"
346 HREF="synth-install.html"
356 >eCos Synthetic Target</TD