How to implement the configuration of the device under Linux (on)

xiaoxiao2021-03-06  37

Lenovo (Beijing) computer company software engineer in August 2001

This article is

"How to implement the automatic detection of hardware under Linux" sister articles. Will introduce you to the device detection, after obtaining the driver, working parameters, etc. of the device, working parameters, etc., how to configure the correct configuration script, to generate the correct configuration script after the information is obtained by the device information file. .

The configuration process of the device under Linux refers to the use of this information to configure the driver, operating mode, etc. (see how the device's detection process "is used, and how to implement hardware under Linux. automatic detection"). To complete such a task, you need to do two work: First, a detailed device information file, this file describes the device ID, the device ID corresponding to the device, device configuration parameter (device option), device settings Detailed description, device configuration method description, the alias corresponding to the device, the main device number of the device, etc. The current Linux kernel uses KMOD to complete the automatic load of the device module, and its general working mechanism is: When the device module is first referenced, the kernel uses system command / sbin / modprobe to load this device module. In order to make this mechanism work normally, you first need to use DepMod -a to establish file modules.Dep between representation modules, and then set the correct device alias in /etc/modules.conf (About /etc/modules.conf) Detailed introduction See Appendix A of this article, if you need to set the parameters corresponding to the device. For example, in setting up a network card, the driver of the NE2K-PCI is NE2K-PCI. The device alias of the NIC is eth0, and the alias Alias ​​Eth0 NE2K-PCI is added in the file /etc/modules.conf, set the NE2000-compatible PCI network card. When the program is to try to access the network, the kernel will automatically load the NIC driver NE2K-PCI. Its second is to set the device corresponding script file for the installed Linux system version according to the type of device, and the installed Linux system (different Linux distributions for configuration script files for the same device). 1 Configuring Keyboard 1.1 Configuring the device module of the keyboard generally has three types for our common keyboard, which is an old-fashioned five-pin keyboard, which is a PS / 2 keyboard, and the third is a USB mouse. For the first two keyboards, the current Linux distribution will be packaged into the kernel, so there is no need to perform additional module insertion operations, the keyboard can work. For the USB type keyboard, in general, to make it properly working must first insert the corresponding device module. For the USB type keyboard, if you work by manually load the module, you must first insert the USB bridge module, then you must also insert the keyboard module USBKBD.O, and KeybDev.o, so the USB keyboard can work properly . At this time, the running system command: / sbin / modprobe usbkbd / sbin / modprobe keybdev For the 2.2.x series of kernel to automatically load automatically when the kernel is required, you must set an alias USB in the /etc/modules.conf file. Interface, it corresponds to the bridge module you are using. For example, when the type of bridge is UHCI, add the device alias in /etc/modules.conf: Alias ​​USB-Interface USB-UHCI For the 2.4.x series kernel, this device alias changes to: Alias ​​USB-Controller USB -uhci After setting this alias, USB device detection is automatically performed when the system starts. When the detection process finds a connection device is system support, the system will automatically insert the desired module. 1.2 Keyboard configuration file keyboard configuration file / etc / sysconfig / keyboard, its content is simple, optional configuration item is KeyTable (the content of this file will vary with the content of this file, but this field is the most important ).

For example, when setting KeyTable = "US", the system is represented using a American keyboard. Then, in order to correctly use the function keys on the keyboard, you also need to call the command dumpkeys to generate file /etc/sysconfig/console/default.kmap. / usr / bin / dumpkeys> /etc/sysconfig/console/default.kmap This file describes the keyboard scan code of the keyboard and the corresponding keyboard scanning code of the keyboard after the keyboard is added. Similarly, in order to operate normally in the X system environment, you may also need to set the keyboard under the X system, then you must use XModMap to set the correct keyboard mapping. For example, / usr / x11r6 / bin / xmodmap /usr/share/xmodmap/xmodmap.fr Sets your keyboard under your X system to the French keyboard. After the correctly configured / etc / sysconfig / keyboard file, the X system's configuration program is configured to configure X of the keyboard configuration in the information of this file. When this file is incorrect or this file does not exist, the X system is unable to start and configure. 2 Configuring the basic information of the mouse 2.1 LINUX supports four different bus mouse hardware interfaces: Inport (Microsoft), Logitech, PS / 2, and ATI-XL. 2.4 The kernel also supports the IBM PC110 digitizer and Apple Desktop mouse. Inport MiceInport Mice contains most old types of Microsoft mouse. Inport Mice is typically connected to the main board's interface card. If the mouse line connecting head is round, there are 9-pin, it may be inport mice. Logitech Mice PS / 2 Mice ATI Combo Video / Mice IBM PC110 Palmtop Digitizer Apple Desktop Mouse Hybrid Mice For mouse protocols, most bus mice use the BUSMOUSE protocol, some old logitech mouse use the MouseSystems protocol, and some older Microsoft mouse use Logitech protocol. The PS / 2 mouse always uses the PS / 2 protocol. Different types of mice corresponding device files:

Interface Type Equipment Main Equipment Memorial Number Logitech / DEV / LOGIBM100PS / 2 / DEV / PSAUX101Inport / DEV / InportBM102TI-XL / DEV / INPOM103USB MOUSE / DEV / INPUT / MICE1363 Table 2-1 Create a command for the corresponding device:

MKNOD / DEV / LOGIMM C 10 0

MKNOD / DEV / PSAUX C 10 1

MKNOD / DEV / InportBM C 10 2

MKNOD / DEV / ATIBM C 10 3

Mknod / dev / input / mice c 13 63

After creating the device file corresponding to the mouse, because many programs use / dev / mouse as the default mouse device file, in order to make the mouse normally you have to create a symbolic connection / dev / mouse point to true mouse devices file. For example, for PS / 2 mice, / dev / mouse points to / dev / psaux, for USB mouse, / dev / mouse / point / dev / input / mice, for serial mouse / dev / mouse points / dev / ttys0. For different Linux release, these files may vary, the above introduction is mainly based on the configuration of the RedHat release. For the three most common mice: serial mouse, PS / 2 mouse and USB mouse, because the PS / 2 mouse support is generally hit in the kernel, you don't need to insert the device module before the mouse work. But for other two mice, the operation of the insertion module is generally necessary. For serial mouse, you must first insert module serial.o, / sbin / modprobe serial successfully insert module, if serial mouse supports plug-and-play serial protocol, you can read from serial port (/ dev / ttys *) To the type information of the mouse, then this information is then completed the mouse configuration file. For USB mouse, in order to make it work properly, you must first insert module USBMouse.o and mouseDev.o / sbin / modprobe USBMOUSE / SBIN / MODPROBE MOUSEDEV, in order to make the mouse driver automatically load, you also need to be available / etc / Create a USB-Interface (USB-Controller) alias in the modules.conf file. 2.2 Mouse configuration file Correctly configure the mouse to generate a configuration file / etc / sysconfig / mouse, which includes the following options: MouseType, XMouseType, FullName, Xemu3, Device. The mouse configuration file is also the basis for the M Mouse configuration section in the X configuration file. If there is no file, many X configuration programs will not work. MouseType = Configure the type of mouse, including PS / 2, Busmouse, Imps2, NetMouse, Microsoft, Logitech, Mouseman, Mmhittab, MouseSystems, PNP, Logim, MS3, MMSeries, and so on. The type of mouse configured under xmousetype = x system, including Mouseman, Intellimouse, MMSeries, Mmhittab, Logitech, Mouseman, Microsoft, MouseSystems, PS / 2, BUSMOUSE, etc. FullName = Describes the full name of the mouse device. For example, for a normal PS / 2 mouse, its full name is PS / 2 | STANDARD. XEMU3 = Whether the three-button mouse is simulated, the optional parameter is YES or NO. Device = Describes the device file corresponding to the mouse. E.g. For ordinary PS / 2 mice, the device file is PSAUX. 2.3 Configuration Tips of the mouse can use the mouse in the command line mode via GPM. In this way, in the console mode, the mouse can be used to use the mouse. For example, for the PS / 2 mouse, its configuration is: gpm -t ps / 2 -m / dev / psaux If the -m option is not specified, then the system will look for files / dev / mouse. The mouse movement is not ruled because the mouse has an error. If the new Logitech mouse does not use the Logitech protocol, use the Microsoft Agreement (Mouseman). If your mouse moves irregular, then you may first need to try to replace the value specified by MouseTyPE (XMOUSETYPE).

Under the X system, you can perform XModMap -e "Pointer = 3 2 1" if you need to replace the left and right key of the mouse. 3 NIC configuration procedure 3.1 Configuring a network card device module According to the bus type, the current Ethernet card mainly has a PCI network card, an ISA network card, and a PCMCIA network card. To make these network cards working properly, set the device alias Eth0 in /etc/modules.conf, and the device parameters to be passed to the driver. This kernel is automatically loaded with the required device module using the kernel service KMOD using the system command ModProbe (Insmod) when using the driver. When configuring a network card, if this network card can be automatically detected, you only need to identify the device driver in the device description information file, and then configure a network card. However, this method is not suitable for the NE2000 compatible network card of the ordinary ISA bus, as they generally do not satisfy the ISAPNP specification when designing, so they cannot read their device information. However, this type of NIC usually uses NE as a device driver, but in order to make it properly operated, the IRQ of the IO address and the occupied IRQ are required. For example, for Ne2000 compatible ISA network cards, such as DE220X, their drivers are NE. At this point, this network card is working properly, you need to join in the /etc/modules.conf file: Alias ​​Eth0 Neoptions Ne IO = 0x300 IRQ = 5 Generally, for this network card, only the correct I / O address is specified Space, network card can work normally. This address is exactly the same as the port address used by this NIC under DOS. If you can't find the NIC on the port address 0x300, you can try 0x240 and other addresses. 3.2 NIC configuration files To properly configure the network card, you must generate the following script file, / etc / sysconfig / network, / etc / sysconfig / network-scripts / ifcfg-eth0 (multiple network cards for IFCFG-Eth1, IFCFG) For only one network card -TH2 pushes in this class) and / etc / hosts. If you need to configure a domain name resolution service, then generate file /etc/resolv.conf. For the / etc / sysconfig / network script file, the most commonly used setup items include Networking, Forward_IPv4, Hostname, DomainName, Gateway, GatewayDev. Note: This file is also set when there is no configured network card, so that the ring loop device (LO) of this unit can work normally, this device is the basis for many Linux internal communications. Networking = indicates whether the system uses the network, typically set to YES. If set to NO, the network cannot be used, and many system service programs will not be able to start. Forward_IPv4 = indicates whether IPv4 automatic forwarding is supported. Generally, this item is False when there is only one network card. Hostname = Sets the host name of this machine, where the host name set, and the host name set in / etc / hosts. DomainName = Sets the domain name of this unit. Gateway = Set the IP address of the gateway connected to the unit. For example, the gateway is 10.0.0.2 GatewayDev = When communicating with this gateway, the network card device alias used. For example, when a network card is used, the gateway is connected, the value at this time is Eth0. The setting is not available when there is no network card: networking = "yes"

Forward_IPv4 = "false" Hostname = "localhost.localdomain"

DomainName = "LocalDomain"

/ etc / sysconfig / network-scripts / ifcfg- * describes information about the network interface. Each different network interface corresponds to a different file. For example, IFCFG-ETH0 corresponds to configuration information that may occur in Eth0 of the first block. Common configuration options include Device, Bootproto, iPaddr, Netmask, Network, Broadcast, Onboot. Device = Describe the device alias corresponding to the network card, such as the file of IFCFG-ETH0 is Eth0. Bootproto = Set the network card to get the IP address, the possible options are static, DHCP, or BOOTP, respectively correspondingly specified IP addresses, and the IP address obtained by the BOOTP protocol, respectively, with the IP address obtained by the DHCP protocol. IPaddr = If the network card is set to get the IP address is static, this field specifies the IP address corresponding to the NIC. Netmask = network mask corresponding to the NIC. Network = network address corresponding to the network card. Broadcast = The corresponding subnet broadcast address. ONBOOT = Whether the system is set to set this network interface, when set to YES, the system is activated when the system is activated. /etc/resolv.conf, the system generates this file for domain name analysis. Otherwise, the reverse name of the installation process cannot work. Possible options: Search DomainName Specifies the domain name Nameserver DNSSERVER Domain Name Server, you can specify multiple. / etc / hosts, add the host name list to this file. 4 MODEM Configuration Process For Modem's configuration procedure, we now usually use KPPP to dial, using this program, the entire dialing process will become very simple. Therefore, this article will no longer introduce the manual dialing procedure using PPPD and CHAT. This article only describes how to set the basic device driver module and the configuration of the underlying device file. After configuring these files, you can use KPPP to dial. 4.1 External Modem When configuring an external Modem, because most of the modems are connected to the computer via the serial port, you must insert the serial driver module serial.o before configuring modem. After successfully inserting the serial communication module, you can connect the device / dev / modem to the appropriate serial port device. For example, the MODEM is connected to / dev / TTYS0 (corresponding to COM1 under Windows), establish a connection: ln -sf / dev / ttys0 / dev / modem After this, the external serial modem can work normally. You can detect and configure MODEM's working mode by sending an AT command to the serial port using Minicom. Regularly used commands:

AT Command Command Description ATDT (ATDP) Perform Dial ATZ Reset Modem ATH Suspension The ATI0 Returns the Status ATI1 ATI1 Execute the ROM Check and Check and Return Value ATI2 Verify the ROM verification, return OK or Errorati3 Return to ROM components Software version number. The ATI4 query the status information of the modem, including the baud rate, parity bit length, word length, dial mode, register status, etc. The ATI5 queries status information in the RAM of the modem. The ATI6 query the link status information of the modem, including the number of transmitted (received, lost) characters, the number of transmitted data blocks, the link connection state, the last dial time, and the like. ATI7 gets a preface file, this file described information includes: MODEM supported communication protocol, FAX version number, EPROM version number. ATI8 gets the connection time ATI9 obtains the description name table 4-1 for the modem, for example, for a Lenovo-echoleral ejaculation external Modem, after starting minicom, input ATI9 return value is: (1.0AKY1010ModeMaky101056k Data Fax Voice MODEM) FF 4.2 Built-in Linmodemlinmodem is a Linux implementation of WinModem. About further information about Linmodem You can access www.linmodems.org. The current LINMODEM is generally the PCI type, and you can also obtain the device device description information through the PCI detection process. After obtaining the description information, you can compare if your MODEM belongs to the Modem type listed below. The LINMODEM now supported includes: CONEXANT / ROCKWELL HSF its driver at http://www.olitec.com/pci56kv2.html or http://linmodems.org. The Ambient Technology (Formerly Cirrus Logic) driver is at http://linmodems.org/clmodem-0.3.0.tar.gz. Lucent LTHTTP: //LINMODEMS.ORG/LINUX568.ZIP PCTELPCI, AMR and ZOLTRIX PHANTOM type binary drivers: http://www.kcdata.com/~gromitkc/winmodem.html#drivers. ESS56T-PI (PCI) And ES56V-I (ISA) binary driver: ISA: ftp://ftp.sstech.com/pub/modem/isa/unsupported/56v-i/linux/kernel61/linux11.zip. PCI: ftp://ftp.sstech.com/pub/modem/pci/unsupported/56t-pi/linux/kernel61/111.zip. 3Com Mini-PCI has no available drivers. In order to some extent and the programming interface of the external modem, Linmodem is usually generated to generate an emulated serial device. In order to generate these device files, the command MKNOD can be usually used.

Lucent LT: MKNOD / DEV / TTYS14 C 62 78 PCTEL: MKNOD / DEV / TTYS15 C 62 79 Esscom: MKNOD / DEV / ESSCOM C 127 1. Esscom users want to connect to / dev / ttys14 to / dev / esscom to make only the PPP dial program that only identify TTYS * can be used normally. ChGRP UUCP / DEV / TTYS14CHMOD 666 / DEV / TTYS14 allows non-root users to use this service dial. Ln -s / dev / devicefile / dev / modem You can also use SetSerial, modify the serial port configuration, such as setting the boat rate of the serial port, can also set the operating parameters of the serial port. SetSerial -Agv / DEV / TTYS * 5 Sound Card Configuration Procedure 5.1 Configuration of Dermage Soundtrack Drivers Now is using the sound cards that are currently using primary PCI and ISA. Under the Linux system, the configuration process of both type sound cards is actually generating profile /etc/modules.conf, establishing the correct device alias and the correspondence of the sound card device driver. After the correct setting drive module, use the mixer program to set the output volume of the sound card. If your sound card is an ISA PNP type, then if this sound card works well under the DOS (Windows) system, you can remember the working parameters of the sound card, including IRQ, DMA, and I / O. In general, the same parameters as DOS should be used under Linux systems. If you don't know its working parameters, you can get the configuration space of the sound card via / proc / isapnp, including information such as DMA, IOOPORT, and IRQ. You can then you can learn free IRQs, IOPORTS, and DMA and other information in the system by checking / proc / interfaces, / proc / iports, and / proc / dma files, whereby the appropriate sound card configuration parameters can then be selected. In the 2.4.x kernel, ISA PNP support is implemented, and a part of the sound card driver now supports automatic detection and configuration without using the ISAPNP tool. For more information about sound card devices, you can also view files in core document / usr / src / linux / documentation / sound /. For PCI sound cards, their drivers contain automatic detection process, so you only need to insert the correct drive module, and the sound card will usually work. When the sound card module is first referenced, the kernel will request to load the corresponding drive module. The device alias corresponding to the sound card module is Sound-slot-0 (0 represents a sound card in the system, and push it). For example, add: Alias ​​Sound-Slot-0 EssoLO1 configured an Ess Solo-1 sound card. This statement indicates that the module Esssolo1 is automatically loaded when the sound card is required. Sometimes the device module corresponding to Sound-Slot-0 is loaded, and all the functions of the sound card cannot take effect. At this time, the device will request access to the Sound-Service-0-N alias. n represents different devices: The number of the device 0 mixer (Mixer) 2MIDI3, 4DSP Table 5-1 requires you to set the correct sound card service module, so that the sound card can work normally. Equipment file corresponding to sound card:

Device File Name Device Description / dev / audio Normal connection to / dev / audio0 / dev / audio0sun workstation compatible sound equipment (partially implementation, do not support the Sun IOCTL interface, only U-LAW code) / dev / audio1 second Sound equipment (using multiple sound cards) / DEV / DSP Normal connection to / dev / dsp0 / dev / dsp0 first digital sampling device / DEV / DSP1 second digital sampling device / dev / mixer connection to / dev / dev / Mixer0 / DEV / Mixer0 First Sound Mixer / DEV / MIXER1 Second Sound Mixer / DEV / MUSIC Advanced Serialization Interface / DEV / SEQUENCER Bottom MIDI, FM and GUS Access / DEV / SEQUENCER2 Normal connection To / dev / music / dev / midi00 first original MIDI port / dev / midi01 second original MIDI port / dev / midi02 third original MIDI port / dev / midi03 fourth original MIDI port / dev / sndstat display Sound Driver Status Table 5-2 PC Speaker Provides the following devices: / dev / pcaudio equivalent / dev / audio

/ DEV / PCSP equivalent / dev / dsp

/ dev / pcmixer equivalent / dev / mixer

You can send the sound file directly into the corresponding device, for example, the original sample can be sent to / dev / dsp by playing the .au sound file to play it in / dev / audio. Cat Sample.su> / dev / audio However, a PLAY command should be used when doing this. For WavPlay and VPlay (SND-Util Packages) will play WAV files with the best effect, but they cannot identify Microsoft ADPCM compressed WAV files. If you have a correct parameter, SPLAY is used to play most sound files. The sampling data returned by the read / dev / audio and / dev / dsp can be redirected to a file. VREC can make this process easier. You may need a mixer program to select the appropriate input device. 5.2 ALSA Sound Card Driver Configuration For the sound card driver, in addition to the drivers of the kernel, you can also use the drivers provided by Advanced Linux Sound Architecture (ALSA, http://www.alsa-project.org/) . It supports a series of mainstream sound cards, and it is compatible with the sound structure of the kernel. To some extent, it can be said to be supplemented by the kernel's sound card drive module. The general naming rule of the ALSA sound card driver is SND-CARD-

. SoundCard represents different types of sound cards. For example, for all 16-bit SoundBlaster sound cards, their corresponding driver modules are SND-CARD-SB16.

If you need two modules SND-PCM-OSS and SND-MIXER-OSS that are backward compatible with the Linux kernel sound drive. For multiple mixers set in Amixer, they are all for different devices. For example, the setting of the CD channel is for the CD player. And many applications, such as MPG123, XMMS, RealPlayer, depend on the setting of the PCM channel. MIC represents the microphone. Different GAIN parts provide special gains for different uses. By default, AlSA mutes all outputs. In order to get the sound, the main volume and the mute of the PCM volume must be released. Amixer -c 0 sset 'master', 0 100%, 100% unmuteamixer -c 0 sset 'pcm', 0 100% unmute option includes Mute, Unmute, Capture, Nocapture, REC, NOREC, NUM, or LEFT: RIGHT. Amixer returns the setting of all channels on the sound card without parameters. In order to open the mute every time you insert a sound card drive module, you can add the following footprints in /etc/modules.conf: Post-install snd-card-sb16 amixer -c 0 sset 'master', 0 100%, 100% Unmute && amixer -c 0 sset 'pcm', 0 100% unmute After successfully inserting the ALSA sound card module, the system will appear / proc / asseound directory, which describes the work of the sound card, and the created device file. After you load the SND-PCM-OSS device module, you can also use the sound card with the OSS-compatible way. At this time, the following mapping will be completed:

转载请注明原文地址:https://www.9cbs.com/read-66984.html

New Post(0)