简体   繁体   English

如何在Linux内核构建过程中生成可加载模块?

[英]How do I generate loadable modules during Linux kernel build?

I seem to successfully build a kernel image, but I can not generate all the modules I expect. 我似乎已成功构建了内核映像,但无法生成我期望的所有模块。 I expect more modules since I see them enabled in the gconfig window. 我希望有更多的模块,因为我在gconfig窗口中看到了启用的模块。 Here is a copy of my make session. 是我的制作会话的副本。 Seems like make goes into the devices directories. 好像make进入devices目录。 I can not figure out why it is not create the .ko files. 我不知道为什么它不能创建.ko文件。 I expect to see .ko files. 我希望看到.ko文件。 I have checked the Makefile in /drivers directory, and I can see that it is configured with a number of lines like 我已经检查了/ drivers目录中的Makefile,可以看到它配置了许多行,例如

obj-$(CONFIG_PCI)               += pci/

Which directs make to build the pci module for instance. 例如,哪个命令make构建pci模块。 I think this implies that I should see a number .ko files. 我认为这意味着我应该看到多个.ko文件。 But I do not. 但我不。 I have seen just one .ko file for scsi module. 我只看到一个.ko文件用于scsi模块。 I like to be able to build all of modules selected. 我希望能够构建所有选定的模块。

I also verified that a number of mudules are enabled when I issued: 我还验证了发出以下消息时是否启用了一些混淆:

make VARIANT_DEFCONFIG=msm8974_sec_hlte_spr_defconfig msm8974_sec_defconfig SELINUX_DEFCONFIG=selinux_defconfig gconfig

But as I said, I do not see any of them. 但是正如我所说,我没有看到任何一个。 What am I missing please? 我想念什么?

@Subin - Thanks. @Subin-谢谢。 I just tried make modules_install. 我刚试过make modules_install。 I have to mention that I am cross compiling this for an arm target. 我不得不提到,我正在交叉编译这个目标。 I believe modules_install is for the purpose of installing the driver for the machine you are on? 我相信modules_install是为了为您所在的计算机安装驱动程序? I got a message about needing to be in root, and I did not proceed. 我收到一条有关需要扎根的消息,但我没有继续。 I have been wondering when I need to run it. 我一直想知道何时需要运行它。 What does it do exactly please? 请问到底有什么作用?

Re: the make modules; 回复:make模块; I have run it before. 我以前已经运行过。 I'll run it again and post the result. 我将再次运行它并发布结果。 Since I got one .ko file I figured the issue is something different between that one module, and every other one enabled in my config. 由于我得到一个.ko文件,因此我认为问题是该模块与配置中启用的其他模块之间有所不同。 Here is what I got when I ran make modules: 这是我运行make模块时得到的:

sansari@ubuntu:~/WORKING_DIRECTORY$ make modules
CHK     include/linux/version.h
CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CALL    scripts/checksyscalls.sh
Building modules, stage 2.
MODPOST 1 modules

Re: your comment on the location of .ko files, I am doing a find to see if perhaps I am not looking at the right place, it only finds the one which was built. 回复:您对.ko文件位置的评论,我正在做一个发现,看我是否不是在正确的位置,它只会找到已构建的文件。 Not the other ones. 没有其他的。 Here is the output: 这是输出:

sansari@ubuntu:~/WORKING_DIRECTORY$ find . -type f -name "*.ko"
./drivers/scsi/scsi_wait_scan.ko
sansari@ubuntu:~/WORKING_DIRECTORY$ 

Should I perhaps run make v=1, in verbose mode that is? 我是否应该以详细模式运行make v = 1? Would that provide more information on why the other modules are not built? 这样可以提供更多关于为什么不构建其他模块的信息吗?

@Gil Hamilton - Thanks. @吉尔·汉密尔顿-谢谢。 You are right. 你是对的。 Here is an excerpt of the .config file: 这是.config文件的摘录:

#
# SCSI support type (disk, tape, CD-ROM)
#
CONFIG_BLK_DEV_SD=y
# CONFIG_CHR_DEV_ST is not set
# CONFIG_CHR_DEV_OSST is not set
# CONFIG_BLK_DEV_SR is not set
CONFIG_CHR_DEV_SG=y
CONFIG_CHR_DEV_SCH=y
CONFIG_SCSI_MULTI_LUN=y
CONFIG_SCSI_CONSTANTS=y
CONFIG_SCSI_LOGGING=y
CONFIG_SCSI_SCAN_ASYNC=y
CONFIG_SCSI_WAIT_SCAN=m

This entry is the only one set to 'm'. 该条目是唯一设置为“ m”的条目。

Most device driver modules in the linux kernel build system use a tristate (3-valued) configuration setting. linux内核构建系统中的大多数设备驱动程序模块都使用三态(三值)配置设置。 The options are 选项是

  • 'n' (don't build at all), 'n'(根本不建),
  • 'y' (build and link statically into the main kernel object), and 'y'(构建并静态链接到主内核对象),以及
  • 'm' (build as module for dynamic loading). 'm'(作为模块进行动态加载)。

The values are determined by the content of .config. 这些值由.config的内容确定。 The values in .config are usually generated from an existing config file (look in arch/ <ARCH> /configs for your <ARCH> ). .config中的值通常是从现有的配置文件生成的(请在arch / <ARCH> / configs中查找<ARCH> )。 Also check the output of 'make help' for interesting configuration targets. 还要检查“ make help”的输出以了解有趣的配置目标。

If you're not seeing the .ko files being created, that indicates the corresponding configuration variable is either set to 'y' or 'n'. 如果没有看到正在创建的.ko文件,则表明相应的配置变量设置为“ y”或“ n”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM