内核与驱动编译方法
驅動編譯有兩種方法:
1. 編譯到內核中
2. 編譯為獨立模塊
?
建立方法:
1)?在linux源碼樹的驅動目錄增加自己的驅動目錄,比如:現在新增一個網絡設備驅動
mkdir?linux_tree/drivers/net/poker_driver -p
cd?linux_tree/drivers/net/poker_driver
2) 編寫驅動源碼
vi??poker_drv_part1.c
vi??poker_drv_part2.c
vi??poker_drv_part3.c
3) 編寫源碼目錄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) 編寫源碼目錄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) 修改上級Kconfig
vi?linux_tree/drivers/net/Kconfig
source "drivers/net/poker_driver/Kconfig"
6) 修改上級Makefile
? vi?linux_tree/drivers/net/Makefile
obj-$(CONFIG_POKER_DRV) +=?poker_driver/
7) 配置內核
make menuconfig
Device Drivers ?--->
?[*] Network device support ?--->?
<>poker_driver?support
1. 編譯到內核中:
<*>poker_driver?support
linux_tree# make uImage
2. 編譯為獨立模塊
<M>poker_driver?support?
linux_tree# make modules
?
括號問題:
[] ? 可選項 * 空
<> 可選項?* M?空
Kconfig語法:
Makefile語法:
未完待續....
轉載于:https://www.cnblogs.com/pokerface/p/5780159.html
總結
- 上一篇: 让我们来了解一下:操作系统和平台相关性
- 下一篇: css3实现超出文本指定行数(指定文本长