主要就是编写了驱动模块Helloko(hello.c 、Makefile) & 测试应用程序(hellotest.c)
hello.c:
makefile:
hellotest.c:
step1: make 先生成ko文件
step2: insmod ko模块 ,但没有出现初始化打印,很奇怪,应为printk的打印等级比较高,KERN_ALERT,但终端没有出现打印。所以不知道确认有没有执行成功,但我发现有一个dmesg,可以打印。
说明驱动初始化正常
step3: 查看proc/devices
cat proc/devices 字符设备里的
step4:挂载成设备点 mknod /dev/hellodev c 200 0
step5:编译hellotest,执行hellotest,发现报错 can't open!
原来权限不够,打开hellodev读写权限,再次运行,查看
至此成功。