Linux's simplest driver authoring and testing process

Source: Internet
Author: User

This article uses the NFS Mount network file system, manually create the device node,

Dynamic loading of driver modules is a great benefit to understanding the driver writing process!

First, the primary driver implementation process:


1. Write the makefile file, which contains the script that compiles the application into the app file, compiles the driver into the Mydrv.ko file.

2. Execute sudo make in Ubuntu

3. Ensure that the Mydrv.ko and app are copied to the/modules directory of the NFS mounted root filesystem

4. Create the device node in the module (execute in the Development Board file system shown in the serial software)
Mknod/dev/dcx-drv C 250 0

4.1, the implementation of Ls/dev
See if there is a device dcx-drv, there is ok

5. Installing the module equipment
Insmod/modules/mydrv.ko

5.1, execute cat/proc/devices (the device in this file is generated by the driver)
See if there are "dcx-drv" and there is OK

6, implementation./modules/app
Observe if the kernel module you created has been executed, OK

Second, the code changes need to recompile, after completion of the execution:

1. Delete the original module:
Rmmod/modules/mydrv

2. Install the new module:
Insmod/modules/mydrv.ko

3. Execute the application:

./modules/app

Iii. makefile file used in this paper


Obj-m + = MYDRV.O

Kernel_dir =/opt/03.kernel_transplant/android-kernel-samsung-dev
GCC = ARM-LINUX-GCC
All
Make-c $ (kernel_dir) m= ' pwd ' modules #编译驱动程序
$ (GCC)-wall app.c-o app #编译应用程序

CP./mydrv.ko/mini_rootfs/modules
CP./app/mini_rootfs/modules

#clean:
Rm-rf./*.o
Rm-rf./*.order
Rm-rf./*.symvers
Rm-rf./*.mod.c


Linux's simplest driver authoring and testing process

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.