【问题标题】:Compiling module with external toolchain使用外部工具链编译模块
【发布时间】:2012-03-02 08:34:37
【问题描述】:

我创建了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

这有什么问题?我真的很陌生。

提前致谢,

【问题讨论】:

  • 在Makefile 中使用$(MAKE) 而不是make
  • 在开始处理内核代码之前,您确实应该熟练掌握用户级 Linux 命令行实用程序和应用程序级 Linux 系统调用。
  • 我解决了,谢谢。我添加了错误的工具链路径。现在,我添加了正确的,它起作用了。

标签: linux makefile arm toolchain


【解决方案1】:

您可以使用remake 来调试和理解您的Makefile。以remake -x -d 调用它,它将为您提供大量调试输出,而在其他方面则表现为GNU make。

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

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

所有这些都不能解决你的问题,但会帮助你理解它

【讨论】:

    猜你喜欢
    • 2017-07-02
    • 2020-10-30
    • 2017-11-07
    • 1970-01-01
    • 2020-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-04
    相关资源
    最近更新 更多