【问题标题】:How to cross-compile external kernel modules whe the kernel build is out-of-tree?当内核构建在树外时如何交叉编译外部内核模块?
【发布时间】:2019-07-23 13:39:43
【问题描述】:

在 x86_64 主机上,我已经为树外的 ARM 目标交叉编译了 Linux 内核。所以我有两个目录:

  1. ~/kernel_git_repo/ - 仅包含内核源代码
  2. ~/kernel_buld_dir/ - 包含 .config 文件和构建的内核对象

在第三个目录中

  1. ~/external_module - 外部内核模块的源代码

我有一个外部模块的源代码,带有一个 Makefile。

树内构建内核的“常规”命令是:

make -C <path-to-compiled-src-code> M=$(PWD) modules

对于我的树外构建的内核,~/kernel_git_repo/ 和 ~/kernel_buld_dir/ 都不是&lt;path-to-compiled-src-code&gt;。似乎 make 命令需要both 带有 Kbuild 基础设施的内核源代码库 带有 .config 文件和对象的构建目录。

在这种情况下,在 ~/external_module/Makefile 中使用什么 make 命令来构建模块?

【问题讨论】:

  • 在使用make O=~/kernel_build_dir 构建内核时,您应该始终使用make -C ~/kernel_build_dir
  • 另外,您需要提供一段我在之前评论中描述的情况下发生的实际错误的摘录。

标签: kernel-module kbuild


【解决方案1】:

你是对的,本质上是一样的,

$(MAKE) -C  $(KDIR) SUBDIRS=$(shell pwd) modules

除了

KDIR=/path/to/kernel/source

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-28
    • 2020-08-15
    • 2014-10-23
    • 2014-01-25
    • 1970-01-01
    • 2014-05-01
    • 2014-04-30
    • 1970-01-01
    相关资源
    最近更新 更多