成功编译网卡驱动

我的毕设终于有眉目了 🙂
我的网卡驱动文件是: driver/net/forcedeth.c
最近在读代码过程中,做了一下代码汉字注释,还有一些笔记。就是编译总出现格式不可用。今天在helight的帮助下,终于把经过自己稍微修改的网卡驱动,编译、安装好,现在使用的就是“自己的网卡驱动了”。

1. Install the kernel header files
$ sudo apt-get install linux-headers-2.6.27-13-generic

2. Get the source code of forcedeth.c, and modify it
kongove@ubuntu:~/code/kernel/force$ ls
forcedeth.c  Makefile

3. Write the Makefile
$ cat Makefile
obj-m := forcedeth.o

KERNELDIR=/lib/modules/`uname -r`/build
#KERNELDIR := /usr/src/linux-headers-2.6.22-14
modules:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
        rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

4. Compile the module
$ make

5. Remove the module
$ sudo rmmod forcedeth

6. Install your module
$ sudo insmod ./forcedeth.ko

7. Check if it works
$ ifconfig
$ ping www.baidu.com

2 thoughts on “成功编译网卡驱动

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.