📄 manual_instructions_for_linux.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html lang="en"><head><title>Instructions for Linux - Universal Driver Documentation</title><meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"><meta name="robots" content="index,follow"><link rel="shortcut icon" href="/favicon.ico"><link rel="stylesheet" href="/dscud/style/wikiprintable.css"><script type="text/javascript" src="/dscud/style/wikibits.js"></script><style type='text/css'><!--a.new, #quickbar a.new { color: #CC2200; }#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }#article { margin-left: 152px; margin-right: 4px; }//--></style></head><body bgcolor='#FFFFFF'><div class='titlebox'><h1 class='pagetitle'>Instructions for Linux</h1><span class='subtitle'>Universal Driver Documentation</span></div><div class='navbox'><a href="manual_Main_Page.html" class='printable' title ="Main Page">Main Page</a> || <a href="manual_Table_of_Contents.html" class='printable' title ="Table of Contents">Table_of_Contents</a> || <a href="http://www.diamondsystems.com/">Diamond Systems Website</a></div></div><div class='bodytext'><a name="top"></a><p><table border="0" id="toc"><tr><td align="center"><b>Table of contents</b> <script type='text/javascript'>showTocToggle("show","hide")</script></td></tr><tr id='tocinside'><td align="left"><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#What_is_Linux?">1 What is Linux?</A><BR></div><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#Supported_Linux_Versions">2 Supported Linux Versions</A><BR></div><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#Instructions_If_You_Don't_Need_Interrupt_Features">3 Instructions If You Don't Need Interrupt Features</A><BR></div><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#Things_To_Do_Before_You_Install">4 Things To Do Before You Install</A><BR></div><div style="margin-left:2em;"><A CLASS="internal" HREF="#Download_the_Kernel_Source">4.1 Download the Kernel Source</A><BR><A CLASS="internal" HREF="#Prepare_the_Kernel_Source_For_Use">4.2 Prepare the Kernel Source For Use</A><BR></div><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#Installing_the_Driver_on_your_Development_System">5 Installing the Driver on your Development System</A><BR></div><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#Compiling_the_Linux_Kernel_Module">6 Compiling the Linux Kernel Module</A><BR></div><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#Compiling_With_the_Driver">7 Compiling With the Driver</A><BR></div><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#Installing_the_Driver_on_your_Embedded_System">8 Installing the Driver on your Embedded System</A><BR></div><div style="margin-bottom:0px;"><A CLASS="internal" HREF="#Troubleshooting_Linux_Driver_Problems">9 Troubleshooting Linux Driver Problems</A><BR></div></td></tr></table><P><h2><a name="What_is_Linux?">What is Linux?</a></h2>
<p>
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.
<p>
<h2><a name="Supported_Linux_Versions">Supported Linux Versions</a></h2>
<p>
Linux kernel versions 2.2, 2.4, and 2.6 are supported.<p><h2><a name="Instructions_If_You_Don't_Need_Interrupt_Features">Instructions If You Don't Need Interrupt Features</a></h2>
<p>
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 <a href="manual_DscADSampleInt.html" class='printable' title ="DscADSampleInt">dscADSampleInt</a>() and <a href="manual_DscUserInt.html" class='printable' title ="DscUserInt">dscUserInt</a>(). Simple functions like <a href="manual_DscDAConvert.html" class='printable' title ="DscDAConvert">dscDAConvert</a>(), <a href="manual_DscADSample.html" class='printable' title ="DscADSample">dscADSample</a>(), and digital I/O operations do not require interrupts.
<p>
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 <tt>install.sh</tt> or <tt>load.sh</tt> shell scripts, or create the <tt>/dev/dscud</tt> device, do anything with kernel source code, or create a kernel module.<p><h2><a name="Things_To_Do_Before_You_Install">Things To Do Before You Install</a></h2>
<p>
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.
<p>
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.
<p>
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.
<p>
<h3><a name="Download_the_Kernel_Source">Download the Kernel Source</a></h3>
<p>
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.
<p>
Extract the kernel source on your development system so that it is available in <tt>/usr/src/linux</tt>. Below is an example of how this is normally done.
<p>
<pre>
$ 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
</pre>
<p>
<h3><a name="Prepare_the_Kernel_Source_For_Use">Prepare the Kernel Source For Use</a></h3>
<p>
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.
<p>
The first step is to configure the kernel. Run this command.
<p>
<pre>
$ cd /usr/src/linux
$ make menuconfig
</pre>
<p>
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.
<p>
Run this command to finish setting up the kernel source.
<p>
<pre>
$ make depend
</pre>
<p>
This kernel source is now ready to be used to build kernel modules.
<p>
<h2><a name="Installing_the_Driver_on_your_Development_System">Installing the Driver on your Development System</a></h2>
<p>
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.
<p>
<pre>
$ tar zfx dscud-5.9.tar.gz
$ mv dscud5 /usr/local/
</pre>
<p>
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.
<p>
<pre>
$ cd /usr/local/dscud5
$ ./install.sh
$ ./load.sh
</pre>
<p>
See the next section if you experience any problems with the install script.<p><h2><a name="Compiling_the_Linux_Kernel_Module">Compiling the Linux Kernel Module</a></h2>
<p>
You should run the install script to build the kernel module. Here is an example.
<p>
<pre>
$ cd /usr/local/dscud5
$ ./install.sh
</pre>
<p>
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 <em>load.sh</em> this module will be loaded into the kernel so that it can be used.
<p>
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.<p><h2><a name="Compiling_With_the_Driver">Compiling With the Driver</a></h2>
<p>
The driver is a library which you link with your application. Here is an example.
<p>
<pre> $ gcc myapp.c -o myapp -I/usr/local/dscud5 -L/usr/local/dscud5 -ldscud5 -lm -pthread</pre><p><h2><a name="Installing_the_Driver_on_your_Embedded_System">Installing the Driver on your Embedded System</a></h2>
<p>
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.
<p>
<ol><li> Copy the dscudkp.o file to <tt>/lib/modules/misc</tt> on your embedded system
</li><li> Copy the <tt>load.sh</tt> script to <tt>/root/load.sh</tt> on your embedded system
</li><li> Modify your system startup script to run <tt>/root/load.sh</tt> every time Linux boots.
</li></ol><p>
On many systems there is an <tt>/etc/rc.sysinit</tt> or <tt>/etc/rc.local</tt> file which you can use to add custom bootup commands.
<p>
<h2><a name="Troubleshooting_Linux_Driver_Problems">Troubleshooting Linux Driver Problems</a></h2>
<p>
Here are some tips on troubleshooting problems on Linux.
<p>
<ul><li> The driver must be run as the root user. If you would rather not do this to avoid potential security risks, you can use the <tt>setuid()</tt> call to switch to a different user after calling <a href="manual_DscInit.html" class='printable' title ="DscInit">dscInit</a>(). You should also change the file permissions for <tt>/dev/dscud</tt> so that your alternate user has read/write access to it.
</li></ul><p>
<ul><li> Check to make sure the <tt>/dev/dscud</tt> device exists. This device file is created by the <tt>load.sh</tt> script. It is required for communication with the <tt>dscudkp.o</tt> kernel module. If it does not exist, run the <tt>load.sh</tt> script provided with the driver to create it.
</li></ul><p>
<ul><li> Run the <tt>lsmod</tt> command to make sure the <tt>dscudkp</tt> kernel module is loaded. If it is not listed, either the <tt>load.sh</tt> script was not run, or an error occured. Run the <tt>load.sh</tt> script manually to check for errors.
</li></ul><p>
<ul><li> If the module loader complains of "unresolved symbols" this indicates that the module was built for a different version of Linux than you are running. Make sure that /usr/src/linux on the system where the driver was built matches the version of the kernel you are running on the target system.
</li></ul><p>
<ul><li> If the module loader complaints of "kernel-module version mismatch" this also indicates that the kernel source that was downloaded in /usr/src/linux on your development system does not match the version on the target system.
</li></ul><p>
<ul><li> If the <tt>install.sh</tt> script complaints of "missing or wrong headers" this indicates that the full kernel source was not found in <tt>/usr/src/linux</tt>. Make sure you followed the full process of preparing the kernel source for using including running "make depend".
</li></ul><p>
<ul><li> If the module loader complains "dscudkp.o will taint the kernel" you can disregard this message. This is the Linux community making you aware that you are loading a module provided by a 3rd party (in this case, Diamond Systems) and that they will want you to come to us instead of them for support with problems that come from this.
</li></ul><p></div><p><em> <br> This page was last modified 22:18, 2 Aug 2005.<br>Copyright (c) 2004 Diamond Systems. All Rights Reserved.</em><!-- Time since request: 0.20 secs. --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -