Universal Device Driver Framework for Embedded Systems

Recently I’ve been considering how useful it would be if the embedded systems world had something similar to Perl’s CPAN: an open repository of software modules useful for embedded systems and portable across any RTOS. This was partly triggered by a thread on StackOverflow from someone who wanted to know why he couldn’t find a ready-rolled device driver to interface his CPU with a peripheral device.

Here are some excerpts from the thread:

…it just seems like there are hundreds or thousands of guys who end up writing the same software again and again… Just seems like a giant waste of engineering hours…

…I’m talking about a complete software package, something equivalent to a gem in Ruby, where I could call functions like “OutputVoltage(unsigned int voltage, unsinged int channel)” and be oblivious to the hardware implementation…

Think how useful it would be to design in a new peripheral device and run the following to download and install the appropriate device driver in your source tree:

install lan9118

For those developing on major operating systems like Linux this kind of flexibility is a given, but it is by no means so easy for developers using a smaller RTOS. While some operating systems, such as eCos, provide an impressively large suite of device drivers for various peripherals, the drivers are generally targeted specifically at the RTOS in question and cannot be simply compiled and run on other operating systems. This fragmentation results in multiple separate implementations of device drivers for the same peripheral, where (with care) a single portable device driver might be able to support a wide range of operating systems.

Designing a truly portable device driver for embedded systems is a fairly challenging task; the software needs to run happily on any CPU architecture with varying bus widths, endianness, DMA schemes etc. It needs to compile successfully on a wide range of compilers from different vendors. It also needs to integrate with many different RTOS implementations. None of these are insurmountable but they go some way to explaining why the embedded systems community have not naturally settled on a portable framework for integrating portable software modules.

Despite these challenges it is possible to develop highly portable device drivers and software modules which are agnostic to the operating system, architecture or compiler used. Having worked on successful projects on this basis for many years I have seen the benefits in terms of code reuse and faster development of new products based on entirely different underlying technologies.

An open source repository of software modules based on a highly portable framework would reduce wasted effort across the various operating system projects out there. Any open source or otherwise RTOS project would benefit from the existence of such a repository, and I include my own RTOS (Atomthreads) as a major potential beneficiary. Atomthreads has always been intended to be a lightweight library for handling multi-threading which can be combined with the best external libraries for other features (in recognition of the Unix philosophy of doing one thing and doing it well). Separating the device driver framework from the RTOS in an OS-independent manner like this allows users of any RTOS (and even users with no RTOS) to benefit from the same software pool.

Device manufacturers would also benefit through the reduced effort of writing a single device driver that is portable across operating systems. However the biggest winner would be developers of embedded systems products. A wide-ranging repository of portable device drivers and other software modules would allow product development teams to focus on adding their own value, rather than reinventing the wheel by writing brand new device drivers for old peripherals.

Retrofitting the framework to an existing RTOS would require shim layers to convert between APIs and herein, I believe, lies the real difficulty in creating such a framework. While using the new portable API for new systems would be relatively pain-free, finding an API which would fit well with a wide range of existing operating systems’ already well entrenched APIs would be challenging. However when you consider the potential benefits of a free repository of peripheral drivers and other embedded software modules it may well be worth the effort.

If anyone is interested in helping get such a project off the ground then please get in touch.

Bookmark and Share This Article
[del.icio.us] [Digg] [Google] [Reddit] [Slashdot] [StumbleUpon] [Technorati] [Twitter] [Yahoo!] [Email]
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

Comments are closed.