Add your own drivers to the Linux kernel files, add your own Linux drivers, compile your own Linux driver methods and sample graphics

Source: Internet
Author: User

This article is done original, reproduced please specify the source, respect for the original.

Writing this article, I refer to some blogs on the Internet:



Also refer to the "Linux driver development in detail" 3.4 chapters, to achieve the establishment of their own drive directory.

The driving example in this article is: Linux device Driver Development detailed second edition of global Mem Tow, Song Baohua Editor's book CD source

After we learned about Linux drivers, we all wanted to write a Linux driver to verify that we wrote the right, so how do we build our own drivers in the Linux kernel? How to add your own Linux driver? Let's try it out here:
Linux-kernel 2.6.28;
1. Enter your kernel source document and create a Donelin_driver folder to store your driver, so folder path: drivers/donelin_driver/:
2. Copy your example driver to the newly created Donelin_driver folder, my example name is GLOBAL_MEM_TWO.C:
3. In Create two new text files in the Donelin_driver folder: Kconfig and Makefile
4. Modify the Kconfig file under the Donelin_driver folder and enter the following:
Menu "Donelin-driver" comment "global_mem_two-driver" config global_mem_twotristate "Global_mem_two dritst"  Help This is global Mem 2test Programmingendmenu
5. Then modify another file of Donelin_driver makefile, enter the following:

obj-$ (config_global_mem_two)+ = global_mem_two.o
6. Modify the Kconfig file in the previous level directory (driver directory) and declare your own source code:
Under "menu" Device drivers, add the following:
SOURCE "Drivers/donelin_driver/kconfig" ##...add my TST Driver module
7. Modify Arch/arm/kconfig

Similarly, as in Driver/kconfig, add the same statement under "menu device Drivers":
SOURCE "Drivers/donelin_driver/kconfig"
That is: add source "Drivers/donelin_driver/kconfig" between arch/arm/kconfig menu "Device Drivers" Endmenu in Drivers/kconfig Add source "Drivers/hello/kconfig" between the menu "Device Drivers" Endmenu(I don't know why arch/arm/ Kconfig in the drivers contains a copy of Kconfig content, the experiment proves that only the changes in the Drivers/kconfig is invalid. )
8. Modify the makefile in the drivers directory, in the location, add:

obj-$ (config_global_mem_two)+ = donelin_driver/#ADD for test add_for_test the driver
8. All modified, saved well, back to the Linux kernel root, make menuconfig, the miracle appeared, my own Linux driver appears in the Kernel device drivers option:

Select Global_mem_tow_dritst to M, which means to compile into a module and compile into a KO file
Then, save the exit, make, make  zimage and make  modules to generate the new kernel and the new modules,
Finished, stop pen, write your own kernel driver passed, is not very cool?
GLOBAL_MEM_TWO.C is Song Baohua's book Linux device driver development in detail in the CD source, my other blog has, the address is:
Compile through, direct copy available

Add your own drivers to the Linux kernel files, add your own Linux drivers, compile your own Linux driver methods and sample graphics

Related Article

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: 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.