To build an eCos application, you must link the application with the eCos library. This appendix describes how to build a new eCos library for linking with application code.
A prebuilt eCos library is already included in the book’s compressed file, but you may need to know the eCos library build procedure if you move to a new development board or require additional functionality in the eCos library.
The eCos examples, covered in Chapter 11, are built in the same manner as the other examples in the book. The build procedure is covered in Chapter 4, and the download-and-debug procedure in Chapter 5. The eCos examples are built using the GNU tools set up in Appendix B, along with the prebuilt eCos library.
Additional details about building eCos applications can be found in the book Embedded Software Development with eCos, by Anthony Massa (Prentice Hall PTR).
Enter the following commands in a Cygwin bash shell under Windows or in a terminal window under Linux. The instructions extract the eCos source code to the /opt/ecos directory. Other directories can be used, but the instructions need to be adjusted accordingly.
Using Linux, you will need permission to become superuser (root) to perform the setup successfully.
The eCos source code is contained in the file ecos.tar.gz. If you use a different version of the eCos source code, change the following instructions accordingly:
Make a directory where the eCos source code is extracted, with the following command:
mkdir –p /opt/ecos#
Copy the eCos source file ecos.tar.gz to the /opt/ecos directory.
Extract the eCos source code files using the following:
tar xvzf ecos.tar.gz
The directory that contains the eCos source code should now be available under /opt/ecos/ecos-redboot-viper-v3i7.
Set up the environment variables. Edit the $HOME/.bash_profile file (where $HOME is specific to your environment) and add the following lines:
PATH=/opt/ecos/ecos-redboot-viper-v3i7/tools:$PATH ; export PATH
ECOS_REPOSITORY=/opt/ecos/ecos-redboot-viper-v3i7/packages ; export ECOS_REPOSITORY
Close the current bash environment and open a new one. This allows the changes just made to the environment to become effective.
For this build procedure, we use the eCos command-line configuration tool ecosconfig, which is included under the /opt/ecos/ecos-redboot-viper-v3i7/tools directory. Therefore, these commands are also executed either at a Cygwin bash shell prompt on Windows platforms or on a command line on Linux. There is also a graphical configuration tool that could be used to accomplish the same outcome.
The resulting eCos files are located under the /opt/ProgEmbSys/chapter11/ecos directory. If you have installed the book’s source code, there should already be an eCos library present at this location. You need to rename or move the existing eCos library directory before proceeding.
Make a directory where the eCos files are going to be built, using the following commands:
mkdir –p /opt/ProgEmbSys/chapter11/ecos#
Create a new configuration for the Arcom board using the
default template by
entering the following command:
ecosconfig new arcom-viper default
Create the eCos build tree using the command:
Finally, build the eCos library by entering the command:
If you encounter an error, make sure the path is set up correctly, as previously shown. After successfully building an eCos library, you should see the following message:
You should have various directories under /opt/ProgEmbSys/chapter11/ecos, including the directory install/lib. The lib directory contains the eCos operating system archive files that get linked with eCos applications.
The eCos makefiles contain a variable,
ECOS_INSTALL_DIR, which is set to the
location of the eCos install directory—/opt/ProgEmbSys/chapter11/ecos/install in
this case. If the eCos install directory location changes, this
variable must also be changed.