Instructions for Linux

Universal Driver Documentation

Table of contents

What is Linux?

Linux is a kernel developed and distributed under an open source model. Distributions such as Redhat, SuSE, and Debian package this kernel with other software to provide a complete operating system. The Universal Driver works directly with the Linux kernel, so any distribution should work fine as long as they used a supported Linux kernel version.

Supported Linux Versions

Linux kernel versions 2.2, 2.4, and 2.6 are supported.

Instructions If You Don't Need Interrupt Features

Many of the instructions that follow relate to building and installing a Linux kernel module provided by Diamond Systems. This kernel module is required to support high speed processing of interrupts from the data acquisition boards. However, if you do not intend to use interrupts from the board, there is no need for you to install this kernel module. Examples of interrupt functions are dscADSampleInt() and dscUserInt(). Simple functions like dscDAConvert(), dscADSample(), and digital I/O operations do not require interrupts.

If you don't need interrupts, you can simply extract the driver files, link to the driver library with your program, and copy your executable to your embedded system. You don't need to run the install.sh or load.sh shell scripts, or create the /dev/dscud device, do anything with kernel source code, or create a kernel module.

Things To Do Before You Install

The driver uses a Linux kernel module developed by Diamond Systems to handle interrupt processing. If you intend to use any interrupt related functions of the driver you will need this module. It is compiled during the installation procedures described below.

To build a Linux kernel module you must have the source code to the Linux kernel available on your system. Additionally, kernel modules are built for a specific version of the kernel, so if you build the module for one version and then attempt to load the module under another version, errors or unexpected results may occur.

The kernel version you select should be the version you will use on your embedded system. If you build a module for the version of Linux you are running on your desktop PC, this module will not run correctly on your embedded system unless it is running the exact same kernel version. Often this means that the driver will only load properly on one platform and not the other.

Download the Kernel Source

If your embedded system is using a standard version of the Linux kernel you can download the source from the kernel.org website. If it is a patched or custom kernel you will have to get the kernel source from the organization that provided the custom kernel.

Extract the kernel source on your development system so that it is available in /usr/src/linux. Below is an example of how this is normally done.

  $ tar jxf kernel-source-2.4.19.tar.bz2
  $ mv linux-2.4.19 /usr/src/linux-2.4.19
  $ ln -s /usr/src/linux-2.4.19 /usr/src/linux

Prepare the Kernel Source For Use

The kernel source is not ready to be used for building kernel modules until it is configured. In some kernel configurations you must also begin the kernel compile process for it to include all the code required.

The first step is to configure the kernel. Run this command.

  $ cd /usr/src/linux
  $ make menuconfig

You will be presented with a menu that lists many options. You should select the correct CPU type and disable Symmetric multi-processing support under "Processor Type and Features". Then go to "Loadable Module Support" and make sure that "Enable loadable module support" is enabled. Exit the menu making sure it saves the kernel configuration.

Run this command to finish setting up the kernel source.

  $ make depend

This kernel source is now ready to be used to build kernel modules.

Installing the Driver on your Development System

The driver is available as a simple tar gzip'd archive. To install the driver in this format you just extract the archive and move the new driver folder to the correct location on your system. Here is an example.

  $ tar zfx dscud-5.9.tar.gz
  $ mv dscud5 /usr/local/

Once you have moved the directory, you must run an install script which will prepare the driver for use on your system. This will build a Linux kernel module which is required to use the interrupt related features of the driver. Here is an example.

  $ cd /usr/local/dscud5
  $ ./install.sh
  $ ./load.sh

See the next section if you experience any problems with the install script.

Compiling the Linux Kernel Module

You should run the install script to build the kernel module. Here is an example.

  $ cd /usr/local/dscud5
  $ ./install.sh

This will compile the dscudkp.c file using the Linux kernel source located in /usr/src/linux and build a loadable kernel module called dscudkp.o. This file will then be copied to /lib/modules/misc. When you run load.sh this module will be loaded into the kernel so that it can be used.

If you see an error complaining about "unresolved symbols" it means that the kernel you are running does not match the kernel source in /usr/src/linux, or the kernel has been configured differently, for example with or without SMP support.

Compiling With the Driver

The driver is a library which you link with your application. Here is an example.

  $ gcc myapp.c -o myapp -I/usr/local/dscud5 -L/usr/local/dscud5 -ldscud5 -lm -pthread

Installing the Driver on your Embedded System

If you are not using any interrupt related functions of the driver, you can simply copy your compiled program to the embedded system and run it without problems. However, if you need interrupt functions you'll need to setup the Linux kernel module on your embedded system. Follow these steps.

  1. Copy the dscudkp.o file to /lib/modules/misc on your embedded system
  2. Copy the load.sh script to /root/load.sh on your embedded system
  3. Modify your system startup script to run /root/load.sh every time Linux boots.

On many systems there is an /etc/rc.sysinit or /etc/rc.local file which you can use to add custom bootup commands.

Troubleshooting Linux Driver Problems

Here are some tips on troubleshooting problems on Linux.


This page was last modified 22:18, 2 Aug 2005.
Copyright (c) 2004 Diamond Systems. All Rights Reserved.