开发者

Embedded linux driver load-up

开发者 https://www.devze.com 2023-03-27 06:27 出处:网络
I\'m developing a device driver for embedded linux(ARM). How can I compile the KO file generated as a part of the kernel,

I'm developing a device driver for embedded linux(ARM). How can I compile the KO file generated as a part of the kernel, in a way that the module will be loaded in boot ?

this is the first time I need to compile the driver into the kernel an开发者_开发技巧d not as a loadable module. so I'm not sure how to do it.

Thanks, Ramon.


For your first question, I assume that you want to build your driver statically into the kernel image(not as a module). First, you select a directory in drivers directory where you want to put your driver files. Assume you want to put your files in drivers/char/. Copy your files into this directory. There will be a Kconfig file in the drivers/char/ directory, open it and add an entry like this in the before the endmenu.

config MYDRIVER
    bool "This is a driver for something"
    default n
    help
      This is a test driver.

Save the file and open Makefile in the same directory. Goto end of the file and add the following entry.

     obj-$(CONFIG_MYDRIVER)            += mydriver.o

That's it you have added the file to the kernel tree. Now, as usual, do make menuconfig and select MYDRIVER.

See this Kernel Compilation article for more info.


You need to build your device driver as a built-in. You can either edit your kernel .config file manually and change "=m" to "=y" for the CONFIG option that belongs to your module, or use make menuconfig to change <M> to <*> for your device driver.

before -> <M> Your Device Driver Name Here
after  -> <*> Your Device Driver Name Here
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号