简体   繁体   English

如何在Linux中制作内置设备驱动程序

[英]How to make a built-in device driver in linux

I know how to make loadable kernel modules in Linux. 我知道如何在Linux中制作可加载的内核模块。 But i want that loadable kernel module to be a part of the kernel , and after booting that driver should automatically load, like most of the other general driver. 但是我希望该可加载内核模块成为内核的一部分,并且在启动后,该驱动程序应该像大多数其他通用驱动程序一样自动加载。

How to do that? 怎么做?

There are two ways to do for your query 1) building your module as statically compiled along with kernel (your source code should reside in kernel tree ),so while building build it static which come as a part of kernel, so when kernel boots your module will be loaded. 查询有两种方法:1)将module as statically compiled along with kernel (您的源代码应驻留在内核树中),因此在构建模块时将其作为内核一部分进行module as statically compiled along with kernel ,因此当内核启动时模块将被加载。 2)Same as above but while building build as dynamic loadable module so that wheneever required you can load it . 2)与上述相同,但是while building build as dynamic loadable module so that wheneever required you can load it

to illustrate above concept you can try below link for simple helloworld example. 为了说明上述概念,您可以在下面的链接中尝试简单的helloworld示例。

http://www.agusbj.staff.ugm.ac.id/abjfile/Chap8.pdf http://www.agusbj.staff.ugm.ac.id/abjfile/Chap8.pdf

You have to configure modprobe to load automatically driver after kernel boot. 您必须将modprobe配置为在内核引导后自动加载驱动程序。 Here an example of configuration. 这里是一个配置示例

If you want to a built-in module, you must re-compile the kernel, and set Y in the configuration file on all modules that you want inside the kernel 如果要使用内置模块,则必须重新编译内核,并在内核中想要的所有模块上的配置文件中设置Y

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

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