LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 05-02-2008, 11:15 PM   #1
jacatone
Member
 
Registered: Mar 2004
Posts: 277

Rep: Reputation: 30
Need help creating a Loadable Kernel Modules


I'm trying to create a loadable kernel module for Kubuntu 7.10 which has the 2.6 KDE kernel. The file is a serial speed enhancer for my motherboard. It's name is viahss-0.92 and within the file are thefollowing text files:

file:///home/jacatone/Desktop/Module/viahss-0.92/Makefile
file:///home/jacatone/Desktop/Module/viahss-0.92/Makefile-2.6
file:///home/jacatone/Desktop/Module/viahss-0.92/viahss.c

The instructions are:

If you have a working kernel build environment then you'll need to do
following things:

1) Edit viahss.c in viahss-0.92 directory remove following line (15):
#include <linux/config.h>

2) Copy Makefile for 2.6 on top of 2.4 for makefile
# cp Makefile-2.6 Makefile

3) Compile package with make

# make

This worked at least with my Ubuntu 8.04 based mythbuntu machine (also
with my CentOS4 machine. If this doesn't work most likely you don't
have full kernel build environment."


Could someone explain this to me in plainer language and maybe walk me through the process? Many thanks.

Last edited by jacatone; 05-02-2008 at 11:19 PM.
 
Old 05-03-2008, 12:29 AM   #2
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 474
Blog Entries: 100

Rep: Reputation: 74
Apparently the linux/config.h file has been removed as of 2.6.19. (http://www.linuxquestions.org/questi...kernel-506363/) If you're using a 2.6.19+ kernel (check by running 'uname -r' in a terminal), you'd need to remove that line:

Code:
user@host ~/viahss-0.92 $ mv viahss.c{,.bak}
user@host ~/viahss-0.92 $ sed '15d' viahss.c.bak > viahss.c
If you're paranoid and want to ensure you removed the right line, then diff the .c and .c.bak files:

Code:
user@host ~/viahss-0.92 $ diff viahss.c{.bak,}
Once you're satisfied with that, copy the Makefile-2.6 to Makefile:

Code:
user@host ~/viahss-0.92 $ cp Makefile{-2.6,}
Then build it:

Code:
user@host ~/viahss-0.92 $ make
Then load it into the kernel (have to be root):

Code:
root@host ~/viahss-0.92 # cp ./viahss.ko /lib/modules/`uname -r`/kernel/drivers/serial
root@host ~/viahss-0.92 # update-modules --force
root@host ~/viahss-0.92 # modprobe viahss
After that, you can use the command "setserial" to alter the speed of your VIA VT82C686A or VT82C686B chipset. If something goes wrong during the "make" command, then it's likely your kernel dev environment isn't complete.

Edit - it's the 2.6 kernel, not the 2.6 KDE kernel. KDE runs on top of the OS and is independent of the kernel (i.e. KDE will run on FreeBSD/OpenBSD/NetBSD/etc..., which do NOT use the Linux kernel)...don't mean to nit-pick, but I thought I'd point that out =)

Last edited by rocket357; 05-03-2008 at 01:50 AM.
 
Old 05-05-2008, 12:54 AM   #3
jacatone
Member
 
Registered: Mar 2004
Posts: 277

Original Poster
Rep: Reputation: 30
When I do the "diff viahss.c{.bak,}" command, I get the following:

jacatone@eMax:~/Desktop/Module/viahss-0.92$ diff viahss.c{.bak,}
15d14
< #include <linux/config.h>


Does this mean it's still there? If so, how do I remove it? Thanks.
 
Old 05-05-2008, 09:56 AM   #4
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 474
Blog Entries: 100

Rep: Reputation: 74
Quote:
Originally Posted by jacatone View Post
When I do the "diff viahss.c{.bak,}" command, I get the following:

jacatone@eMax:~/Desktop/Module/viahss-0.92$ diff viahss.c{.bak,}
15d14
< #include <linux/config.h>


Does this mean it's still there? If so, how do I remove it? Thanks.
The "diff" command takes two files as arguments and compares them, then outputs the differences. The curly braces are expanded (in this instance) from:

viahss.c{.bak,}

to:

viahss.c.bak viahss.c

"diff" uses greater than/less than signs to show which file the modifications are in, so this line:

< #include <linux/config.h>

means that viahss.c.bak (the file on the left of the expansion above...notice the "<" at the beginning of the line) still contains the #include directive, but it's absent in the viahss.c file (which is what we want). If that line was still there in viahss.c, it wouldn't show up when diff was run against those two files.

Sorry for not making that clear...the line was removed successfully and you can compile it now.
 
Old 05-05-2008, 03:28 PM   #5
jacatone
Member
 
Registered: Mar 2004
Posts: 277

Original Poster
Rep: Reputation: 30
Not a problem rocket357, I really appreciate your help. Everything went fine until I got to:

root@eMax:/home/jacatone/Desktop/Module/viahss-0.92# modprobe viahss
FATAL: Module viahss not found.
root@eMax:/home/jacatone/Desktop/Module/viahss-0.92# setserial
The program 'setserial' is currently not installed. You can install it by typing:
apt-get install setserial


When I try installing setserial I get:

Media change: please insert the disc labeled
'Kubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016.1)'
in the drive '/cdrom/' and press enter


Which I did, but it keeps repeating this message. I guess the "FATAL: Module viahss not found." is where it went wrong.
 
Old 05-05-2008, 04:15 PM   #6
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 474
Blog Entries: 100

Rep: Reputation: 74
Quote:
Originally Posted by jacatone View Post
FATAL: Module viahss not found.
Did you copy the viahss.ko file to /lib/modules/`uname -r`/kernel/drivers/serial and run update-modules --force? If you did, did you get any errors there?

Quote:
Originally Posted by jacatone View Post
When I try installing setserial I get:

Media change: please insert the disc labeled
'Kubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016.1)'
in the drive '/cdrom/' and press enter
Sounds like you might need to enable some repositories...
 
Old 05-05-2008, 08:40 PM   #7
jacatone
Member
 
Registered: Mar 2004
Posts: 277

Original Poster
Rep: Reputation: 30
Yeah, I did. I just did a copy/paste of all the commands you gave me. Should I try again from scratch?
 
Old 05-05-2008, 09:11 PM   #8
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 474
Blog Entries: 100

Rep: Reputation: 74
Quote:
Originally Posted by jacatone View Post
Should I try again from scratch?
Nah, I'm going to install Kubuntu (couldn't seem to find 7.10, so I'm testing on Kubuntu 8.04) in vmware and see if there's a *buntu specific issue going on here. I usually don't bother blacklisting modules (which seems to be relatively common in *buntu), so perhaps there's a config setting somewhere that's holding you up. I'll post again in a bit.
 
Old 05-05-2008, 10:13 PM   #9
jacatone
Member
 
Registered: Mar 2004
Posts: 277

Original Poster
Rep: Reputation: 30
I tried it over from scratch and didn't get the error message this time, so I guess I did forget something along the way. It's still hung up on the "setserial" command. Keeps asking for the Kubuntu 7.10 disk, which I inserted, then press Enter, but just keeps repeating it over and over:


Media Change: Please insert the disc labeled 'Kubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016.1)' in the drive '/cdrom/' and press [Enter].

Media Change: Please insert the disc labeled 'Kubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016.1)' in the drive '/cdrom/' and press [Enter].

Guess, I'll post this snag as another question.
 
Old 05-05-2008, 10:20 PM   #10
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 474
Blog Entries: 100

Rep: Reputation: 74
Good to hear you got it working.

As for setserial, my initial thought is that there's a universe somewhere that's not being picked up that contains that program. I've got the Kubuntu vmware install finished, so I'll check it out heh. If I can determine a fix, I'll let you know.

Edit - I used the Adept Package Manager, performed a search for setserial, and installed it from there without a hitch. Again, I'm testing on 8.04, so there could be differences in repositories and the like.

Last edited by rocket357; 05-05-2008 at 11:02 PM.
 
Old 05-06-2008, 12:20 AM   #11
jacatone
Member
 
Registered: Mar 2004
Posts: 277

Original Poster
Rep: Reputation: 30
I tried Adept as well, and still got the message asking for the Kubuntu 7.10 disk. Did you get a message asking for your v8.04 disk? I've got all the repositories checked. Even have Multibuntu included. If you were successful with v8.04 maybe I'll do an upgrade and see if that works. Many thanks for your help. I couldn't have gotten as far as I did without it.
 
Old 05-06-2008, 10:01 AM   #12
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 474
Blog Entries: 100

Rep: Reputation: 74
The install I did was from Adept on a default install of 8.04. I performed a clean install, updated the packages it brought up as updates (using Adept to update), then installed setserial.

I'm no *buntu guru, so this issue of asking for the CD is likely better served elsewhere. Wish I could help more, but hey...you got the kernel module built and loaded, right? heh
 
Old 05-08-2008, 05:23 PM   #13
jacatone
Member
 
Registered: Mar 2004
Posts: 277

Original Poster
Rep: Reputation: 30
How do I use this "setserial"? The resulting dialog doesn't really explain how:


root@eMax:/home/jacatone/Desktop/Module/viahss-0.92# setseria
l
setserial version 2.17, 27-Jan-2000

usage: setserial serial-device -abqvVWz [cmd1 [arg]] ...
setserial -g [-abGv] device1 ...

Available commands: (* = Takes an argument)
(^ = can be preceded by a '^' to turn off the
option)
* port set the I/O port
* irq set the interrupt
* uart set UART type (none, 8250, 16450, 165
50, 16550A,
16650, 16650V2, 16750, 16850, 16950,
16954)
* baud_base set base baud rate (CLOCK_FREQ / 16)
* divisor set the custom divisor (see spd_custo
m)
* close_delay set the amount of time (in 1/100 of a
second) that DTR should be ke
pt low
while being closed
* closing_wait set the amount of time (in 1/100 of a
second) that the serial port
should wait for
data to be drained while bein
g closed.
^ fourport configure the port as an AST Fourport
autoconfig automatically configure the serial po
rt
^ auto_irq try to determine irq during autoconfi
guration
^ skip_test skip UART test during autoconfigurati
on

^ sak set the break key as the Secure Atten
tion Key
^ session_lockout Lock out callout port across differ
ent sessions
^ pgrp_lockout Lock out callout port across differen
t process groups
^ callout_nohup Don't hangup the tty when carrier det
ect drops
on the callout device
^ split_termios Use separate termios for callout and
dailin lines
^ hup_notify Notify a process blocked on opening a
dial in line
when a process has finished u
sing a callout
line by returning EAGAIN to t
he open.
^ low_latency Minimize receive latency at the cost
of greater
CPU utilization.
get_multiport Display the multiport configuration
set_multiport Set the multiport configuration

* rx_trigger Set RX trigger level (ESP-only)
* tx_trigger Set TX trigger level (ESP-only)
* flow_off Set hardware flow off level (ESP-only
)
* flow_on Set hardware flow on level (ESP-only)
* rx_timeout Set receive timeout (ESP-only)
* dma_channel Set DMA channel (ESP-only)

spd_hi use 56kb instead of 38.4kb
spd_vhi use 115kb instead of 38.4kb
spd_shi use 230kb instead of 38.4kb
spd_warp use 460kb instead of 38.4kb
spd_cust use the custom divisor to set the spe ed at 38.4kb
(baud rate = baud_base / cust om_divisor)
spd_normal use 38.4kb when a baud rate of 38.4kb is selected

Use a leading '0x' for hex numbers.
CAUTION: Using an invalid port can lock up your machine!
root@eMax:/home/jacatone/Desktop/Module/viahss-0.92#
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loadable Kernel Modules and registering with SCSI shayes_enigmads Programming 0 05-25-2006 09:27 AM
Loadable Kernel Modules jbrashear Debian 7 04-03-2005 05:11 PM
Loadable modules question dudds Linux - Newbie 5 07-20-2004 02:13 AM
of course I have loadable modules enabled! jmynkbht Linux - Software 0 04-26-2004 03:52 AM
loadable modules vs built-in modules nuzzy Linux - Hardware 1 07-21-2003 04:16 PM


All times are GMT -5. The time now is 07:30 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration