[教学] ubuntu 2.6.22 内核树建立
-
- 帖子: 92
- 注册时间: 2008-04-01 0:10
Re: [教学] ubuntu 2.6.22 内核树建立
謝謝,如果將源代碼移植到ARM中,嘗試過嗎?樓主
-
- 帖子: 12
- 注册时间: 2008-01-06 10:38
Re: [教学] ubuntu 2.6.22 内核树建立
作个记号,明天接着看
-
- 帖子: 46
- 注册时间: 2007-12-27 20:50
Re: [教学] ubuntu 2.6.22 内核树建立
printk 是内核的调用接口,它在系统init之前,把消息写往控制台,但是一旦系统init之后,便改写到系统的日志中。
这样做的好处不言而喻的,如果内核在任何的时候都可以写信息到控制台,那控制台一定会被这样的信息淹没,而无法工作。printk的实现很简单,就是在有了日志消息后,首先申请控制台的信号量,如果申请到,则调用控制台写方法,写控制台。当linux初始化完成的时候,会在init之前打开控制台,此后,printk便无法申请到信号量,而把消息组织为skb发往特定的netlink缓冲区,由klogd读出,写向/var/log /messages文件中。
这样做的好处不言而喻的,如果内核在任何的时候都可以写信息到控制台,那控制台一定会被这样的信息淹没,而无法工作。printk的实现很简单,就是在有了日志消息后,首先申请控制台的信号量,如果申请到,则调用控制台写方法,写控制台。当linux初始化完成的时候,会在init之前打开控制台,此后,printk便无法申请到信号量,而把消息组织为skb发往特定的netlink缓冲区,由klogd读出,写向/var/log /messages文件中。
- happy115
- 帖子: 12
- 注册时间: 2007-07-12 11:49
Re: [教学] ubuntu 2.6.22 内核树建立
Thank you DDDDDDDDDDDD
-
- 帖子: 12
- 注册时间: 2008-07-05 11:12
Re: [教学] ubuntu 2.6.22 内核树建立
看过你的文章了。
你所说的在超级终端上没有看到打印的信息,是因为驱动程序一般将打印信息直接发送到缓冲区和/var/log/messages文件中,
所以在超级终端上不能显示打印信息。
不过我们可以自己用命令来看,可以用
dmesg
或是
cat /var/log/messages
你所说的在超级终端上没有看到打印的信息,是因为驱动程序一般将打印信息直接发送到缓冲区和/var/log/messages文件中,
所以在超级终端上不能显示打印信息。
不过我们可以自己用命令来看,可以用
dmesg
或是
cat /var/log/messages
-
- 帖子: 13
- 注册时间: 2007-01-31 18:20
Re: [教学] ubuntu 2.6.22 内核树建立
留个记号学习之
-
- 帖子: 27
- 注册时间: 2008-11-19 9:07
Re: [教学] ubuntu 2.6.22 内核树建立
支持楼主分享。
-
- 帖子: 4
- 注册时间: 2008-11-25 16:25
Re:
和楼上的一样。。haichuan2127 写了:haibo@arasor:~$ make
make -C /lib/modules/2.6.23.14/build M=/home/haibo modules
make[1]: Entering directory `/usr/src/linux-2.6.23.14'
Makefile:1498: ..tmp_kallsyms1.o.cmd: Permission denied
Makefile:1498: ..tmp_kallsyms2.o.cmd: Permission denied
Makefile:1498: ..tmp_vmlinux1.cmd: Permission denied
Makefile:1498: ..tmp_vmlinux2.cmd: Permission denied
Makefile:1498: .vmlinux.cmd: Permission denied
Makefile:1498: .vmlinux.o.cmd: Permission denied
ERROR: Kernel configuration is invalid.
include/linux/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
make[2]: stat: include/config/auto.conf: Permission denied
CC [M] /home/haibo/hello.o
cc1: error: ./include/linux/autoconf.h: Permission denied
In file included from include/linux/prefetch.h:14,
from include/linux/list.h:8,
from include/linux/module.h:9,
from /home/haibo/hello.c:2:
include/asm/processor.h:83: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
include/asm/processor.h:83: error: requested alignment is not a constant
In file included from include/linux/slab_def.h:44,
from include/linux/slab.h:120,
from include/linux/percpu.h:5,
from include/asm/desc.h:11,
from include/asm/elf.h:50,
from include/linux/elf.h:7,
from include/linux/module.h:14,
from /home/haibo/hello.c:2:
include/linux/kmalloc_sizes.h:5:5: warning: "CONFIG_X86_L1_CACHE_SHIFT" is not defined
include/linux/kmalloc_sizes.h:9:5: warning: "CONFIG_X86_L1_CACHE_SHIFT" is not defined
In file included from include/linux/module.h:20,
from /home/haibo/hello.c:2:
include/asm/module.h:64:2: error: #error unknown processor family
make[2]: *** [/home/haibo/hello.o] Error 1
make[1]: *** [_module_/home/haibo] Error 2
make[1]: Leaving directory `/usr/src/linux-2.6.23.14'
make: *** [modules] Error 2
我在make时遇到这样的问题,请楼主和高手帮忙解决 在此非常感谢!!!!!!!!!
那么你需要安装一个软件包build-essential,输入如下命令:
apt-get install build-essential
今天下午解决了这个问题。
-
- 帖子: 4
- 注册时间: 2008-11-25 16:25
Re: 我的内核搞不定
linux-header-2.6.22-14-generic是ubuntu的源码。linfeng41 写了:我的也是linux-header-2.6.22-14-generic,但是按照楼主的方式编译后的内核是2.6.22.9的。而且,我在编译linux设备驱动程序三中的源代码时,总是出错,不知道为什么?
还有就是我的内核编译完之后,在lib/modules 下有两个文件,分别是2.6.22-14-generic和2.6.22.9,这是怎么回事呢?
建立内核树的应该用2.6.22.9
为什么我就不知道。
-
- 帖子: 229
- 注册时间: 2007-07-14 22:39
Re: [教学] ubuntu 2.6.22 内核树建立
有几个疑问:
1.xconfig(必须有GTK环境吧)。好象是qt
2.执行结束之后,会在/lib/modules下生成新的目录/lib/modules/2.6.22-14-generic/
这个是本来就有的吧。应该是2.6.22,就是你新编译的。
3.代码部分用代码格式标出就好了。
1.xconfig(必须有GTK环境吧)。好象是qt
2.执行结束之后,会在/lib/modules下生成新的目录/lib/modules/2.6.22-14-generic/
这个是本来就有的吧。应该是2.6.22,就是你新编译的。
3.代码部分用代码格式标出就好了。
-
- 帖子: 6
- 注册时间: 2008-11-01 17:51
Re: [教学] ubuntu 2.6.22 内核树建立
为什么加载不了呀,如下:
root@xxs-desktop:~/program# ls
hello.c Makefile
root@xxs-desktop:~/program# make
make -C /lib/modules/2.6.27.10/build M=/root/program modules
make[1]: 正在进入目录 `/usr/src/linux-source-2.6.27'
CC [M] /root/program/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/program/hello.mod.o
LD [M] /root/program/hello.ko
make[1]:正在离开目录 `/usr/src/linux-source-2.6.27'
root@xxs-desktop:~/program# ls -l
总用量 152
-rw-r--r-- 1 root root 298 2009-01-06 14:07 hello.c
-rw-r--r-- 1 root root 62914 2009-01-06 14:09 hello.ko
-rw-r--r-- 1 root root 690 2009-01-06 14:09 hello.mod.c
-rw-r--r-- 1 root root 36176 2009-01-06 14:09 hello.mod.o
-rw-r--r-- 1 root root 27712 2009-01-06 14:09 hello.o
-rw-r--r-- 1 root root 193 2009-01-06 14:07 Makefile
-rw-r--r-- 1 root root 291 2009-01-06 14:09 Module.markers
-rw-r--r-- 1 root root 30 2009-01-06 14:09 modules.order
-rw-r--r-- 1 root root 0 2009-01-06 14:09 Module.symvers
root@xxs-desktop:~/program# insmod ./hello.ko
insmod: error inserting './hello.ko': -1 Invalid module format
root@xxs-desktop:~/program#
root@xxs-desktop:~/program# ls
hello.c Makefile
root@xxs-desktop:~/program# make
make -C /lib/modules/2.6.27.10/build M=/root/program modules
make[1]: 正在进入目录 `/usr/src/linux-source-2.6.27'
CC [M] /root/program/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/program/hello.mod.o
LD [M] /root/program/hello.ko
make[1]:正在离开目录 `/usr/src/linux-source-2.6.27'
root@xxs-desktop:~/program# ls -l
总用量 152
-rw-r--r-- 1 root root 298 2009-01-06 14:07 hello.c
-rw-r--r-- 1 root root 62914 2009-01-06 14:09 hello.ko
-rw-r--r-- 1 root root 690 2009-01-06 14:09 hello.mod.c
-rw-r--r-- 1 root root 36176 2009-01-06 14:09 hello.mod.o
-rw-r--r-- 1 root root 27712 2009-01-06 14:09 hello.o
-rw-r--r-- 1 root root 193 2009-01-06 14:07 Makefile
-rw-r--r-- 1 root root 291 2009-01-06 14:09 Module.markers
-rw-r--r-- 1 root root 30 2009-01-06 14:09 modules.order
-rw-r--r-- 1 root root 0 2009-01-06 14:09 Module.symvers
root@xxs-desktop:~/program# insmod ./hello.ko
insmod: error inserting './hello.ko': -1 Invalid module format
root@xxs-desktop:~/program#
-
- 帖子: 6
- 注册时间: 2008-11-01 17:51
Re: [教学] ubuntu 2.6.22 内核树建立
加载成功了,
root@xxs-desktop:~/program# insmod ./hello.ko
root@xxs-desktop:~/program# lsmod|grep hello
hello 9344 0
root@xxs-desktop:~/program# rmmod hello
root@xxs-desktop:~/program# cat/var/log/syslog|grep world
bash: cat/var/log/syslog: 没有该文件或目录
root@xxs-desktop:~/program# cat /var/log/syslog|grep world
Jan 6 15:55:51 xxs-desktop kernel: [ 8503.681629] Hello, world
Jan 6 16:01:08 xxs-desktop kernel: [ 8820.817939] Goodbye, cruel world
Jan 6 16:02:22 xxs-desktop kernel: [ 8894.541033] Hello, world
Jan 6 16:03:10 xxs-desktop kernel: [ 8942.234040] Goodbye, cruel world
root@xxs-desktop:~/program# uname -r
2.6.27-7-generic
root@xxs-desktop:~/program#
原来是编译模块的内核与运行的内核版本不匹配,我把Makefile中的 KERNELDIR 的值改回编译前的版本 /lib/modules/2.6.27-7-generic/build 就可以了。可问题又来了,为什么编译后 uname -r 还是原来的内核版本呢,为什么不是我新下的2.6.27.10呢,编译过程没出问题呀

root@xxs-desktop:~/program# insmod ./hello.ko
root@xxs-desktop:~/program# lsmod|grep hello
hello 9344 0
root@xxs-desktop:~/program# rmmod hello
root@xxs-desktop:~/program# cat/var/log/syslog|grep world
bash: cat/var/log/syslog: 没有该文件或目录
root@xxs-desktop:~/program# cat /var/log/syslog|grep world
Jan 6 15:55:51 xxs-desktop kernel: [ 8503.681629] Hello, world
Jan 6 16:01:08 xxs-desktop kernel: [ 8820.817939] Goodbye, cruel world
Jan 6 16:02:22 xxs-desktop kernel: [ 8894.541033] Hello, world
Jan 6 16:03:10 xxs-desktop kernel: [ 8942.234040] Goodbye, cruel world
root@xxs-desktop:~/program# uname -r
2.6.27-7-generic
root@xxs-desktop:~/program#
原来是编译模块的内核与运行的内核版本不匹配,我把Makefile中的 KERNELDIR 的值改回编译前的版本 /lib/modules/2.6.27-7-generic/build 就可以了。可问题又来了,为什么编译后 uname -r 还是原来的内核版本呢,为什么不是我新下的2.6.27.10呢,编译过程没出问题呀
-
- 帖子: 1
- 注册时间: 2009-01-19 1:17
Re: [教学] ubuntu 2.6.22 内核树建立
不能在终端上输出消息的原因可看看这里:
《Linux Device Drivers》的原文:
According to the mechanism your system uses to deliver the message lines, your out-
put may be different. In particular, the previous screen dump was taken from a text
console; if you are running insmod and rmmod from a terminal emulator running
under the window system, you won’t see anything on your screen. The message goes
to one of the system log files, such as /var/log/messages .
《Linux Device Drivers》的原文:
According to the mechanism your system uses to deliver the message lines, your out-
put may be different. In particular, the previous screen dump was taken from a text
console; if you are running insmod and rmmod from a terminal emulator running
under the window system, you won’t see anything on your screen. The message goes
to one of the system log files, such as /var/log/messages .
-
- 帖子: 1
- 注册时间: 2009-02-13 15:40
Re: [教学] ubuntu 2.6.22 内核树建立
太好了,谢谢