by Chih-Wei Huang (cwhuang) 2009/07/13
OverviewThe Android build system doesn't compile kernel on-fly. It just contains a prebuilt kernel binary which will be added to the target image. This approach may be good enough for the arm emulator target, but not suitable for x86 platforms. The x86 platforms have various hardware. The kernel binary and its modules may need to be adjusted at compile time or runtime.This article describes an extra feature of the build system of android-x86 project. That is, the ability to build kernel and modules by a predefined or customized config during the building process. Compile kernel for Android-x86Prepare the source treeWe have modify the Android build system to compile a kernel image on-fly. You need to use our repository to get this feature. Read the article GetSourceCode for details. Build the default kernelThe prebuilt kernel binary for x86 target is removed. Instead, we put a default config for android-x86 in kernel/arch/x86/configs/. To build a kernel image from this config, run $ make iso_img TARGET_PRODUCT=eeepcBy specifying the TARGET_PRODUCT to eeepc, the build system automatically selects the config android-x86_defconfig to compile the kernel binary and its modules. The binary will finally be generated in out/target/product/eeepc/kernel, and the modules is put under out/target/product/eeepc/system/lib/modules/. The final target out/target/product/eeepc/eeepc.iso will contain the kernel binary and its modules. If you just want to build the kernel rather than the iso, replace the target iso_img by kernel. Build a customized kernelSuppose you already have a workable kernel config for you hardware, it's easy to tell the build system to use your config to build the iso. Just put your config file to kernel/arch/x86/configs/, and run (suppose the name of your config is my_defconfig) $ make iso_img TARGET_PRODUCT=eeepc TARGET_KERNEL_CONFIG=my_defconfigUse a prebuilt kernelIf you have a workable prebuilt kernel binary for your hardware, you can generate the iso with it: $ make iso_img TARGET_PRODUCT=eeepc TARGET_PREBUILT_KERNEL=<path to the prebuilt kernel>Compile kernel for ARMThe kernel build system can also be used to compile kernel for ARM. For example, to compile kernel 2.6.29 for the goldfish CPU of the arm emulator, run $ cd kernel The kernel binary will be generated in out/target/product/generic/kernel. Set TARGET_NO_KERNEL to be empty is important, otherwise the kernel building steps will be skipped. |