[問題] build kernel module

作者: summerdog ( . 人 .)   2014-04-02 19:54:26
在進行android embedded system開發時
遇到了kernel module編譯的小問題, 還請各位指教, 謝謝!
Q1 :
假如我只想要單build kernel module ,
我需要完整的kernel source tree嗎?
還是只需要kernel source 的 header file package?
A1 :
有些部落格提到是下載整個kernel source tree,
然後還要把這個kernel source tree給build過一次 ...
可是我從國外網站查到的答案如下,
簡單來說就是不需要kernel source tree, 只需要kernel headers
請問各位是如何處理的呢 @@?
ref - http://ppt.cc/Tl91
In order to build a kernel module, we need the kernel headers
(or kernel source) that match the binary image.
The headers provide vital definitions that are needed
in order to compile the source code for the module.
The compressed source code is about 110MBytes in size.
This is the full source for the kernel including all of the headers.
Strictly speaking, we just need the headers, but you might want to
explore the kernel, other kernel modules, ARM-specific support code,
or the PERF subsystem. It’s all there.
ref - http://ppt.cc/Fuy8
To be frank you do not need a new full source tree in order to
just compile or build module against the running kernel
i.e an exploded source tree is not required to build kernel driver or module.
Please note that to work with this hack you just need the Linux kernel
headers
and not the full kernel source tree.
也就是說
通常下載的 kernel source code 會在 /usr/src/linux-xxx
/lib/modules/3.6.11+/build 這邊的build 會 ln 到 上面的位址
如果沒有 就手動建立link
ln -s /usr/src/linux /lib/modules/3.6.11+/build
note.
上面那個build你可以連到 kernel source header only
或 kernel full source
================================================================================
Q2.
一般我們build一個c程式, 在link 其他 library 時有兩種case:
a. standard c library , 這不需要特別指定路徑,
gcc 會去 /usr/include 找header ,
去 /usr/lib 找 libc.a libc.so
b. 3rd party library, 這就要指定
header file 及 library binary(*.a / *.so) 的位置
然而在build kernel module的時候,
怎沒看到需要去指定library的動作呢 ?
我的意思是, 自訂的 kernel module 中會include 到
platform.h init.h 之類非standard c 的 部份 ,
這些部份在build kernel module的時候是如何處理的?
文長請多包含 謝謝!
作者: leveler   2014-04-04 08:36:00
1.這要看你的module 是否能夠 out of tree compile2.kernel_src 變數指定

Links booklink

Contact Us: admin [ a t ] ucptt.com