ubuntu下使用qemu模拟ARM(六)------驱动程序编译进内核方法
2017-02-02 11:35
477 查看
有两种方法可以编译自己写的驱动程序。
第一种方法:加入单个文件到驱动目录下
1.将helloworld_nodir.c的驱动源文件拷到/qemu_arm/linux-kernel/linux-3.16.39/drivers/char目录下
2.修改/qemu_arm/linux-kernel/linux-3.16.39/drivers/char/Kconfig文件.
打开Kconfig在 source "drivers/tty/Kconfig"后添加以下信息:
config HELLO_WORLD_NODIR
tristate "hello world no dir "
default y
help
It test how to add module to kernel
If unsure, it is safe to say Y.
3.修改此驱动目录下的Makefile文件,加入对驱动源码的编译:
obj-$(CONFIG_HELLO_WORLD_NODIR) += helloworld_nodir.o
4.make menuconfig
Device Drivers --->
Character devices --->
<*> hello world no dir
5. 编译内核即可。
第二种方法:在驱动目录下建立新的目录
1.新建一个目录如下:
/qemu_arm/linux-kernel/linux-3.16.39/drivers/char/helloworld
2.将文件helloworld_dir.c拷到/qemu_arm/linux-kernel/linux-3.16.39/drivers/char/helloworld文件夹下面
3.在hellowrold目录下面建一个文件, Kconfig,注意K要大写
4.在文件中输入如下内容:
menu "Hello World new dir"
config HELLO_WORLD_DIR
tristate "hello world new dir"
default n
help
It test how to add module to kernel
If unsure, it is safe to say Y.
endmenu
5.在hellowrold目录下面建一个文件,Makefile并写入如下内容
obj-$(CONFIG_HELLO_WORLD_DIR) += helloworld_dir.o
6.修改hellowrold上级目录char里的Makefile文件
增加:obj-$(CONFIG_HELLO_WORLD_DIR) += helloworld/
6、修改hellowrold上级目录char里的Kconfig文件
增加:source "drivers/char/helloworld/Kconfig"
7。make menuconfig
Device Drivers --->
Character devices --->
Hello World new dir --->
<M> hello world new dir
8.编译内核
参考文章:
http://blog.csdn.net/u011164819/article/details/49998597 http://www.linuxidc.com/Linux/2015-05/118021.htm http://www.cnblogs.com/hnrainll/archive/2011/06/22/2087569.html
第一种方法:加入单个文件到驱动目录下
1.将helloworld_nodir.c的驱动源文件拷到/qemu_arm/linux-kernel/linux-3.16.39/drivers/char目录下
2.修改/qemu_arm/linux-kernel/linux-3.16.39/drivers/char/Kconfig文件.
打开Kconfig在 source "drivers/tty/Kconfig"后添加以下信息:
config HELLO_WORLD_NODIR
tristate "hello world no dir "
default y
help
It test how to add module to kernel
If unsure, it is safe to say Y.
3.修改此驱动目录下的Makefile文件,加入对驱动源码的编译:
obj-$(CONFIG_HELLO_WORLD_NODIR) += helloworld_nodir.o
4.make menuconfig
Device Drivers --->
Character devices --->
<*> hello world no dir
5. 编译内核即可。
第二种方法:在驱动目录下建立新的目录
1.新建一个目录如下:
/qemu_arm/linux-kernel/linux-3.16.39/drivers/char/helloworld
2.将文件helloworld_dir.c拷到/qemu_arm/linux-kernel/linux-3.16.39/drivers/char/helloworld文件夹下面
3.在hellowrold目录下面建一个文件, Kconfig,注意K要大写
4.在文件中输入如下内容:
menu "Hello World new dir"
config HELLO_WORLD_DIR
tristate "hello world new dir"
default n
help
It test how to add module to kernel
If unsure, it is safe to say Y.
endmenu
5.在hellowrold目录下面建一个文件,Makefile并写入如下内容
obj-$(CONFIG_HELLO_WORLD_DIR) += helloworld_dir.o
6.修改hellowrold上级目录char里的Makefile文件
增加:obj-$(CONFIG_HELLO_WORLD_DIR) += helloworld/
6、修改hellowrold上级目录char里的Kconfig文件
增加:source "drivers/char/helloworld/Kconfig"
7。make menuconfig
Device Drivers --->
Character devices --->
Hello World new dir --->
<M> hello world new dir
8.编译内核
参考文章:
http://blog.csdn.net/u011164819/article/details/49998597 http://www.linuxidc.com/Linux/2015-05/118021.htm http://www.cnblogs.com/hnrainll/archive/2011/06/22/2087569.html
相关文章推荐
- ubuntu下使用qemu模拟ARM(二)-------编译u-boot
- ubuntu下使用qemu模拟ARM(七)-----uboot从sd卡启动内核
- ubuntu下使用qemu模拟ARM(六)------驱动程序
- UBUNTU下使用QEMU模拟ARM
- Qemu-ARM-Ubuntu 实验二 Linux内核编译
- ubuntu编译安卓内核时arm-eabi-gcc :命令未找到的解决方法
- Ubuntu14.04使用QEMU模拟ARM平台开发环境
- ubuntu下使用qemu-system-arm模拟arm环境
- ubuntu下使用qemu模拟ARM(五)-------应用程序Hello World
- ubuntu下使用qemu-system-arm模拟arm环境
- ubuntu下使用qemu-system-arm模拟arm环境
- 在Ubuntu 7.10下编译使用新内核的方法[转]
- ubuntu下使用qemu-arm-static进入chroot编译环境
- 使用arm-linux-gcc 4.3.2编译必须启用内核中的Use the ARM EABI选项
- 使用arm-linux-gcc 4.3.2编译必须启用内核中的Use the ARM EABI选项
- Ubuntu12.04下建立交叉编译环境、使用QEMU模拟Cortex-A9、QEMU运行uboot
- Ubuntu12.10 内核源码外编译 linux模块--编译驱动模块的基本方法
- Vmware在ubuntu feisty 2.6.20内核下编译出错的解决方法
- 编译、裁剪、安装、删除 Ubuntu内核和模块管理 分类: arm-linux-Ubuntu 2013-07-22 16:29 319人阅读 评论(0) 收藏
- 内核子系统或设备驱动可以直接编译到内核,也可以编译成模块,如果编译到内核,可以使用前一节介绍的方法通过内核启动参数来向它们传递参数,如果编译成模块,则可以通过命令行在插入模块时传递参数,或者在运行时,