Linux Device Drivers ─
新增模組到Kernel中並客製化組態選單加入選項
1.選定模組資料夾
以“linux-2.6.21.x\drivers\char\hello\”為存放檔案的位置
2.編譯“linux-2.6.21.x\drivers\char\Kconfig”
在檔案中找個合適的地點插入以下字串,在此放在最下面的位置
#
# Character device configuration
#
menu "Character devices"
…
…
config EMIL_LDD
tristate "EMIL LDD example"
default m
endmenu
3.make menuconfig 進入到kernel配置頁面
Device Drivers ->
Character devices ->
<M> EMIL LDD example
可自行決定是要模組化,或是直接編譯進入到kernel中。
4.選擇完成後離開,並且開啟“linux-2.6.21.x\.config”確認剛選擇的選項已有寫入。
#
# Character devices
#
…
CONFIG_EMIL_LDD=m
5.編譯“linux-2.6.21.x\drivers\char\Makefile”加入下面這一行,這樣kernel在編譯時才會將hello模組加入。
obj-$(CONFIG_EMIL_LDD) += hello/
修改“linux-2.6.21.x\drivers\char\hello\Makefile”
obj-$(CONFIG_EMIL_LDD) := hello.o
6.接下來若要測試是否編譯完成只能更新kernel之後才能確定,建議可以找塊開發版來作測試。更新完後基本上都可以在
“/lib/modules/kernel版本/kernel/drivers/char/”中找到hello資料夾裡面就有編譯好的hello.ko。