Build Android Kernel && Kernel Module

來源:互聯網
上載者:User

標籤:

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 be 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 be 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.