How to “make” existing Linux kernel module driver

2019-01-19 08:25发布

I have made some trivial modifications to a Linux USB Wi-Fi card driver to insert some logging (printk statements). I am loosely following a guide on how to recompile/load the module, which states that I need to execute make in order to build the .ko file. There is an existing Makefile in the working directory (/usr/src/linux/drivers/net/wireless/rtl818x/rtl8187/), which reads:

rtl8187-objs        := dev.o rtl8225.o leds.o rfkill.o

obj-$(CONFIG_RTL8187)   += rtl8187.o

ccflags-y += -Idrivers/net/wireless/rtl818x

When I execute make inside this directory, I get:

make: *** No targets.  Stop.

According to this, this means "that some makefile was found, but it didn't contain any default goal and none was given on the command line. GNU make has nothing to do in these situations."

So my question is, what does this mean in the context of what I am trying to do, and how do I go about generating the .ko file which I am purported to need for the next step?

1条回答
The star\"
2楼-- · 2019-01-19 08:59

You must run make from the top directory of the Linux source (/usr/src/linux/). Be sure that your driver is included in your /usr/src/linux/.config file. So, build the kernel with your driver. If you don't want to rebuild the entire kernel, read more :)

If you want to re-build all modules inside the directory:

make M=drivers/net/wireless/rtl818x/rtl8187/

If you want to re-build a single module inside the directory:

make M=drivers/net/wireless/rtl818x/ CONFIG_RTL8187=m

The *CONFIG_RTL8187* name can be found in drivers/net/wireless/rtl818x/Kconfig (CONFIG_ + RTL8187)

It should works also this:

make drivers/net/wireless/rtl818x/rtl8187/rtl8187.ko
查看更多
登录 后发表回答