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