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:socket编程中采用的协议族主要有两种
:
1>:网络协议族(形式如:AF_INET, PF_INET等)
2>:本地unix域格式的协议族(形式如:AF_LOCAL, AF_UNIX等)
注:协议族的选择体现在 int socket(int domain, inst type, int protocol)函数的第一个参数处。
2:这两 ......
由于工作需要现在开始从头学习linux,下面先记录amlogic openlinux安装步骤。(前提是安装了虚拟机)
Amlogic open linux 编译环境安装
一、gcc工具的安装
1、从Amlogic网站上下载gcc工具
在下面下载Index of /download/linux/gnutools
gnutools-arc2.2-p4-ubuntu-9.04-2010- ......
1. I/O Port
和硬件打交道离不开I/O Port,老的ISA设备经常是占用实际的I/O端口,在linux下,操作系统没有对I/O口屏蔽,也就是说,任何驱动程序都可对任意的I/O口操作,这样就很容易引起混乱。每个驱动程序应该自己避免误用端口。
有两个重要的kernel函数可 ......
1、修改kernel配置(linux os)
在linux下,终端---进入编译目录,执行make k.menuconfig,
在弹出的配置窗口里选择Device Drivers-----Amlogic Devices Driver-----Amlogic Display Driver-----setup logo和logo on osd0
2、图片转换(windows os)
a、打开BitmapDataGet.exe工具,选择32位。
b、选择加 ......
一、下载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 ......