Transferred from: http://blog.csdn.net/gatieme/article/details/49491325
Directory
1. Questions
2. Drive source Code
3. Kernel configuration
4. Compiling kernel and module drivers
5. Load Driver
Problem
These two days in order to do GPS and arm communication, have to tinker with this stuff. Development Board is Skyworth special JX2410,USB to the serial line of the chip is pl2303. Fortunately this chip, let me not a little effort, to achieve the purpose. Because Linux has supported it, we just need to compile and load the driver on it.
Drive source
Generally speaking, USB to serial port driver is integrated in the kernel, we do not need to download, only need to do some configuration at compile time.
So before compiling we need to confirm that there is no USB to serial port driver in our kernel.
USB to serial port driver is located under the kernel source code root directory/drivers/usb/serial
The main source code usb-serial.c
includes,option.c,pl2303.c
For different chips, there are cp210x.c
pl2303.c
For example, in our case, it ispl2303
Kernel configuration
Configuring with Make Menuconfig
The main configuration information is as follows
-->device Driver
-->usb support
-->USB Serial Converter Surpport
The relevant options.
usb generic serial driver
Selected
usb prolific 2303 single port serial driver
Paired with M.
The specific configuration is shown in
First open menuconfig
, go to the Device Drivers
Drive configuration page
Enter the usb support
USB drive Configuration page The main configuration information is as follows
usb support
Under
Select USB Serial Converter Surpport
the relevant options.
Select USB Serial Converter Surpport
and
usb generic serial driver
Finally select the corresponding chip, note that the choice is m, the driver compiled into a module, dynamic loading
Compiling kernel and driver modules
make zImage, make modules
make modules
Load Driver
Finally in the source directory pl2303.ko
is the driver we need, on the board directly insmod can
Problem:
1. USB Device Debug Command
LSUSB: List USB devices and properties, Lsusb-v can view detailed properties of the device
ls/dev/tty*: Check if the USB device has been loaded successfully
2. Make Dep/make module, Insmod/rmmod, depmode/modprobe Three specific usage of the group
Http://www.cnblogs.com/jacklikedogs/p/4659249.html
- This refers to the normal process of loading kernel drivers, first copy the *.ko file to/lib/module/' Uname-r '/kernel/driver/usb, followed by depmode-a build dependency, Update MODULE.DEP, last run modprobe load module
- Modprobe compared to insmod words, more intelligent, will be based on MODULE.DEP established module dependencies, arrange the loading order, if insmod may appear undefined symbol and other issues
- so in the load Pl2303.ko drive, as long as depmod-a, after using modprobe Pl2303.ko can, no need to have insmod Usb-serial.ko, Insmod Option.ko, Insmod Pl2303.ko and other operations
3. In addition to adding insmod in RC, how does the boot use modprobe automatically load the module?
- CP yourdrivername.ko/lib/modules/' uname-r '/kernel/drivers/misc
- Edit/lib/modules/' uname-r '/MODULES.DEP, set the association between drivers, add a line:/lib/modules/' uname-r '/kernel/drivers/misc/ Yourdrivername.ko, or the use of depmode-a should also be possible, the file will be kept, not with the power loss and disappear
- Edit/etc/rc.d/rc.local, add one line:/sbin/modprobe yourdrivername
4. Pl2303.ko and Option.ko, Usb-serial.ko copy to the/lib/modules/3.14.**/kernel/drivers/usb of the board, the system will automatically load the boot, do not need Insmod?
[drive] kernel add USB to serial port driver support