Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "make" existing Linux kernel module driver after modifying the driver source code

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?

like image 723
Bryce Thomas Avatar asked Oct 28 '25 20:10

Bryce Thomas


1 Answers

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
like image 86
Federico Avatar answered Oct 31 '25 13:10

Federico



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!