2012-03-02 55 views
0

编译模块,我创建make文件与外部工具链

obj-m += hello.o 

all: 
    make -C /home/developer/Desktop/xukr-20120201-omap3/linux-2.6.37-tn M=/home/developer/Desktop/module_test modules 

clean: 
    make -C /home/developer/Desktop/xukr-20120201-omap3/linux-2.6.37-tn M=/home/developer/Desktop/module_test clean 

然后,我发现了一个简单的hello程序

#define __KERNEL__   /* We're part of the kernel */ 
#define MODULE    /* Not a permanent part, though. */ 

/* Standard headers for LKMs */ 
#include <linux/modversions.h> 
#include <linux/module.h> 

#include <linux/tty.h>  /* console_print() interface */ 

/* Initialize the LKM */ 
int init_module() 
{ 
    console_print("Hello, world - this is the kernel speaking\n"); 
    /* More normal is printk(), but there's less that can go wrong with 
    console_print(), so let's start simple. 
    */ 

    /* If we return a non zero value, it means that 
    * init_module failed and the LKM can't be loaded 
    */ 
    return 0; 
} 


/* Cleanup - undo whatever init_module did */ 
void cleanup_module() 
{ 
    console_print("Short is the life of an LKM\n"); 
} 

,我试图在命令行编译此

make ARCH=arm CROSS_COMPILE=angstrom-linux-gnueabi- 

,我得到这个错误

/bin/sh: angstrom-linux-gnueabi-gcc: not found 

有什么不对呢?我真的很新。

由于提前,

+0

使用'$(MAKE)''不是一个'Makefile' – 2012-03-02 08:41:23

+0

不幸的是同样的错误里面make'。 – thehilmisu 2012-03-02 08:57:03

+0

在开始使用内核代码之前,您应该真正获得用户级Linux命令行实用程序和应用程序级Linux系统调用的流畅性。 – 2012-03-02 09:15:20

回答

0

你可以使用remake调试和理解你的Makefile。调用它作为remake -x -d它会给你很多的调试输出,而其他行为为GNU make

正如我所评论的,不要忘记在Makefile内使用$(MAKE)而不是make

关于错误:angstrom-linux-gnueabi-gcc: not found您需要在您的系统上安装适当的交叉编译器(和交叉链接器)工具链(或者适当地设置您的环境变量,以便找到它)。

这一切都不会解决你的问题,但会帮助你理解它