如何“制作"商品修改驱动程序源代码后,现有的Linux内核模块驱动程序 [英] How to "make" existing Linux kernel module driver after modifying the driver source code
问题描述
我对Linux USB Wi-Fi卡驱动程序进行了一些小修改,以插入一些日志记录(printk
语句).我松散地遵循有关如何重新编译/加载模块,其中指出我需要执行make
才能构建.ko
文件.工作目录(/usr/src/linux/drivers/net/wireless/rtl818x/rtl8187/
)中有一个现有的Makefile
,其内容为:
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
在此目录中执行make
时,我得到:
When I execute make
inside this directory, I get:
make: *** No targets. Stop.
根据此,这表示找到了一些makefile,但是它不包含任何默认目标,并且在命令行中未给出任何目标.在这些情况下,GNU make与无关."
所以我的问题是,在我要尝试执行的操作中这意味着什么?如何生成我据认为下一步需要的.ko
文件?
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?
推荐答案
您必须从Linux源代码的顶级目录(/usr/src/linux/中运行 make >).确保您的驱动程序包含在/usr/src/linux/.config 文件中.因此,使用驱动程序构建内核. 如果您不想重建整个内核,请阅读更多:)
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
* CONFIG_RTL8187 *名称可在 drivers/net/wireless/rtl818x/Kconfig (CONFIG_ + RTL8187)中找到
The *CONFIG_RTL8187* name can be found in drivers/net/wireless/rtl818x/Kconfig (CONFIG_ + RTL8187)
这也应该起作用:
make drivers/net/wireless/rtl818x/rtl8187/rtl8187.ko
这篇关于如何“制作"商品修改驱动程序源代码后,现有的Linux内核模块驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!