Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling a driver as a part of a kernel, not as a module

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.

like image 312
Rusty Horse Avatar asked Dec 07 '11 20:12

Rusty Horse


1 Answers

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

like image 99
MatrixManAtYrService Avatar answered Oct 30 '22 01:10

MatrixManAtYrService