OpenCores

ECos

From OR1K

Contents

Introduction

eCos is a popular, open source, real-time operating system. It has been used in a wide variety of applications[1].

eCos is a highly configurable system. Using provided tools, it is possible to perform a detailed configuration of all packages and therefore fulfill different requirements. Using eCos HAL, it is also possible to build RedBoot, the popular bootstrap environment.

Status of the port

The port introduces a target called ORPSoC. This target refers to the ORPSoC project. It is also suitable for MinSoC, but some configuration options may need to be changed.

The current version of the port is tracking the mainline eCos repository. All changes have been rewritten against the code already checked in the official eCos repository.

The port is under constant development. It has been tested under or1ksim, version 0.5.1rc1, and under ordb2 hardware. The provided default configuration passes all eCos test cases.

Device Drivers

Following peripherals are supported:

Requirements

The OpenRISC GNU toolchain, built with newlib is required.

Getting eCos

Currently, eCos is hosted on OpenCores SVN:

 svn co http://opencores.org/ocsvn/openrisc/openrisc/trunk/rtos/ecos-3.0

Installing eCos

eCos uses two tools to build and configure the system: configtool and ecosconfig. ecosconfig is a handy command line program that allows to select the desired eCos target and packages. configtool is a windowed application that provides a clear and intuitive environment to adjust all of the possible configuration options.

There is a pre-built binary of configtool available:

 wget http://www.ecoscentric.com/snapshots/configtool-100305.bz2
 bunzip2 configtool-100305.bz2
 chmod u+x configtool-100305
 ln -s configtool-100305 /usr/local/bin/configtool

ecosconfig needs to be built from scratch. In order to build ecosconfig, go to the ecos-3.0 directory downloaded from SVN.

 ./host/configure

By default, ecosconfig installs itself in the /usr/local/ directory. If you like, you can change that directory to something else:

 ./host/configure --prefix=/desired_path

Finally build the tool

 make
 make install

Both ecosconfig and configtool require environmental variable ECOS_REPOSITORY. The variable must point to the packages directory, inside ecos-3.0 tree. To set the variable, go to the downloaded ecos-3.0 tree.

 ECOS_REPOSITORY=`pwd`/packages
 export ECOS_REPOSITORY

Configuring eCos for OpenRISC

Create a directory to build the eCos library. First start with the default template:

 ecosconfig new orpsoc

The default configuration fits ORPSoC port for ordb2 reference platform. It assumes that hardware multiplication and division are implemented. Floating point variables are handled by software. System clock runs at 50 MHz. If you are using MinSoC, or ORPSoC with different configuation, you need to alter the settings:

 configtool ecos.ecc

Configtool.png

After all modifications are done, save the changes to the ecc file. It is always a good idea to check for possible conflicts.

 ecosconfig check

Building eCos with tests

 ecosconfig tree
 make
 make tests  

Writing program with eCos

It is now possible to write programs linked with eCos. The most simple hello world program would look like this:

 #include <stdio.h>
 int main(void) {
   printf("Hello World\n");
   return 0;
 }

Refer to the eCos Reference Manual for additional information about kernel mechanisms and drivers.

To compile the program, use gcc with the following flags:

 or32-elf-gcc                         \
   -g                                 \
   -O2                                \
   -nostdlib                          \
   -Iecos_build/install/include       \
   -Lecos_build/install/lib           \
   -Tecos_build/install/lib/target.ld \
   *.c

Running eCos programs in or1ksim

Running programs in or1ksim is very easy.

 or32-elf-sim -f sim.cfg program_elf

sim.cfg is a simulator configuration. You can find the configuration that fits ordb2 board in the ORPSoC project tree.

Running eCos programs on ordb2 hardware

The most convenient way is to run the program using GDB debugger. First, start or_debug_proxy:

 or_debug_proxy -r 50001

Then, open the UART link:

 picocom -b 115200 /dev/ttyUSB1

Finally, upload the program via gdb:

 or32-elf-gdb program_elf
   target remote :50001
   load
   spr npc 0x100
   c

It is also possible to execute ecos tests. The following screen presents reslts of the timelice test.

Ecos timeslice.png

© copyright 1999-2012 OpenCores.org, equivalent to ORSoC AB, all rights reserved. OpenCores®, registered trademark.