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下使用动态语言,首先要解决的是语言解释器或执行引擎的交叉编译问题。
交叉编译通常有以下几种途径:
1. 直接通过交叉编译工具,手工配置交叉编译。交叉编译工具可以利用这个脚本来自动生成:
http://kegel.com/crosstool/
此方法的好处是简便快捷,一旦crosstool做好以后,需要什么包直接编译即可, ......
一、Uboot烧录
1、连接jtag、网线、串口
2、把tftpd32.exe放到uboot烧录的目录里
3、启动tftpd32.exe
4、启动ttermpro.exe
5、双击uboot.bat
6、等到窗口弹出来
8、在串口工具中
1、 执行print 命令,查看环境变量
2、执行setenv serverip 具体IP 地址,配置tftp server 的地址等
3、执行setenv loadaddr 8200000 ......
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、选择加 ......
brctl addbr br0
ifconfig br0
br0 MAC is 00:00:00:00:00:00
brctl addif br0 eth1 (eth1 is xx:xx:xx:xx:xx:33)
ifconfig br0
br0 MAC is xx:xx:xx:xx:xx:33 same as eth1, auto change
brctl addif br0 eth2 (eth2 is xx:xx:xx:xx:xx:30)
ifconfig br0
br0 MAC is xx:xx:xx:xx:xx:30 sa ......
使用过程中的心得:
一、解除目录映射关系
umount 目录可以解除关联关系
必须先在客户端umount,然后在服务器端停止nfs服务,以及修改/etc/exports,否则的话会导致df -h无法关闭
二、mount.nfs: Input/output error
解决:在客户端也需启动portmap
三、修改完毕/etc/exports文件之后,可以重启nfs服务,也可以使用exp ......