📄 synth.sgml
字号:
<!-- DOCTYPE part PUBLIC "-//OASIS//DTD DocBook V3.1//EN" --><!-- {{{ Banner --><!-- =============================================================== --><!-- --><!-- synth.sgml --><!-- --><!-- Synthetic target architectural documentation. --><!-- --><!-- =============================================================== --><!-- ####COPYRIGHTBEGIN#### --><!-- --><!-- =============================================================== --><!-- Copyright (C) 2002 Bart Veer. --><!-- Copyright (C) 2002 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/) --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission obtained from the copyright holder --><!-- =============================================================== --><!-- --> <!-- ####COPYRIGHTEND#### --><!-- =============================================================== --><!-- =============================================================== --><!-- #####DESCRIPTIONBEGIN#### --><!-- --><!-- Author(s): bartv --><!-- Contact(s): bartv --><!-- Date: 2002/02/24 --><!-- Version: 0.01 --><!-- --><!-- ####DESCRIPTIONEND#### --><!-- =============================================================== --><!-- }}} --><part id="hal-synth-arch"><title>eCos Synthetic Target</title><!-- {{{ Overview --><refentry id="synth"> <refmeta> <refentrytitle>Overview</refentrytitle> </refmeta> <refnamediv> <refname>The eCos synthetic target</refname> <refpurpose>Overview</refpurpose> </refnamediv> <refsect1 id="synth-description"><title>Description</title> <para>Usually eCos runs on either a custom piece of hardware, speciallydesigned to meet the needs of a specific application, or on adevelopment board of some sort that is available before the finalhardware. Such boards have a number of things in common: </para> <orderedlist> <listitem><para>Obviously there has to be at least one processor to do the work. Oftenthis will be a 32-bit processor, but it can be smaller or larger.Processor speed will vary widely, depending on the expected needs ofthe application. However the exact processor being used tends not tomatter very much for most of the development process: the use oflanguages such as C or C++ means that the compiler will handle thosedetails. </para></listitem> <listitem><para>There needs to be memory for code and for data. A typical system willhave two different types of memory. There will be some non-volatilememory such as flash, EPROM or masked ROM. There will also be somevolatile memory such as DRAM or SRAM. Often the code for the finalapplication will reside in the non-volatile memory and all of the RAMwill be available for data. However updating non-volatile memoryrequires a non-trivial amount of effort, so for much of thedevelopment process it is more convenient to burn suitable firmware,for example RedBoot, into the non-volatile memory and then use that toload the application being debugged into RAM, alongside theapplication data and a small area reserved for use by the firmware. </para></listitem> <listitem><para>The platform must provide certain mimimal I/O facilities. Most eCosconfigurations require a clock signal of some sort. There must also besome way of outputting diagnostics to the user, often but not always via a serial port. Unless special debug hardware is being used, sourcelevel debugging will require bidirectional communication between ahost machine and the target hardware, usually via a serial port or anethernet device. </para></listitem> <listitem><para>All the above is not actually very useful yet because there is no wayfor the embedded device to interact with the rest of the world, exceptby generating diagnostics. Therefore an embedded device will haveadditional I/O hardware. This may be fairly standard hardware such asan ethernet or USB interface, or special hardware designedspecifically for the intended application, or quite often somecombination. Standard hardware such as ethernet or USB may besupported by eCos device drivers and protocol stacks, whereas thespecial hardware will be driven directly by application code. </para></listitem> </orderedlist> <para>Much of the above can be emulated on a typical PC running Linux.Instead of running the embedded application being developed on atarget board of some sort, it can be run as a Linux process. Theprocessor will be the PC's own processor, for example an x86, and thememory will be the process' address space. Some I/O facilities can beemulated directly through system calls. For example clock hardware canbe emulated by setting up a <literal>SIGALRM</literal> signal, whichwill cause the process to be interrupted at regular intervals. Thisemulation of real hardware will not be particularly accurate, thenumber of cpu cycles available to the eCos application between clockticks will vary widely depending on what else is running on the PC,but for much development work it will be good enough. </para> <para>Other I/O facilities are provided through an I/O auxiliary process,ecosynth, that gets spawned by the eCos application during startup.When an eCos device driver wants to perform some I/O operation, forexample send out an ethernet packet, it sends a request to the I/Oauxiliary. That is an ordinary Linux application so it has readyaccess to all normal Linux I/O facilities. To emulate a deviceinterrupt the I/O auxiliary can raise a <literal>SIGIO</literal>signal within the eCos application. The HAL's interrupt subsysteminstalls a signal handler for this, which will then invoke thestandard eCos ISR/DSR mechanisms. The I/O auxiliary is based aroundTcl scripting, making it easy to extend and customize. It should bepossible to configure the synthetic target so that its I/Ofunctionality is similar to what will be available on the final targethardware for the application being developed. </para> <informalfigure PgWide=1> <mediaobject> <imageobject> <imagedata fileref="synth-io-overview.png" Scalefit=1 Align="Center"> </imageobject> </mediaobject> </informalfigure> <para>A key requirement for synthetic target code is that the embeddedapplication must not be linked with any of the standard Linuxlibraries such as the GNU C library: that would lead to a confusingsituation where both eCos and the Linux libraries attempted to providefunctions such as <function>printf</function>. Instead the synthetictarget support must be implemented directly on top of the Linuxkernels' system call interface. For example, the kernel provides asystem call for write operations. The actual function<function>write</function> is implemented in the system's C library,but all it does is move its arguments on to the stack or into certainregisters and then execute a special trap instruction such as<literal>int 0x80</literal>. When this instruction is executedcontrol transfers into the kernel, which will validate the argumentsand perform the appropriate operation. Now, a synthetic targetapplication cannot be linked with the system's C library. Instead itcontains a function <function>cyg_hal_sys_write</function> which, likethe C library's <function>write</function> function, pushes itsarguments on to the stack and executes the trap instruction. The Linuxkernel cannot tell the difference, so it will perform the I/Ooperation requested by the synthetic target. With appropriateknowledge of what system calls are available, this makes it possibleto emulate the required I/O facilities. For example, spawning theecosynth I/O auxiliary involves system calls<function>cyg_hal_sys_fork</function> and<function>cyg_hal_sys_execve</function>, and sending a request to theauxiliary uses <function>cyg_hal_sys_write</function>. </para> <para>In many ways developing for the synthetic target is no different fromdeveloping for real embedded targets. eCos must be configuredappropriately: selecting a suitable target such as<userinput>i386linux</userinput> will cause the configuration systemto load the appropriate packages for this hardware; this includes anarchitectural HAL package and a platform-specific package; thearchitectural package contains generic code applicable to all Linuxplatforms, whereas the platform package is for specific Linuximplementations such as the x86 version and contains anyprocessor-specific code. Selecting this target will also bring in somedevice driver packages. Other aspects of the configuration such aswhich API's are supported are determined by the template, by addingand removing packages, and by fine-grained configuration. </para> <para>In other ways developing for the synthetic target can be much easierthan developing for a real embedded target. For example there is noneed to worry about building and installing suitable firmware on thetarget hardware, and then downloading and debugging the actualapplication over a serial line or a similar connection. Instead aneCos application built for the synthetic target is mostlyindistinguishable from an ordinary Linux program. It can be run simplyby typing the name of the executable file at a shell prompt.Alternatively you can debug the application using whichever version ofgdb is provided by your Linux distribution. There is no need to buildor install special toolchains. Essentially using the synthetic targetmeans that the various problems associated with real embedded hardwarecan be bypassed for much of the development process. </para> <para>The eCos synthetic target provides emulation, not simulation. It ispossible to run eCos in suitable architectural simulators but thatinvolves a rather different approach to software development. Forexample, when running eCos on the psim PowerPC simulator you needappropriate cross-compilation tools that allow you to build PowerPCexecutables. These are then loaded into the simulator which interpretsevery instruction and attempts to simulate what would happen if theapplication were running on real hardware. This involves a lot ofprocessing overhead, but depending on the functionality provided bythe simulator it can give very accurate results. When developing forthe synthetic target the executable is compiled for the PC's ownprocessor and will be executed at full speed, with no need for asimulator or special tools. This will be much faster and somewhatsimpler than using an architectural simulator, but no attempt is madeto accurately match the behaviour of a real embedded target. </para> </refsect1></refentry><!-- }}} --><!-- {{{ Installation --><refentry id="synth-install"> <refmeta> <refentrytitle>Installation</refentrytitle> </refmeta> <refnamediv> <refname>Installation</refname> <refpurpose>Preparing to use the synthetic target</refpurpose> </refnamediv> <refsect1 id="synth-install-host"><title>Host-side Software</title> <para>To get the full functionality of the synthetic target, users mustbuild and install the I/O auxiliary ecosynth and various supportfiles. It is possible to develop applications for the synthetic targetwithout the auxiliary, but only limited I/O facilities will beavailable. The relevant code resides in the <filenameclass="directory">host</filename> subdirectory of the synthetic targetarchitectural HAL package, and building it involves the standard<command>configure</command>, <command>make</command>, and<command>make install</command> steps. </para> <para>There are two main ways of building the host-side software. It ispossible to build both the generic host-side software and allpackage-specific host-side software, including the I/O auxiliary. in asingle build tree. This involves using the<command>configure</command> script at the toplevel of the eCosrepository, which will automatically search the <filenameclass="directory">packages</filename> hierarchy for host-sidesoftware. For more information on this, see the<filename>README.host</filename> file at the top of the repository.Note that if you have an existing build tree which does not includethe synthetic target architectural HAL package then it will benecessary to rerun the toplevel configure script: the search forappropriate packages happens at configure time. </para> <para>The alternative is to build just the host-side for this package.This involves creating a suitable build directory and running the<command>configure</command> script. Note that building directly inthe source tree is not allowed. </para> <screen>$ cd <somewhere suitable>$ mkdir synth_build$ cd synth_build$ <repo<>/packages/hal/synth/arch/<version>/host/configure <options>$ make$ make install</screen> <para>The code makes extensive use of Tcl/TK and requires version 8.3 orlater. This is checked by the <command>configure</command> script. Bydefault it will use the system's Tcl installation in <filenameclass="directory">/usr</filename>. If a different, more recent Tclinstallation should be used then its location can be specified usingthe options <option>--with-tcl=<path></option>,<option>--with-tcl-header=<path></option> and<option>--with-tcl-lib=<path></option>. For more information on these optionssee the <filename>README.host</filename> file at the toplevel of theeCos repository. </para> <para>Some users may also want to specify the install location using a<option>--prefix=<path></option> option. The default installlocation is <filename class="directory">/usr/local</filename>. It isessential that the <filename class="directory">bin</filename>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -