最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

the hello driver no output

工作和技术 crifan 1247浏览 0评论

problem:

no output for hello driver.

reason maybe:

——————————————————————————-

4.卸载驱动模块:rmmod hello.

加载模块后就可在屏幕上看到如下信息:Hello world enter.

卸载时就可在屏幕上看到如下信息:hello world exit.

有的执行的时候竟然什么也没有,既没有报错,也没有任何输出

这时你可以在/var/log/messages这个文件中看到以上输出信息(使用cat /var/log/messages一般在最下面几行)。

那么怎么才能在屏幕上打印出这些信息呢?

这时你必须对源文件做如下修改:

<1> 将"printk(KERN_ALERT "Hello World enter!n");”一句中的“KERN_ALERT”换成"KERN_EMERG"以提高内核打印的优先级(0);

<2> 同理将printk(KERN_ALERT "Hello world exit!n");改成printk(KERN_ALERT "Hello world exit!n");

重新编译,加载,你就可在屏幕上看到输出信息了。

文章出处:http://www.diybl.com/course/6_system/linux/Linuxjs/2008727/134024.html

——————————————————————————-

need to be checked. after test, the above method is still not work, still can not see the output in terminal, but can see output in /var/log/kern.log :

——————————————————————————-

Feb 26 23:50:20 ubuntu810 kernel: [ 418.549708] Hello, world
Feb 26 23:50:38 ubuntu810 kernel: [ 435.637320] Goodbye, cruel world

——————————————————————————-

转载请注明:在路上 » the hello driver no output

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.145 seconds, using 22.09MB memory