Linux device driver arrangement (2)

Source: Internet
Author: User
Linux device driver arrangement (2) & quot; for the sake of interest, first use the tool & quot; to compile the makefile of the linux device driver. Java code www.2cto. comall: KERNELDIR? /Lib/modules/$ (shelluname-r)/buildPWD: $ (shellpwd) $ (... linux device driver arrangement (2) "profit first, profit first", and tidy up the makefile for compiling the linux device driver program. Java code www.2cto.com all: KERNELDIR? =/Lib/modules/$ (shell uname-r)/build PWD :=$ (shell pwd) $ (MAKE)-C $ (KERNELDIR) M =$ (PWD) modules clean: $ (MAKE)-C $ (KERNELDIR) M = $ (PWD) clean note: In the makefile file, the indent part must be a tab, it cannot be replaced by spaces. /Lib/modules/$ (shell uname-r)/build corresponds to the linux source code tree of the current compiling environment. Use uname-r to check whether the kernel version of the compiling environment is consistent with that of the target environment (that is, the operating system where the driver is to be installed. If they are different, install the linux source code tree consistent with the target environment. Otherwise, the compiled ko file cannot be loaded in the target environment because of its different vermagic values. Another method is to modify include/linux/utsrelease in the kernel source code tree. h (UTS_RELEASE macro) and include/linux/vermagic. VERMAGIC_STRING in h can also compile the ko with vermagic consistent with the target environment. Use modinfo MyLinuxDrv. ko on www.2cto.com to find its corresponding vermagic. Write a device driver code for MyLinuxDrv. c, and save the makefile script in the Makefile file in the same directory. Run make to compile the MyLinuxDrv. ko file. Execute make clean to clear the compiled MyLinuxDrv. ko file and intermediate target file (. o) for recompilation.

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.