I Build Android Kernel (with Module enabled)
1. Kernel source is under Android_src/kernel folder
2. Config file is under kernel_src/arch/arm/configs folder Xxx_deconfig
3. Setup Config:
$make Arch=arm Cross_compile=arm-eabi-xxx_defconfig
(. config file can also is created from device:
ADB pull proc/config.gz
Zcat config.gz >. config
)
4. Enable module:
$make Arch=arm Cross_compile=arm-eabi-modules_prepare
5. Build Kernel:
$make arch=arm cross_compile=arm-eabi--JX
[Error in compiling kernel:]
[Error1:]
Drivers/scsi/ufs/ufs_test.c:25:19:fatal error:. /sd.h:no such file or directory
#include < /sd.h>
Solution:
---kernel2/drivers/scsi/ufs/ufs_test.c 2014-09-18 14:37:07.000000000 +0800
+ + + kernel/drivers/scsi/ufs/ufs_test.c 2014-11-02 10:18:05.282973816 +0800
@@ -22,7 +22,7 @@
#include <scsi/scsi_device.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_host.h>
-#include < /sd.h>
+ #include ". /sd.h "
#include "Ufshcd.h"
#include "Ufs.h"
[Error2:]
In file included from drivers/video/msm/mdss/mdss_mdp_trace.h:260:0,
From drivers/video/msm/mdss/mdss_mdp.c:61:
Include/trace/define_trace.h:79:43:fatal error:./mdss_mdp_trace.h:no such file or directory
#include Trace_include (trace_include_file)
Solution:
---kernel2/drivers/video/msm/mdss/mdss_mdp_trace.h 2014-09-18 14:37:12.000000000 +0800
+++kernel/drivers/video/msm/mdss/mdss_mdp_trace.h 2014-11-02 10:31:53.000000000 +0800
@@ -17,7 +17,7 @@
#undef Trace_system
#define Trace_system MDSS
#undef Trace_include_path
-#define Trace_include_path.
+ #define Trace_include_path. /.. /.. /.. /drivers/video/msm/mdss
#undef Trace_include_file
#define Trace_include_file Mdss_mdp_trace
II Build Module 1. Makefile:
VERSION = 3
Patchlevel = 10
Sublevel = 40
Extraversion =-xxxxxx
Extra_cflags=-fno-pic
Obj-m + = XXXX.O
Kdir=src_to_android_src/source/kernel
PWD: = $ (shell pwd)
Ccpath: = Src_to_ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
Default
Make-c $ (Kdir) Arch=arm cross_compile=$ (Ccpath)/arm-linux-androideabi-subdirs=$ (PWD) modules
Clean
Make-c $ (Kdir) Arch=arm cross_compile=$ (Ccpath)/arm-linux-androideabi-subdirs=$ (PWD) Clean
2. VERSION in Makefile:
Kernel version can found using the following command
$ adb shell
$ cat/proc/version
3. After build, adb push ... ko/sdcard/; ADB shell; Insmode ... ko
DMESG See log
Reference:
[1] Https://github.com/marco-pratesi/android/blob/master/HOWTOs/Android-Build-Kernel-Modules-HOWTO.txt
[2] http://forum.xda-developers.com/showthread.php?t=1585289
[3] Http://forum.xda-developers.com/note-4/snapdragon-dev/sm-n910f-twrp-2-8-1-0-t2923509/page3
[4] https://www.movzio.com/howto/compile-android-kernel-source-beginners-guide-2/
[5] http://forum.xda-developers.com/showthread.php?t=1236576
Build Android Kernel && Kernel Module