2010-04-19

android kernel module building and installation

1. download android source (the platform) with repo
    - checkout the official tutorial
    - the toolchain is in mydroid/prebuilt, we need it
2. download android kernel: common.git (this is out of the platform)
     - a simple git will work
3. compile kernel
    2. enable loadable modules for the kernel: kerneltrap.org/node/16607
    3. make and get the kernel in arch/arm/boot
4. make your module by setting KDIR to common.git
   - do not forget to set ARCH=arm CROSS_COMPILE=xxxx
   - say your module is foo.ko
5. start the android emulator
   - download the sdk, and make tools in your path
   - create avd (android list targets to make sure which target to choose)
   - emulator -avd youravd -kernel your/path/common.git/arch/arm/boot/zImage -show-kernel 
     - append -show-kernel to know what's going on
   - now, see the window?
6. cd to your kernel module folder, and upload foo.ko to the emulator
   - adb push foo.ko /data
      - do not push to /, it's read-only
7. install the module
    - adb shell
    - cd /data
    - insmod foo.ko
      # check the terminal where you starts the emulator, see something related to foo.ko?


 

没有评论: