Android内核开发 adb远程调试内核模块

本文出处: http://blog.csdn.net/leytton/article/details/52733776

PS:关于内核模块如何编写编译,有空再补上

1、连接远程Android设备

D:\test>adb.exe connect 192.168.1.3
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
connected to 192.168.1.3:5555

连接本地Android模拟器

adb.exe connect 127.0.0.1:5554

进入Android shell模式

D:\test>adb.exe shell
root@android:/ #

2、建立目录并远程上传内核模块文件

建立目录,因为只读属性会失败,下面有解决方法。

root@android:/ # mkdir /llqqww

Ctrl+C退出Android shell,adb远程上传文件

D:\test>adb push word_count.ko /llqqww
332 KB/s (72176 bytes in 0.212s)

进入shell模式查看,文件上传成功

D:\test>adb.exe shell
root@android:/ # cd /llqqww
root@android:/ # ls
word_count.ko

mkdir failed for , Read-only file system的解决办法

先:adb shell 后:mount -o remount ,rw /

ro只读属性

3、加载模块

加载内核模块前没有"word_count"设备

root@android:/llqqww # ls /dev/ | grep word_count

没有相关日志消息

root@android:/llqqww # dmesg

加载内核模块后多了"word_count"设备

root@android:/llqqww # insmod word_count.ko
root@android:/llqqww # ls /dev/ | grep word_count
word_count

向设备输入数据

root@android:/llqqww # echo hello > /dev/word_count
root@android:/llqqww # cat /dev/word_count
hello
root@android:/llqqww # cat /dev/word_count

卸载内核模块

root@android:/llqqww # rmmod word_count.ko

有内核加载成功、内核模块读写和卸载的相关日志消息

root@android:/llqqww # dmesg
<4>[ 4954.270000] word_count init success!
<4>[ 5110.280000] count_write:write_count:6
<4>[ 5130.860000] read:read_count:6
<4>[ 5130.860000] read:read_count:0
<4>[ 5134.530000] read:read_count:0
<4>[ 5403.450000] word_count exit success!


转载于:https://www.cnblogs.com/leytton/p/8253300.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值