Compile kernel module "Go" in high-pass platform Android Environment

Source: Internet
Author: User

This article was reproduced from: http://blog.xeonxu.info/blog/2012/12/04/zai-gao-tong-ping-tai-androidhuan-jing-xia-bian-yi-nei-he-mo-kuai/

The Linux kernel in the Qualcomm Android Environment is compiled as part of Android, and you can use make to do it all at once from the beginning to the end. For some platforms such as Marvell, the kernel compiles relatively independently and must be compiled separately using standard kernel compilation commands. In general, the use of high-pass this way to compare the fool, a step to the end of the feeling, and use Marvell Way user intervention more, more flexibility. Of course, this is not to compare their merits and demerits, for me, these two ways are different. In the case of specific problems, it is sometimes more convenient to compile the kernel independently, such as compiling kernel modules.

The kernel must be compiled before the kernel module is compiled, and the kernel configuration must be specified before the kernel can be compiled. In the case of a self-compiled kernel, once the kernel has been compiled, you can use   directly, make module   to compile the kernel modules, and if the corresponding module files are modified, the same command can be used to compile incrementally quickly. In the high-pass environment, the kernel compilation process has been integrated into the Android compilation, so each time the kernel or kernel module is compiled, it must be enabled through the Android compilation environment. While Android provides such things as   make bootimage   commands, you can compile only bootimage related content, but Android's huge compilation system also takes a lot of time to initialize. The previous time when debugging a separate kernel module has been plagued by this problem, each time you modify the module code must pass   make bootimage   to compile. Although there is only one file, each compilation costs at least 1min30sec, which seriously affects the progress of the development. To do this, refer to the kernel modules independently compiled makefile and the environment features of Android write a kernel module compiled makefile.

123456789-ten-19                    about 
# Author:zhiqiang.xu# email: [Email protected]Cross_arch:=ARCH=armCross_compile="$ (arm_eabi_toolchain)/arm-eabi-"Kdir:=$ (android_product_out)/obj/kernel_obj/Pwd:=$ (shellPwd)Obj-m:= MY_MODULE.O. Phony:modules Package CleanAll:packageModules@if["$ (android_build_top) _yes"="_yes"];ThenEcho"You had to run \". Build/envsetup.sh\ "to init enviroment first. \nand then you had to run\ "Choosecombo\" to setup the project. "&&Exit 1;Fi@if[!-D$ (Kdir)];ThenEcho "Build Kernle first." &&cd $ (Android_build_top&&make bootimage&&cd-; fi $ (Make) $ (Cross_arch)-C $ (Kdir) m=$ (pwd< Span class= "K") Modulespackage:modules @mkdir-P. Package @cp $ (Obj-m:.o=.koclean: RM-RF *.o *~ core depend. *.cmd *.ko *.mod.c. Tmp_versions *. Order *.symvers Package             

The makefile by default compiles the files in the current directory my_module.c into kernel modules. At the same time, at compile time, the Android environment is forced to check if it is properly configured, and if it is not configured, it will be prompted to exit the compilation process. The kernel configuration used when compiling the module is the kernel configuration configured by the specified project when compiling Android. If the kernel has not yet been compiled, the kernel body is compiled automatically before the module is compiled. If everything is OK, only the modified module files will be compiled at a time. When compiled, the module files are copied separately to the directory in the current directory for package ease of use.

With this compilation script, the module is much more efficient to write debugging, at least every time the compilation module can be done within 5sec. Coupled with on-machine test debugging, can also be completed within 30SEC. Life is precious, be a lazy man like me.

Compile kernel module "Go" in high-pass platform Android Environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.