how do I install a .c file as a module in Linux??

Soccerman

Elite Member
Oct 9, 1999
6,378
0
0
I have a NIC that includes a linux driver on a diskette.. anywho, it's a .c file, and I don't know what to do with that.. can someone explain what each step does to insert it as a module? FYI I'm a linux newbie, trying to figure out how best to go about making a server out of freesco on a Pentium 233 TX mobo, with 128 megs SDRAM and a 4 gig HD..

I'm pretty sure that the 2.2 kernel (what freesco uses) will not recognize this NIC (DFE-538TX) automatically, so inserting the module is the only way to go..

oh and btw, will ANY hardware ISA 56k modem work? I have a Diamond Supra Express 56k internal that I quickly tried (and failed I think) on Mandrake 8.0. what would I do in freesco? use the setserial command? I guess I'd have to find what the modem would be using in the first place (it's on PnP mode right now, which is set by a jumper), right? using what command?

oh and btw, what's the equivalent to /p in Linux (ie, dir /p so it stops after a page), or |more.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
The .c file is a C source code, you have to compile it. It should come with a README or INSTALL file that details that for you.

The modem should work if you take out of PnP mode, it'll just be another serial port and should be listed (ttyS0 is COM1, ttys1 is COM2, etc) on bootup.
 

Soccerman

Elite Member
Oct 9, 1999
6,378
0
0
The modem should work if you take out of PnP mode, it'll just be another serial port and should be listed (ttyS0 is COM1, ttys1 is COM2, etc) on bootup.

ya ok, I thought that would be how to get the modem working.. I'd probably set it to COM 3 (TTYS4)..

The .c file is a C source code, you have to compile it. It should come with a README or INSTALL file that details that for you.

that's the problem.. there is a readme file on the disk.. here are the instructions:

The procedure to activate DFE-538TX on Red Hat 6.X linux is as follows:

step 1: copy the driver rtl8139.c from driver diskette to you linux.


step 2: compile:
The instruction for compiling the driver is include at the end of
the driver file. (run this instruction at /usr/src/linux)
Or you can use the Makefile included in the driver diskette \Linux.

step 3: insert the driver as module:
insmod rtl8139.o
(run 'lsmod' to see if the module is inserted)

step 4: bind your card to an IP address

/sbin/ifconfig eth0 ${IPADDR} broadcast ${BROADCAST}
netmask ${NETMASK}
(run 'netstat -i' to see if there is a interface 'eth0')

step 5: add your card to IP routing table, then add gateway also your card:
/sbin/route add -net ${NETWORK} netmask ${NETMASK} eth0
(should be able to ping local network now)
gateway:
/sbin/route add default gw ${GATEWAY} netmask 0.0.0.0 metric 1

step 6: start inet deamon.
/usr/sbin/inetd
(you are on the network now)

*make sure that your kernel is built with network, fast_ethernet and module
support. Otherwise, you have to rebuild your kernel.
(1:go to /usr/src/linux directory
2:run 'make menuconfig' or 'make config'
3:mark the options list above.
4:exit and rebuild your kernel.
make dep;make clean;make zImage
the file 'zImage' will be at /usr/src/linux/arch/i386/boot/zImage
5:modify /etc/lilo.conf.(this file specify where kernel image is)
6:run 'lilo' )


now, that also includes rebuilding the kernel, giving my card an IP address, binding my card to the IP routing table (I'm guessing that's good for using the computer as a router), and adding a gateway...

my problem is, it refers to this:
step 2: compile:
The instruction for compiling the driver is include at the end of
the driver file. (run this instruction at /usr/src/linux)
Or you can use the Makefile included in the driver diskette \Linux.


now that means I have to look at the .c file right?

here's the last few lines of the .c file:

/*
* Local variables:
* compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c rtl8139.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`"
* SMP-compile-command: "gcc -D__SMP__ -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c rtl8139.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`"
* cardbus-compile-command: "gcc -DCARDBUS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c rtl8139.c -o realtek_cb.o -I/usr/src/linux/pcmcia-cs-3.0.9/include/"
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/


I'm guessing I have to do this: gcc -DMODULE -......

right? do I to fill in any of the underscores (__)? or just type in the compile command? I don't think I have to do the SMP compile command, nor the Cardbus compile command right? what about c-indent and all the rest?
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Try to use the Makefile if you can find it.

Generally you just run "make;make install", though some Makefiles are different.

Copy both the .c file and the Makefile to /usr/src/linux and run "make;make install".
 

BlackOmen

Senior member
Aug 23, 2001
526
0
0
My 2.2.19 kernel has the rtl8139 available as a supplied module. Perhaps it has been included by freesco; check in /lib/modules/2.2.19/net and look for rtl8139.o.gz. If it is there, a simple /sbin/modprobe/rtl8139 should suffice.
 

Soccerman

Elite Member
Oct 9, 1999
6,378
0
0
ya I just looked at the freesco modules list and it says rt8139 is already built in. that's good, but I'd still like to know how to install from the .c file (cause I'm curious, and cause I don't want to ask again should the situation occur again).

AFAIK, I tried to use the makefile that comes on the diskette (this was a while ago), but it didn't work (I tried make install, not knowing what else to try).

I just looked at the makefile and at the top it said this:

# To create a debuggable driver with emulation, do
# make clean
# make depend
# make all


so I should just do those 3 commands? do I want emulation?? or a debuggable driver?

and do u think the above command from the other file work? in other words:

* compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c rtl8139.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`"
 

Soccerman

Elite Member
Oct 9, 1999
6,378
0
0
hello?? will those sequence of commands install that should I need them?

and finally, sometimes when I'm having trouble with a command (like what all the options in it are), how can I list the options like in DOS, where it goes page by page, rather than just shoot out the whole list and let me see only the bottom?
 

neuralfx

Golden Member
Feb 19, 2001
1,636
0
0
'make clean && make dep && make'

will install it, but it wont insert it. assuming your device is pci, just use 'insmod filename.o' .. you will have to make an alias in ur modules.conf, or conf.modules, whichever you have, to this module ..
and to answer u question u use the '| less' pipe .. you could use '| more' .. but Less is more=) .. good luck ..
-neural
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Soccerman, for the command problem thing, try "man" :)
Like "man ls" or "man whatever-command-you-want"
 

neuralfx

Golden Member
Feb 19, 2001
1,636
0
0
ah yes i forgot you asked how to get help , 'man' is the most popular like 'man grep' now, you can also use 'info' like 'info grep' .. its a little clearer to understand, shorter .. good luck ..
-neural
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
you can also use 'info' like 'info grep' .. its a little clearer to understand, shorter .. good luck

info is a GNU only thing and hasn't really caught on, many things have man pages that don't have info pages.
 

Soccerman

Elite Member
Oct 9, 1999
6,378
0
0
I don't know for sure, but I don't think Freesco has the MAN pages.. thanks for the info!

will install it, but it wont insert it. assuming your device is pci, just use 'insmod filename.o' .. you will have to make an alias in ur modules.conf, or conf.modules, whichever you have, to this module ..

will install it but not insert it?? that doesn't make much sense.. I'm guessing it doesn't insert it as a module so it's not associated with the kernel right?

what do u mean by an alias? I'm guessing u mean that I have to put the line 'insmod filename.o' in the modules.conf or whatever it is?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
will install it but not insert it?? that doesn't make much sense..

He means it'll put the module in /lib/modules/... but won't insert it into the running kernel.

what do u mean by an alias? I'm guessing u mean that I have to put the line 'insmod filename.o' in the modules.conf or whatever it is?

He means a line like 'alias eth0 il' because programs like ifup will run 'modprobe eth0' and expand the eth0 alias to il so the proper module gets loaded.
 

neuralfx

Golden Member
Feb 19, 2001
1,636
0
0


<< info is a GNU only thing and hasn't really caught on, many things have man pages that don't have info pages. >>


ya .. i know, should have stated it wont work on all commands on all distro's ..


<< He means a line like 'alias eth0 il' because programs like ifup will run 'modprobe eth0' and expand the eth0 alias to il so the proper module gets loaded. >>

>>

ya i should have been more clear about that as well .. thanks nothinman ..

-neural
 

Chatterjee

Senior member
Nov 16, 1999
855
0
0
in your drivers directory under /lib/modules/KERNELVERSION/drivers/net, check to see if you have the 8139too.o module file... this MAY work as a replacement!

do an insmod 8139too.o command... if you don't get any error messages, it may have worked... to verify, do an lsmod command and see whether it appears in the list.. if so, you're golden..

-S