Use mdev in busybox and configure mdev. conf rules

Source: Internet
Author: User

Mdev is the udev Lite version in busybox and is suitable for managing devices in embedded systems.

Mdev dynamically creates all devices under the/dev/directory. For example, if some programs use the device name under the dev directory subdirectory, You need to modify the program, of course, you can also manually create a directory after mdev runs and then create the ln link.

Here someone has made a better script processing mechanism:

Http://lists.busybox.net/pipermail/busybox/2007-May/027309.html


Paste the mdev instructions

-------------------------------------------

Mdev entry (for details)

Busybox-1.7.0/docs/mdev.txt
Tekkamanninja mail: tekkamanninja@163.com-1-

-------------
Mdev Primer
Mdev entry
-------------
For those of us who know how to use mdev, a primer might seem lame.
This document may seem superficial to those who know how to use mdev.
Everyone else, mdev is a weird black box that they hear is awesome, but can't
But for others, mdev may be a mysterious black box, and even awesome.
Seem to get their head around how it works. Thus, a primer.
This document is insufficient to let them know how mdev works. Therefore, this is an entry-level document.
-----------
Basic use
Basic usage
-----------
Mdev has two primary uses: initial population and dynamic updates. Both
Mdev has two main applications: initialization object and dynamic update.
Require sysfs support in the kernel and have it mounted at/sys. For dynamic
Both applications require support from the kernel sysfs and must be mounted to/sys. To achieve dynamic updates,
Updates, you also need to have hotplugging enabled in your kernel.
You must also add hotging ging support during Kernel configuration ).
Here's a typical code snippet from the init script:
The following is a typical mdev code snippet in the system initialization script:
[1] Mount-T sysfs/sys
[2] echo/bin/mdev>/proc/sys/kernel/hotplug
[3] mdev-S

Of course, a more "full" setup wocould entail executing this before the previous
Of course, a more complete installation of mdev must also execute the following command before the above code snippets:
Code snippet:
[4] Mount-T tmpfs mdev/dev
[5] mkdir/dev/PTS
[6] Mount-T devpts/dev/PTS

The simple explanation here is that [1] You need to have/sys mounted before
Briefly describe the above Code: [1] You must mount/sys before executing mdev.
Executing mdev. Then you [2] instruct the kernel to execute/bin/mdev whenever
Then you [2] Run the command kernel/bin/mdev when adding or deleting devices,
A device is added or removed so that the device node can be created or
This allows you to create and delete device node files.
Destroyed. Then you [3] seed/dev with all the device nodes that were created
Finally, you [3] Set mdev to create all the device nodes when the system starts.
While the system was booting.
For the "full" setup, you want to [4] Make sure/Dev is a tmpfs filesystem
For more complete mdev installation, you must [4] ensure that/Dev is the tmpfs File System
(Assuming you're running out of Flash). Then you want to [5] Create
(Assume that the file system runs out of Flash ). And you must [5] Create

-------------
Mdev config (/etc/mdev. conf)
Mdev configuration (/etc/mdev. conf)
-------------
Mdev has an optional config file for controlling ownership/permissions
Device nodes if your system needs something more than the default root/root
660 permissions.
If your system requires more permissions than the default root/root 660,
You can use the optional configuration file of mdev to control the owner and permissions of the device node.
The file has the format:
The file format is as follows:
<Device RegEx> <uid >:< GID> <octal permissions>
For example:
For example:
HD [A-Z] [0-9] * 0: 3 660
The Config File Parsing stops at the first matching line. If no line is
This configuration file stops parsing at the First Matching row. If no matching row exists,
Matched, then the default of 0: 0 660 is used. To set your own default, simply
Use the default 0: 0 660. You can also create the following full match at the end
Create your own total match like so:
To set your own default settings:
. * 1:1 777
If you also enable support for executing your own commands, then the file has
If you want mdev to execute a custom command when matching a row is found, the file format is as follows:
The format:
<Device RegEx> <uid >:< GID> <octal permissions> [<@ | $ | *> <command>]
The special characters have the meaning:
The significance of special characters is as follows:
@ Run after creating the device.
@ Run the command after creating the device node.
$ Run before removing the device.
$ Run the command before deleting a device node.
* Run both after creating and before removing the device.
* Run the command after the device node is created and before the device node is deleted.
The command is executed via the system () function (which means you're giving
These commands are executed through the system function (system () (that is, you are running commands on Shell)
Command to the shell), so make sure you have a shell installed at/bin/sh.
So make sure that you have installed the shell in/bin/sh.
For your convenience, the shell env var $ mdev is set to the device name. So if
For convenience, the shell environment variable $ mdev is set to the device name. For example
The device 'hdc 'was matched, mdev wocould be set to "HDC ".
Mdev resolves to the device 'hdc 'to match, and mdev is set to "HDC ".

----------
Firmware
Firmware
----------
Some kernel device drivers need to request firmware at runtime in order
Some device drivers need to upload firmware to initialize the device correctly during running.
Properly initialize a device. Place all such firmware files into
Put all firmware files
/Lib/firmware/directory. At runtime, the kernel will invoke mdev with
/Lib/firmware/directory. At runtime, the kernel will call mdev according to the firmware file name,
Filename of the firmware which mdev will load out of/lib/firmware/and
Then mdev uses the sysfs interface to extract the firmware from/lib/firmware/
The kernel via the sysfs interface. The exact filename is hardcoded in
Load to the kernel. The specified file name is fixed in the kernel,
Kernel, so look there if you need to want to know what to name the file in
If necessary, you must know how to name this file in the user space.
Userspace.

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.