内核与驱动编译方法
驅(qū)動(dòng)編譯有兩種方法:
1. 編譯到內(nèi)核中
2. 編譯為獨(dú)立模塊
?
建立方法:
1)?在linux源碼樹(shù)的驅(qū)動(dòng)目錄增加自己的驅(qū)動(dòng)目錄,比如:現(xiàn)在新增一個(gè)網(wǎng)絡(luò)設(shè)備驅(qū)動(dòng)
mkdir?linux_tree/drivers/net/poker_driver -p
cd?linux_tree/drivers/net/poker_driver
2) 編寫(xiě)驅(qū)動(dòng)源碼
vi??poker_drv_part1.c
vi??poker_drv_part2.c
vi??poker_drv_part3.c
3) 編寫(xiě)源碼目錄Kconfig
vi Kconfig
config?POKER_DRV
tristate "poker_driver support"
default n
---help---
If you say Y here, the kernel will support poker_driver.
If you say M here, the kernel not support poker_driver, must perform "insmod poker_driver.ko".
If you say N here, the kernel not support?poker_driver.
4) 編寫(xiě)源碼目錄Makefile
vi Makefile
obj-$(CONFIG_POKER_DRV) += poker_drv.o
poker_drv-objs += poker_drv_part1.o poker_drv_part2.o poker_drv_part3.o
5) 修改上級(jí)Kconfig
vi?linux_tree/drivers/net/Kconfig
source "drivers/net/poker_driver/Kconfig"
6) 修改上級(jí)Makefile
? vi?linux_tree/drivers/net/Makefile
obj-$(CONFIG_POKER_DRV) +=?poker_driver/
7) 配置內(nèi)核
make menuconfig
Device Drivers ?--->
?[*] Network device support ?--->?
<>poker_driver?support
1. 編譯到內(nèi)核中:
<*>poker_driver?support
linux_tree# make uImage
2. 編譯為獨(dú)立模塊
<M>poker_driver?support?
linux_tree# make modules
?
括號(hào)問(wèn)題:
[] ? 可選項(xiàng) * 空
<> 可選項(xiàng)?* M?空
Kconfig語(yǔ)法:
Makefile語(yǔ)法:
未完待續(xù)....
轉(zhuǎn)載于:https://www.cnblogs.com/pokerface/p/5780159.html
總結(jié)
- 上一篇: 让我们来了解一下:操作系统和平台相关性
- 下一篇: c#事件的应用