Introduction to USB hardware driver in Linux

Source: Internet
Author: User
Article Title: introduces the USB hardware device driver in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

USB stands for "Universal Serial Bus", meaning "Universal Serial Bus ". It was proposed jointly by Compaq (Compaq), DEC, IBM, Intel, NEC, Microsoft, and Northern Telecom (Northern Telecom) in November 1994, the main purpose is to solve the drawbacks of too many interface standards. USB uses a 4-pin connector as the standard connector to connect all peripherals in the form of chrysanthemum petals. It transmits data in serial mode. Currently, the maximum data transmission rate is 12 Mbps, supports concurrent operations on multiple data streams and multiple devices, and supports hot swapping of peripherals.

At present, although the USB interface has only developed 2 generations (USB 1.1/, USB), USB integrates all the advantages of a multi-platform standard-including cost reduction and compatibility increase, A large number of external devices can be connected, combining advanced features and quality. It gradually became a PC interface standard and entered a period of rapid development.

Correctly supporting and configuring common USB devices for Linux is an essential step.

  Related technical basics

Module (driver)

A module is a program running in the kernel space. It is actually a target object file and cannot be run independently without links. However, it can be loaded into the system and run as part of the kernel, in this way, the kernel functions can be dynamically expanded. The main use of the module is to implement the device driver.

In Linux, a hardware driver can be directly loaded into the kernel code. When the kernel is started, the hardware device can be driven. The other is to compile a. o file in the module mode. When the application needs to be added to the kernel space for running. Therefore, a hardware driver usually refers to a driver module.

Device Files

For a device, it can have a corresponding logical device node under/dev. This node exists as a file, but it is not a file in the general sense. It is a device file, more specifically, it is a device node. This node is created using the mknod command, which specifies the master device number and secondary device number. The primary device number indicates a certain type of device, which generally corresponds to a specific driver. The secondary device number generally distinguishes different attributes, such as different usage methods, locations, and operations. This device number is obtained from the/proc/devices file. Therefore, the device node is in the directory only when the driver is in the kernel. The main function of this device number (especially the main device number) is to declare the driver used by the device. Drivers correspond to device numbers one by one. When you open a device file, the operating system knows the driver corresponding to the device.

SCSI Device

SCSI is a standard computer interface different from IDE. Nowadays, most flat-board scanners, CD-R recorders, MO optical transceiver and so on gradually tend to use the SCSI interface, coupled with SCSI and can provide a high-speed transmission channel, so, access to SCSI devices more and more users. Linux supports many SCSI devices, such as SCSI hard drives, SCSI optical drives, and SCSI tape drives. More importantly, Linux provides an IDE device for SCSI simulation (ide-scsi.o module), we usually simulate the IDE optical drive for SCSI optical drive access. In Linux, many software can only operate the SCSI Optical Drive. For example, most of the recording software and some media playing software. Generally, our USB storage device simulates access to the SCSI hard disk.

Linux hardware driver architecture

For a hardware, the Linux driver is like this: first, we must provide a. o driver module File (Here we only describe the module mode, in fact, the kernel mode is similar ). To use this driver, first load and run it (insmod *. o ). In this way, the driver will register with the system based on its own type (character device type or block device type, for example, the mouse is a character device and the hard disk is a block device, after successful registration, the system will return a primary device number, which is the unique identifier of the system, the main device we see with ls-l/dev/had must be 3 ). The driver creates a device file that is generally placed in the/dev directory based on the master device number (mknod command is used to create it, it must use the master device Number Parameter ). To access this hardware, you can run open, read, write, and other commands on the device file. The driver will receive the corresponding read and write operations and proceed according to the corresponding functions in its module.

There are also a few more related things: one is the/lib/modules/2.4.XX Directory, which is the module for the current kernel version. As long as your module dependency is correct (you can set it through depmod), you can load it using the modprobe command without knowing the location of the specific module File. The other is the/etc/modules. conf file, which defines aliases of some common devices. The system can find the driver module correctly when this device is needed. For example, alias eth0 e100 indicates that the driver module of the first Nic is e100.o. Their relationship diagram is as follows:


  Configure a USB device

[1] [2] [3] [4] Next page

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