Compile Linux Kernel Modules
我正在学习写linux device driver for embedded system.
我有一个linux嵌入式设备,也有这个设备的linux源代码。也有cross compiler tool chain.
第一步,就是写一个简单的hello模块,然后装到设备中。以验证我这个开发环境。
在网上搜索了一下, how to cross compile linux device driver
发现在linux代码根目录的Makefile中有关于cross compile的描述
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
#
# When performing cross compilation for other architectures ARCH shall be set
# to the target architecture. (See arch/* for the possibilities).
# ARCH can be set during invocation of make:
# make ARCH=ia64
# Another way is to have ARCH set in the environment.
# The default ARCH is the host where make is executed.
# CROSS_COMPILE specify the prefix used for all executables used
# during compilation. Only gcc and related bin-utils executables
# are prefixed with $(CROSS_COMPILE).
# CROSS_COMPILE can be set on the command line
# make CROSS_COMPILE=ia64-linux-
# Alternatively CROSS_COMPILE can be set in the environment.
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
只要指定ARCH和CROSS_COMPILE就可以了。
在我的这个Makefile中,已经指定了ARCH=arm,CROSS_COMPILE=arm-linux-
因为在编译module的时候,使用的是内核构造系统,也就是使用的上面所说的这个在内核源码根目录的Makefile。所以我就不需要在我调用make的命令行中指定ARCH和CROSS_COMPILE了。
用来测试的hello模块的源码来自 http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html
hello.c
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void
相关文档:
1、总结背景
在linux系统下,如果你下载并安装了应用程序,很有可能在键入它的名称时出现“command not
found”的提示内容。如果每次都到安装目标文件夹内,找到可执行文件来进行操作就太繁琐了。这涉及到环境变量PATH的设置问题,而PATH的设置也
是在linux下定制环境变量的一个组成部分。本案例基于RedHat ......
在安装完jdk以后,就来安装MyEclipse了。
有一些安装了jdk以后没有生效,出现的还是1.4版本的。
所以安装MyEclipse7.0或者是6.5、6.6的都会出错
[root@gupt aaaa]# ll
总用量 380
dr-xr-xr-x 6 root root 4096
2009-01-17 configuration
-r--r--r-- 1 root root 7 ......
一、下载jpeg库
二、配置编译,生成Makefile文件。
#./configure --prefix=/usr/arm/arm-linux --exec-prefix=/usr/arm/arm-linux \
--enable-shared --enable-static
注意:prefix是最后安装时库存放的文件,shared是编译成动态库,static是编译成静态库
三、修改生成的Makefile。
使用gedit Makefile
将CC ......
使用过程中的心得:
一、解除目录映射关系
umount 目录可以解除关联关系
必须先在客户端umount,然后在服务器端停止nfs服务,以及修改/etc/exports,否则的话会导致df -h无法关闭
二、mount.nfs: Input/output error
解决:在客户端也需启动portmap
三、修改完毕/etc/exports文件之后,可以重启nfs服务,也可以使用exp ......