<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9"> <TITLE>Linux I/O port programming mini-HOWTO: Troubleshooting</TITLE> <LINK HREF="IO-Port-Programming-9.html" REL=next> <LINK HREF="IO-Port-Programming-7.html" REL=previous> <LINK HREF="IO-Port-Programming.html#toc8" REL=contents> </HEAD> <BODY> <A HREF="IO-Port-Programming-9.html">Next</A> <A HREF="IO-Port-Programming-7.html">Previous</A> <A HREF="IO-Port-Programming.html#toc8">Contents</A> <HR> <H2><A NAME="s8">8. Troubleshooting</A></H2> <P> <DL> <DT><B>Q1.</B><DD><P>I get segmentation faults when accessing ports. <P> <DT><B>A1.</B><DD><P>Either your program does not have root privileges, or the <CODE>ioperm()</CODE> call failed for some other reason. Check the return value of <CODE>ioperm()</CODE>. Also, check that you're actually accessing the ports that you enabled with <CODE>ioperm()</CODE> (see Q3). If you're using the delaying macros (<CODE>inb_p()</CODE>, <CODE>outb_p()</CODE>, and so on), remember to call <CODE>ioperm()</CODE> to get access to port 0x80 too. <P> <DT><B>Q2.</B><DD><P>I can't find the <CODE>in*()</CODE>, <CODE>out*()</CODE> functions defined anywhere, and gcc complains about undefined references. <P> <DT><B>A2.</B><DD><P>You did not compile with optimisation turned on (<CODE>-O</CODE>), and thus gcc could not resolve the macros in <CODE>asm/io.h</CODE>. Or you did not <CODE>#include <asm/io.h></CODE> at all. <P> <DT><B>Q3.</B><DD><P><CODE>out*()</CODE> doesn't do anything, or does something weird. <P> <DT><B>A3.</B><DD><P>Check the order of the parameters; it should be <CODE>outb(value, port)</CODE>, not <CODE>outportb(port, value)</CODE> as is common in MS-DOS. <P> <DT><B>Q4.</B><DD><P>I want to control a standard RS-232 device/parallel printer/joystick... <P> <DT><B>A4.</B><DD><P>You're probably better off using existing drivers (in the Linux kernel or an X server or somewhere else) to do it. The drivers are usually quite versatile, so even slightly non-standard devices usually work with them. See the information on standard ports above for pointers to documentation for them. </DL> <P> <P> <HR> <A HREF="IO-Port-Programming-9.html">Next</A> <A HREF="IO-Port-Programming-7.html">Previous</A> <A HREF="IO-Port-Programming.html#toc8">Contents</A> </BODY> </HTML>