将驱动程序编译为内核的一部分,而不是模块
我正在尝试为嵌入式设备创建一个简约的 Linux。这意味着需要编译内核和驱动程序。一个驱动程序是由其创建者直接为设备板编写的,因此它不是存储库驱动程序。它可以被编译为内核模块。
然而,由于 Linux 的不可变特性以及对内存使用极少的要求,我不想使用模块。我希望所有驱动程序都内置在内核中。所有随内核提供的驱动程序我都这样设置的。
所以我的问题是如何将一个特殊的驱动程序编译到内核?
所有搜索都没有为我提供解决方案 - 所有搜索都只是作为模块进行编译。
感谢您的任何帮助。
I am trying to create a minimalistic Linux for an embedded device. That means the necessity of compiling kernel and drivers. One driver is written directly for the device's board by it's creator, so it is not a repository one. It can be compiled as a kernel module.
However because of immutable nature of the Linux and requirement of extremely small use of memory I do not want to use modules. I want all drivers built-in in the kernel. And all drivers provided with kernel I have set this way.
So my problem is how to compile that one special driver to the kernel?
All searching have not provided me with a solution - all are only about compiling as modules.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您肯定必须将驱动程序源代码放入内核源代码树中并更新 makefile 以包含它。您可以在此处查看步骤 1.1 到 1.3 的工作原理< /a>.
如果用户级软件与设备驱动程序进行任何通信,它可能是通过系统调用来完成的。搜索驱动程序的源代码以查找
asmlinkage
,如果您找到其中任何一个,那么您正在考虑添加一些系统调用。上述文档的其余部分将解释如何设置它们。您必须修改至少两个文件(根据您的内核版本,它们可能会略有不同)。如果设备驱动程序直接与内核进行任何对话,我们正在处理中断、内存映射 I/O 或 DMA。老实说,我不知道它们是否可以在您的驱动程序的源文件中进行处理(在这种情况下您很好做),或者它们是否还需要修改源树中的其他文件。 Linux 内核模块编程指南 是此类内容的良好资源。
祝你好运
You're definitely going to have to put the driver source in the kernel source tree and update the makefile to include it. You can see how this works in steps 1.1 through 1.3 here.
If user-level software does any talking with the device driver it probably does it via system calls. Search through the source of the driver looking for
asmlinkage
if you find any of these then you're looking at adding some system calls. The remainder of the above document will explain how to set them up. You'll have to modify at least two files (and they might vary slightly depending on your kernel version).If the device driver does any talking with the kernel directly, we're dealing with Interrupts, Memory Mapped I/O, or DMA. To be honest with you I do not know whether they can be handled within the source file for your driver (in which case you're good do go), or whether they also require modifying other files in the source tree. The Linux Kernel Module Programming Guide is a good resource for such things.
Good Luck