Skip to contentSkip to conversation

Building a new module from an existing one

DISCUSSION Marcus Ramos 3 participants 3 messages Feb 22, 2001

lore
Share & tools
lore
#0 lore raw

Hello,

I plan to make a few changes to 3c90x.c (Ethhernet driver) located at /usr/src/linux-2.2.16/drivers/net, in RH7. Since the correspondent object file 3c90x.o resides in /lib/modules/2.2.16-20/net, I ask: how shall I proceed in order to have the C file properly compiled and placed in the right place, so that the modified version replaces the previous one after system boot up ?

Thanks in advance,
Marcus.

#1 lore raw
Quoted 8 lines · Marcus Ramos

Hello,

I plan to make a few changes to 3c90x.c (Ethhernet driver) located at /usr/src/linux-2.2.16/drivers/net, in RH7. Since the correspondent object file 3c90x.o resides in /lib/modules/2.2.16-20/net, I ask: how shall I proceed in order to have the C file properly compiled and placed in the right place, so that the modified version replaces the previous one after system boot up ?

after you compile it with something like this command line

gcc -c 3c90x.c -O2 -Wall -Wstrict-prototypes -fomit-frame-pointer \
    -fno-strength-reduce -pipe -m486 -malign-loops=2 \
    -malign-jumps=2 -malign-functions=2 -DCPU=486 -DMODULE -D__KERNEL__

just copy the generated 3c90x.o to /lib/modules/2.2.16-20/net, overwriting the old 3c90x.o (made a backup if you wish)

Fernando Fuganti

#2 lore raw
In reply to Marcus Ramos
Quoted 9 lines · Marcus Ramos

Hello,

I plan to make a few changes to 3c90x.c (Ethhernet driver) located at /usr/src/linux-2.2.16/drivers/net, in RH7. Since the correspondent object file 3c90x.o resides in /lib/modules/2.2.16-20/net, I ask: how shall I proceed in order to have the C file properly compiled and placed in the right place, so that the modified version replaces the previous one after system boot up ?

Quoted 3 lines

Thanks in advance,
Marcus.

I assume this is serious. Therefore, I answer.

cd /usr/src/linux-2.2.16
make modules
make modules_install

You should be able to test your changes without having to reboot and without overwriting the existing (working) driver. If you are doing a lot of work, I suggest you make a script:

#!/bin/bash
ifconfig eth0 down
rmmod 3c90x
insmod /usr/src/linux-2.2.16/drivers/net/3c90x.o ifconfig eth0 xx.xx.xx.xx netmask mm.mm.mm.mm broadcast bb.bb.bb.bb route add -net xx.xx.xx.0 netmask mm.mm.mm.mm broadcast dev eth0 route add default gw (etc)

Once you have verified that your revised driver works as intended, then you do make modules_install to put it into the correct place for the next boot.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of course you get it all back when you reboot..."; Actual explanation obtained from the Micro$oft help desk.