Comtrol eCos User Manual

Page 748

Advertising
background image

Overview

standard eCos ISR/DSR mechanisms. The I/O auxiliary is based around Tcl scripting, making it easy to extend and
customize. It should be possible to configure the synthetic target so that its I/O functionality is similar to what will
be available on the final target hardware for the application being developed.

A key requirement for synthetic target code is that the embedded application must not be linked with any of the
standard Linux libraries such as the GNU C library: that would lead to a confusing situation where both eCos and
the Linux libraries attempted to provide functions such as

printf

. Instead the synthetic target support must be

implemented directly on top of the Linux kernels’ system call interface. For example, the kernel provides a system
call for write operations. The actual function

write

is implemented in the system’s C library, but all it does is move

its arguments on to the stack or into certain registers and then execute a special trap instruction such as

int 0x80

.

When this instruction is executed control transfers into the kernel, which will validate the arguments and perform
the appropriate operation. Now, a synthetic target application cannot be linked with the system’s C library. Instead
it contains a function

cyg_hal_sys_write

which, like the C library’s

write

function, pushes its arguments on

to the stack and executes the trap instruction. The Linux kernel cannot tell the difference, so it will perform the
I/O operation requested by the synthetic target. With appropriate knowledge of what system calls are available,
this makes it possible to emulate the required I/O facilities. For example, spawning the ecosynth I/O auxiliary
involves system calls

cyg_hal_sys_fork

and

cyg_hal_sys_execve

, and sending a request to the auxiliary uses

cyg_hal_sys_write

.

In many ways developing for the synthetic target is no different from developing for real embedded targets. eCos
must be configured appropriately: selecting a suitable target such as

i386linux

will cause the configuration sys-

tem to load the appropriate packages for this hardware; this includes an architectural HAL package and a platform-
specific package; the architectural package contains generic code applicable to all Linux platforms, whereas the
platform package is for specific Linux implementations such as the x86 version and contains any processor-specific
code. Selecting this target will also bring in some device driver packages. Other aspects of the configuration such as
which API’s are supported are determined by the template, by adding and removing packages, and by fine-grained
configuration.

In other ways developing for the synthetic target can be much easier than developing for a real embedded target.
For example there is no need to worry about building and installing suitable firmware on the target hardware, and
then downloading and debugging the actual application over a serial line or a similar connection. Instead an eCos
application built for the synthetic target is mostly indistinguishable from an ordinary Linux program. It can be run
simply by typing the name of the executable file at a shell prompt. Alternatively you can debug the application
using whichever version of gdb is provided by your Linux distribution. There is no need to build or install special
toolchains. Essentially using the synthetic target means that the various problems associated with real embedded
hardware can be bypassed for much of the development process.

The eCos synthetic target provides emulation, not simulation. It is possible to run eCos in suitable architectural
simulators but that involves a rather different approach to software development. For example, when running eCos
on the psim PowerPC simulator you need appropriate cross-compilation tools that allow you to build PowerPC
executables. These are then loaded into the simulator which interprets every instruction and attempts to simulate
what would happen if the application were running on real hardware. This involves a lot of processing overhead,
but depending on the functionality provided by the simulator it can give very accurate results. When developing for
the synthetic target the executable is compiled for the PC’s own processor and will be executed at full speed, with

644

Advertising