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