900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 编写Android的LKM(Linux Kernel Module)

编写Android的LKM(Linux Kernel Module)

时间:2019-07-12 10:46:41

相关推荐

编写Android的LKM(Linux Kernel Module)

默认的内核是不支持加载与卸载LKM的,所以在编译Android的Linux内核之前,需要配置下,

在Android的Linux内核的源代码,目录下,运行

$ make menuconfig

出现如下的图片:

另外,按向左键选择,卸载模块相关

注意:

如果用官方的模拟器内核或者没有进行以上的配置的话:

1 运行 insmod hello.ko 来加载模块的时候,会提示

insmod: init_module 'hello.ko' failed (Function not implemented)

2 而如果运行 rmmod hello.ko 来卸载模块的时候,会提示

rmmod: delete_module 'hello.ko" failed (errno 38)

当编译完andorid的内核后,重新编译我们的hello模块,然后用我们自己编译的内核启动模拟器:

$ emulator -avd AVD15 -kernel ~/android_source/kernel/common/arch/arm/boot/zImage -show-kernel

//其中

~/android_source/kernel/common/arch/arm/boot/zImage 是编译生成的内核的Image

//而 show-kernel 是为了显示系统的Log信息

操作如下:

1)加载与卸载LKM

2)内核的Log信息

参考:

1. /wiki/Android/Linux/ARMCrossCompileOnIntel#BuildaCustomModule

2 在 Android Emulator 中开发 LKM 程序

3 /p.handhelds.android.kernel/810

附件,本文的测试程序

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。