易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

linux socket编程相关知识的总结

1:socket编程中采用的协议族主要有两种

   1>:网络协议族(形式如:AF_INET, PF_INET等)
   2>:本地unix域格式的协议族(形式如:AF_LOCAL, AF_UNIX等)
   注:协议族的选择体现在  int  socket(int domain, inst type, int protocol)函数的第一个参数处。
2:这两 ......

嵌入式Linux下常用的交叉编译方法


要在嵌入式Linux下使用动态语言,首先要解决的是语言解释器或执行引擎的交叉编译问题。
交叉编译通常有以下几种途径:
1. 直接通过交叉编译工具,手工配置交叉编译。交叉编译工具可以利用这个脚本来自动生成:
http://kegel.com/crosstool/
此方法的好处是简便快捷,一旦crosstool做好以后,需要什么包直接编译即可, ......

Linux 文件系统概述

Linux 文件系统概述
作者:北南南北
来自:LinuxSir.Org
摘要: 本文通过文件系统的定义说起,然后通过引文简单的介绍了一下文件系统类型;对Linux常用的ext2、ext3及reiserfs 根据本人使用经验也泛泛的谈了谈,但并不是专业的。如何阅读本文,还是用马克思理论告诉我们的方法:一分为二,边看边批吧;目录索引 一、什么 ......

linux nfs设置

使用过程中的心得:
一、解除目录映射关系
umount 目录可以解除关联关系
必须先在客户端umount,然后在服务器端停止nfs服务,以及修改/etc/exports,否则的话会导致df -h无法关闭
二、mount.nfs: Input/output error
解决:在客户端也需启动portmap
三、修改完毕/etc/exports文件之后,可以重启nfs服务,也可以使用exp ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号