OpenRISC Ethernet driver for eCos RTOS
We have been maintaining the eCos real-time OS for openRISC for some time now, but what has been an obstacle to use it in a wider array of applications was the lack of suitable driver support enabling the construction of a platform featuring a richer set of interfaces.
In a series of posts, we have decided to amend this situation by writing, contributing and showing how to use drivers for some essential peripherals for ORPSoC.
The first peripheral we are going to work with is Ethernet.
The driver for the Ethernet controller will be automatically added to the eCos build if we select any network stack. We can pick from the following:
– TCP/IP stack from OpenBSD
– TCP/IP stack from FreeBSD (including KAME IPv6)
– Lightweight TCP/IP stack: lwIP (note: originally created by Adam Dunkels at the Center for Networked Systems at SICS, with whom we cooperate)
For example, in order to build eCos with the FreeBSD stack, the following steps have to be taken:
ecosconfig new orpsoc default ecosconfig add CYGPKG_NET ecosconfig add CYGPKG_NET_FREEBSD_STACK ecosconfig add CYGPKG_IO_FILEIO ecosconfig add CYGPKG_IO_ETH_DRIVERS
Before we proceed to compilation, we need to do some additional configuration of the driver and the network stack. The most important configuration options are of course the MAC address of the Ethernet controller itself as well as the IP address (either static or dynamically allocated via DHCP) of the device. The configuration can be done in two ways: either using the GUI program, configtool, or via editing ecos.ecc.
When we are done, we should issue:
ecosconfig tree make
which results in a compiled eCos with Ethernet and TCP/IP support. The nice thing is that the network services API in eCos is POSIX-compliant, so the networking programs look and work just like Linux ones. It is best to look at some examples, residing in the packages/net/common/current/tests/ directory – especially ping_test.c and server_test.c are worth noting.
Note: the code described in this post is available here.