為Android內核添加新驅動
時間:2017-01-06作者:華清遠見
為Android內核添加新驅動,并提供menuconfig選項 為Android的Linux內核2.6.35添加驅動。 1. 在drives目錄下添加hello目錄,內含hello.c Kconfig Makefile
hello.c內容:
static int hello_init(void)
printk(KERN_ALERT"Goodbye, world\n");
module_init(hello_init);
Kconfig內容: 2. 上面的Kconfig文件再加上下面的兩個配置,可使hello項出現在配置菜單中。
在arch/arm/Kconfig menu "Device Drivers" endmenu之間添加:
在drivers/Kconfig menu "Device Drivers" endmenu之間添加:
3.修改Drivers目錄下的Makefile文件,添加如下行: linux-2.6.35目錄下make menuconfig,在Device Drivers菜單下選中Hello Driver added by Farsight項比如M,作為module。然后保存配置,執行make命令,就可以看到 CC [M] drivers/hello/hello.o 的log了,hello目錄里生成了hello.o hello.ko的等文件。
發表評論
|