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

I am trying to create minimalistic Linux for an embedded device. This means compiling the kernel and drivers. One driver is written directly for the device board by the creator, so it is not a repository. It can be compiled as a kernel module.

However, due to the immutable nature of Linux and the requirement for extremely low memory usage, I do not want to use modules. I want all drivers to be embedded in the kernel. And all the drivers equipped with the kernel, I installed in this way.

So my problem is how to compile this special driver for the kernel?

All search queries did not provide me with a solution - all of them are intended only for compilation in the form of modules.

Thanks for any help.

+6
source share
1 answer

You will definitely have to put the driver source in the source tree of the kernel and update the makefile to include it. You can see how this works in steps 1.1 to 1.3 here .

If user-level software talks to a device driver, it probably does this through system calls. Look for a driver source that is looking for asmlinkage , if you find any of them, then you are looking at adding some system calls. The rest of the above document will explain how to set them up. You will need to modify at least two files (and they may vary slightly depending on the version of your kernel).

If the device driver directly talks to the kernel, we are dealing with interrupts, I / O memory, or DMA. Honestly, I do not know if they can be processed in the source file for your driver (in this case you will do it well), or whether they also require changing other files in the source tree. This is a good resource for such things.

Luck

+5
source

Source: https://habr.com/ru/post/903329/


All Articles