1th Linux driver ___ to NFS Network file system

Source: Internet
Author: User

We have been testing our FIRST_DRV driver modules in the virtual machine Ubuntu environment before, but this is not our development direction, in the beginning of the study we avoid building too much environment, so we chose only in Ubuntu test drive.


Our model is:


[first_drv.c]-->[uses Ubuntu kernel source to compile]-->[first_drv.ko (can run on virtual machine)]-->


[Install into virtual machine]-->[Hello world!] -->[Uninstalling]-->[Goodbye World from a virtual machine ...]


But our ultimate goal is to run the driver on the arm microprocessor platform.


So we need to change to the following pattern:


[first_drv.c]-->[uses Arm-kernel kernel source to compile]-->[first_drv.ko (can run on Arm-kernel)]


- [install into Arm-kernel]-->[Hello world!] --[uninstall]-->[from Arm-kernel goodbye World ...]


Here we need to explain what is arm-kernel (this is my temporary name), the arm microprocessor we have developed is s3c2440, in s3c2440 external memory there is an area where the Linux kernel is running, and the code running in this memory area is called Uimage , this uimage is compiled in the virtual machine Ubuntu environment, based on what compiled it? According to the kernel source code, which kernel source? is the/work/kernel/linux-2.6.22.6 directory of the kernel source code.


We have to use this kernel source code to compile FIRST_DRV.C, then we must modify the makefile.


Open the Makefile we wrote in the/work/my_drivers/frist_drv/1th directory:


Kern_ver = $ (Shell uname-r) Kern_dir =/lib/modules/$ (kern_ver)/build#kern_dir =/work/kernel/linux-2.6.22.6all:make- C $ (kern_dir) m= ' pwd ' modules clean:make-c $ (kern_dir) m= ' pwd ' modules clean rm-rf modules.order obj-m + = first_drv.o



We commented on the/work/kernel/linux-2.6.22.6 path before, and now we uncomment it, and instead comment on the first two lines, the changes are as follows:


#KERN_VER = $ (Shell uname-r) #KERN_DIR =/lib/modules/$ (kern_ver)/buildkern_dir =/work/kernel/linux-2.6.22.6



Save the makefile, execute make, generate the latest First_drv.ko, and this First_drv.ko can be installed in the s3c2440 Linux kernel, why s3c2440 's Linux kernel endorses our First_ Where's Drv.ko? Because s3c2440 's Linux kernel itself is uimage, and this uimage itself is based on the/work/kernel/linux-2.6.22.6 directory of the kernel source code compiled, Uimage and First_ Drv.ko from the same s3c2440, the Linux kernel of course recognizes the First_drv driver module.


In this regard, I believe I have made it clear enough.


OK, we put this uimage in advance on the arm Development Board, the driver module has been generated, is now lying on the Ubuntu disk directory/work/my_drivers/frist_drv/1th/, the driver module first_ How can DRV be installed into the Linux kernel of the arm board?


We can't always add a keyboard to the arm Development Board, and then enter Insmod First_drv.ko?


In fact, we do this when developing drivers more:


Make a minimal root filesystem (path tentatively:/work/mini_fs) on the virtual machine, and make its image file (fs_mini.yaffs2), burn it to the Development Board, we connect the Development Board serial port to the computer, To the Development Board power, start the kernel, can be SECURECRT serial terminal to observe the output information of the core, the last meshing hook up the minimum root file system, the SECURECRT serial terminal on the input LS, CD and other commands to test the minimum root file system, It's basically the same as what we do in a virtual machine Ubuntu environment.


So what do you do to get the Linux kernel of the board to access the First_drv.ko in another system (virtual machine Ubuntu) disk directory?


A good way to do this is to access it over the network.


Now we have a minimal root filesystem in our development Board, similar to the Ubuntu file system, which is equivalent to its castrated version, we build the ko_file folder in the/work directory and then/work/my_drivers/frist_ The First_drv.ko in the drv/1th/directory is copied to the /work/ko_file/ directory.


We can then use NFS to hook First_drv.ko from the /work/ko_file/ directory in Ubuntu to the minimum root filesystem of the Development Board /MNT Directory, of course, is not a random directory can be directly connected to NFS, how to make the /work/ko_file/ directory is hooked up?


We are executing in the current/work/my_drivers/frist_drv/1th/directory: sudo vi/etc/exports, modified as follows:


#/etc/exports:the access Control list for filesystems which is exported# to NFS clients. See Exports (5). # Example for NFSv2 and nfsv3:#/srv/homes hostname1 (rw,sync,no_subtree_check) hostname2 (ro,sync,no_   Subtree_check) # # Example for nfsv4:#/srv/nfs4 gss/krb5i (rw,sync,fsid=0,crossmnt,no_subtree_check) #/srv/nfs4/homes gss/krb5i (Rw,sync,no_subtree_check) #/work/ko_file * (Rw,sync,no_root_squash)


Where line 11th is what we add, this configuration file will configure the contents of the/work/ko_file directory to be NFS-mounted.


Next, restart the NFS service, execute: sudo/etc/init.d/nfs-kernel-server restart


In this way we can hook up the contents of the /work/ko_file directory through the minimum root file system on the Development Board, and after the kernel boot is successful, the YFFS2 minimum root file system will be hooked up and the last line on the SECURECRT serial terminal is displayed:


Press Enter to activate the this console.


Enter the command line interface for the Linux entry.


Incidentally, the current network environment is this:


    1. The Windows computer receives the wireless signal of the router through the Wireless network card (my IP here is: 192.168.2.224);


    2. The Ubuntu virtual machine in Windows is connected via bridging mode (my IP here is: 192.168.2.110);


    3. Take a network cable, one end of the router's LAN port, a side to the Development Board (my IP Here is: 192.168.2.100).



Execute ifconfig eth0 192.168.2.100 (This is the IP address of the Development Board)


Then Ping 192.168.2.110 (this is the IP address of the Ubuntu virtual machine)


Final execution mount-t nfs-o nolock 192.168.2.110:/drv/ko_file /mnt


After the carriage return, if there is no abnormal, the description is mounted successfully.


Execute on SECURECRT serial terminal: LS/MNT


Printed the First_drv.ko


This indicates that the First_drv.ko in the /work/ko_file/ directory has been attached to the /mnt directory of the smallest root filesystem of the board, and this First_drv.ko is the First_drv.kothat we executed make generation in the /work/my_drivers/frist_drv/1th/ directory.




This article is from the "12253782" blog, please be sure to keep this source http://12263782.blog.51cto.com/12253782/1873412

1th Linux driver ___ to NFS Network file system

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.