Chapter 6. Programming With eCos
Table of Contents
The following chapters of this manual comprise a simple tutorial for configuring and building eCos, building and running eCos tests, and finally building three stand-alone example programs which use the eCos API to perform some simple tasks.
You will need a properly installed eCos system, with the correct versions of the GNU toolchain, Host Tools and Eclipse. The eCosPro installer will perform all of the necessary configuration during installation for you to allow you to build and run applications on the hardware supported by the eCosPro Developer's Kit out-of-the-box.
Alternatively, you can also integrate a command line environment with whatever editor and revision control system you are familiar with. For the command line environment, on Linux this will typically be a command shell through a console or terminal window. On Windows you can use either the Command Prompt (CMD.exe) or the bash command line interpreter provided with your eCosPro installation, with the environment variables set as described in Section 11.2, “Environment Variables” and the chapter Environment Variables in the eCosPro Developer's Kit - Installation and Getting Started Guide.
6.1. The Development Process
Most development projects using eCos would contain some (or most) of the following:
6.1.1. eCos Configuration
eCos is configured to provide the desired API (the inclusion of libc, uitron, and the disabling of certain undesired funtions, etc.), and semantics (selecting scheduler, mutex behavior, etc.). See Chapter 7, Configuring and Building eCos from Source.
It would normally make sense to enable eCos assertion checking at this time as well, to catch as many programming errors during the development phase as possible.
Note that it should not be necessary to spend much time on eCos configuration initially. It may be important to perform fine tuning to reduce the memory footprint and to improve performance later when the product reaches a testable state.
6.1.2. Integrity check of the eCos configuration
While we strive to thoroughly test eCos, the vast number of configuration permutations mean that the particular configuration parameters used for your project may not have been tested. Therefore, we advise running the eCos tests after the project's eCos configuration has been determined. See Chapter 8, Running an eCos Test Case.
Obviously, this should be repeated if the configuration changes later on in the development process.
6.1.3. Application Development - Target Neutral Part
While your project is probably targeting a specific architecture and platform, possibly custom hardware, it may be possible to perform part of the application development using simulated or synthetic targets.
There are three good reasons for doing this:
It may be possible by this means to perform application development in parallel with the design/implementation of the target hardware, thus providing more time for developing and testing functionality, and reducing time-to-market.
The build-run-debug-cycle may be faster when the application does not have to be downloaded to a target via a serial interface. Debugging is also likely to be more responsive when you do not have to to communicate with the remote GDB stubs in RedBoot via serial. It also removes the need for manually or automatically resetting the target hardware.
New hardware can often be buggy. Comparing the behaviour of the program on the hardware and in the simulator or synthetic target may allow you to identify where the problems lie.
This approach is possible because all targets (including simulators and synthetic ones) provide the same basic API: that is, kernel, libc, libm, uitron, infra, and to some extent, HAL and IO.
Synthetic targets are especially suitable as they allow you to construct simulations of elaborate devices by interaction with the host system, where an IO device API can hide the details from the application. When switching to hardware later in the development cycle, the IO driver is properly implemented.
Simulators can also do this, but it all depends on the design and capabilities of the simulator you use. Some like Bochs provide complete hardware emulation, while others just support enough of the instruction set to run compiled code.
Therefore, select a simulator or synthetic target and use it for as long as possible for application development. That is, configure for the selected target, build eCos, build the application and link with eCos, run and debug. Repeat the latter two steps until you are happy with it.
Obviously, at some time you will have to switch to the intended target hardware, for example when adding target specific feature support, for memory footprint/performance characterization, and for final tuning of eCos and the application.
6.1.4. Application Development - Target Specific Part
Repeat the build-run-debug-cycle while performing final tuning and
debugging of application. Remember to disable
eCos assertion checking if you are testing
any performance-related aspects, and to enable compiler optimization
-O2) it can make a big difference.
It may be useful to switch between this and the previous step repeatedly through the development process; use the simulator/synthetic target for actual development, and use the target hardware to continually check memory footprint and performance. There should be little cost in switching between the two targets when using two separate build trees.
|2019-06-13||Open Publication License|