|
ubuntu上内核模块开发环境的架设
工作是Linux驱动开发,工作环境定为ubuntu7.10,主要是考虑到软件安装更新比较方便。 考虑到网速方面的因素,首先需要更改sources.list文件(位于/etc/apt/sources.list),将里面的软件网站改为ubuntu的中国镜像网站。可将以下文本替换掉sources.list里的内容(注意ubuntu的版本区别,要修改什么最好根据自己的实际情况到网上搜下,再进行修改)。deb http://ubuntu.cn99.com/ubuntu/ gutsy main restricted universe multiverse deb http://ubuntu.cn99.com/ubuntu/ gutsy-security main restricted universe multiverse deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted universe multiverse deb http://ubuntu.cn99.com/ubuntu/ gutsy-proposed main restricted universe multiverse deb http://ubuntu.cn99.com/ubuntu/ gutsy-backports main restricted universe multiverse deb-src http://ubuntu.cn99.com/ubuntu/ gutsy main restricted universe multiverse deb-src http://ubuntu.cn99.com/ubuntu/ gutsy-security main restricted universe multiverse deb-src http://ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted universe multiverse deb-src http://ubuntu.cn99.com/ubuntu/ gutsy-proposed main restricted universe multiverse deb-src http://ubuntu.cn99.com/ubuntu/ gutsy-backports main restricted universe multiverse
下载安装gcc、linux-headers sudo apt-get install gcc
sudo apt-get install linux-headers-$(uname -r)
立马写个最简单的helloworld应用程序,谁知编译不过,提示找不到stdio.h文件,上网搜下,如下可以解决 sudo apt-get install build-essential
再写一个最简单的helloworld内核模块,一运行 make -C /usr/src/linux-headers-$(uname -r) M=$(pwd) modules
接着很多出错信息出来了,不用仔细看,都知道缺少很多东西。再搜下,做法如下: sudo apt-get install modules-assistant
sudo m-a update
sudo m-a prepare
再次编译,现在可以通过了,得到helloworld.ko文件,再insmod helloworld.ko就可以了。
因为以后可能会编译内核,所以一并把需要的东西都装上了。
sudo aptitude install libqt3-headers libqt3-mt-dev libqt3-compat-headers libqt3-mt
这样就完成了Linux在X86平台的内核模块开发环境。而最终要移植到MIPS平台上,所以需要交叉编译工具。具体的设置待以后整理。
发表于: 2008-03-31,修改于: 2008-03-31 17:15,已浏览48次,有评论2条 推荐 投诉
网友评论 网友: sep 时间:2008-04-02 16:38:09 IP地址:210.21.125.★
交叉编译环境可以用以下两种方法。
一、用scratchbox建立交叉编译工具链。
二、用qemu虚拟出相应cpu体系的操作系统。
目前倾向于第二种方案。不过编译效率很低。估计内核编译等模块很大的工程就用交叉编译工具链编译了。
网友: sep 时间:2008-04-03 11:39:18 IP地址:210.21.125.★
发现一个巨快的sources list:
deb http://ftp.tw.debian.org/debian/ etch main
deb-src http://ftp.tw.debian.org/debian/ etch main
deb http://security.debian.org/ etch/updates main
deb-src http://security.debian.org/ etch/updates main
|