android编译helloworld驱动

上传人:艾力 文档编号:35895732 上传时间:2018-03-22 格式:PDF 页数:4 大小:486.72KB
返回 下载 相关 举报
android编译helloworld驱动_第1页
第1页 / 共4页
android编译helloworld驱动_第2页
第2页 / 共4页
android编译helloworld驱动_第3页
第3页 / 共4页
android编译helloworld驱动_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《android编译helloworld驱动》由会员分享,可在线阅读,更多相关《android编译helloworld驱动(4页珍藏版)》请在金锄头文库上搜索。

1、1. 编译环境:编译环境: 虚拟机 Linux 64 位系统, 编译工具 arm-eabi-4.4.0.tgz, 内核: linux-3.1.10.tar.bz2 2. 为内核添加为内核添加 hello world 驱动并添加到驱动并添加到 menuconfig 菜单菜单 : a) 在在 drives 目录下添加目录下添加 hello 目录,内含目录,内含 hello.c Kconfig Makefile 文件文件 hello.c 内容如下:内容如下: #include #include MODULE_LICENSE(“Dual BSD/GPL“); static int hello_init

2、(void) printk(KERN_ALERT “Hello!This is LZ module test!n“); return 0; static void hello_exit(void) printk(KERN_ALERT “GoodBye!This is LZ module test!n“); module_init(hello_init); module_exit(hello_exit); Kconfig 内容如下:内容如下: # #This is module test by lz # config HELLO tristate “Helllo module test crea

3、ted by lz“ default n help test for adding driver to menuconfig Makefile 内容如下:内容如下: obj-$(CONFIG_HELLO) +=hello.o b) 通过给下通过给下面的面的 Kconfig 文件再加上下面的代码文件再加上下面的代码,可使,可使 hello 项出现在配置菜单中:项出现在配置菜单中: 在 arch/arm/Kconfig 文件中 menu “Device Drivers“ endmenu 之间添加 source “drivers/hello/Kconfig“(这个文件好像没有 menu “Devic

4、e Drivers“ endmenu,要自己写) 在 drivers/Kconfig 文件中 menu “Device Drivers“ endmenu 之间添加 source “drivers/hello/Kconfig“ c) 3.修改修改 Drivers 目录下的目录下的 Makefile 文件,添加如下文件,添加如下行:行: obj-$(CONFIG_HELLO) += hello/ 当 CONFIG_HELLO 为 y 或 m 时,使系统能找到 hello 驱动的 makefile。 以上过程完成便将 hello 模块添加至内核 menuconfig 菜单,注意格式与上下文保持一致注

5、意格式与上下文保持一致。 3. 编译方法:编译方法: a) 首先确定目标首先确定目标板参数:板参数: 首先确定目标板的芯片, 目标版的内核版本, 内核板后缀名。 以 samsung galaxy note 10.1 为例子,查到芯片是:Exynos 4412 处理器,内核版本 为:3.1.10,内核名为:3.1.10-1104619,其中-1104619 为后缀名。 b) Kernel 官网下载内核官网下载内核:linux-3.1.10.tar.bz2,解压至/usr/src/kernel。 c) 配 置 编 译 工 具配 置 编 译 工 具 : arm-eabi-4.4.0.tgz (见 附

6、 件)。 解 压 。 将 解 压 后 的 /usr/local/arm-eabi-4.4.0/bin 加入 PATH 路径。 可以通过修改/etc/profile 达到目的, 如下图:。修改重启后(不知是不是一定要重启) ,输入 arm-eabi-gcc v,如果出现下图则 配置成功。d) 编译内核编译内核: i. 因 为 目 标 板 的 芯 片 是Exynos 4412 , 首 先 将arch/arm/configs/ exynos4_defconfig 文件拷出来,成为我们所需要的.config 文件,命令如下:cp arch/arm/configs/ exynos4_defconfig

7、./.config。 ii. 修改 Makefile 文件:主要修改一下部分:使编译目标为 arm 平台,交叉编译 工具为 arm-eabi- iii. 执行 make menuconfig,主要做两个工作:修改后缀名,勾选 hello 模块。如下 图所示: (General setuplocal version-append to kernel release)后缀名改成:-1104619. (Device DriversHello module test created by lz)勾选 hello 模块 iv. 保存后,执行 make modules 编译模块。 v. 编译完毕后, 在 drivers/hello/文件中编译后所得 hello.ko 等文件。 放入目标板, 执行命令:insmod hello.ko;dmesg|grep LZ 便可以得到Hello!This is LZ module test!信息。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号