A hot swap USB

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Turn:

This article is very good :

How to use the busybox streamlined version of udev program --mdev to create dynamic insertion site and the mouse device

busyboxThemdevIs a streamlinedudevManagement program,It can be indirectly byhotplugBy the kernel calls,And then in thearmPlatform/devDynamically create device node directory,BecausehotplugWill be the kernel to sendueventBefore calling,So if the dynamic pluggable equipment many,Very frequent,Then each kernel will be calledelfUser space hotplug,Generation of an independenthotplugProcedures to deal with,SohotplugIs a method to realize a very heavy,But in ourarmDevelopment board,Pluggable equipment don't often imagined
There is no need to transfer the full version of udev, so mdev can be used in embedded equipment is not complicated to manage dynamic node completely,
The method is very simple, is to add the following sentence in rcS script, will transfer the application path the user space to the kernel,
echo /sbin/mdev > /proc/sys/kernel/hotplug
A user space application of /sbin/mdev kernel in each equipment changes call the above sentence passed in to deal with the corresponding information, and then mdev applications operate under the /dev directory, equipment, add or delete, can refer to add hotplug function to kernel uevent, monitoring information
Another very useful where mdev is, he can pass the proc and sys file system to dynamic sorting out the registration device, then to the node /dev/ generated under their corresponding,
We must mount proc and sys file system before using this function, then the following simple implementation of a sentence and then bent into:
mdev -s

If you need to compile the udev, here are the udev download address: http://www.us.kernel.org/pub/linux/utils/kernel/hotplug/udev-145.tar.bz2


This guy is a more detailed:

http://203.208.39.132/search?q=cache:c8dPpXQD5HwJ:jimmy-lee.blog.hexun.com/31155612_d.html+busybox+hotplug&cd=9&hl=zh-CN&ct=clnk&gl=cn&st_usg=ALhdy28vvvlS7owkZsMZfoX5oCEEE3l8aA


1, Busybox add mdev support


2, Add in /etc/rc.d/rcS

#mount filesystem

/bin/mount -a

#start mdev

#Set up the system of hotplug program for the mdev

echo /sbin/mdev > /proc/sys/kernel/hotplug

#Scan and create nodes, this step can not be less

mdev –s


/etc/Fstab is as follows:

proc /proc proc defaults 0 0

none /tmp ramfs defaults 0 0

mdev /dev ramfs defaults 0 0

sysfs /sys sysfs defaults 0 0


Executionmdev -s : The '-s' for the call parameters is located in the /sbin directory written mdev (actually is a link, role is to pass a parameter to the /bin directorybusybox Program and call it), equipment list all mdev scanning /sys/class and /sys/block, if the directory contains a file named "dev", includes and file is equipment number, mdev will use this information for the device in the /dev device nodes created documents. In general only starts to execute a "mdev -s".


Hot plug events: due to start running the command: echo /sbin/mdev > /proc/sys/kernel/ hotplug, so when there is hot plug event occurs, the kernel will be called in the /sbin directory mdev. Then mdev by environment variables in the ACTION and DEVPATH, to determine the hot plug event action as well as the impact of the directory in /sys. Then have a look whether "attribute file dev" this directory, if there is to use the information for this device to create device nodes file in /dev.


Using mdev to solve the "cannot create /proc/sys/kernel/hotplug: nonexistent directory" error

The following options to compile the kernel:

CONFIG_PROC_FS=y

CONFIG_PROC_SYSCTL=y

CONFIG_HOTPLUG=y

CONFIG_NET=y

If CONFIG_HOTPLUG and CONFIG_NET don't choose or not all of the words, /proc/sys/kernel will hotplug file will not be created. (see kernel/sysctl.c)

////////////////////////////////////////////////////////

Here is a translation:

Introduction to MDEV (turn)

Busybox-1.7.0/docs/mdev.txt
Translation: tekkamanninja Email: - 1 -

-------------
MDEV Primer
Introduction to MDEV
-------------
For those of us who know how to use mdev, a primer might seem lame. For
This document for those who know how to use the mdev people may seem somewhat superficial.
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 make people fear.
seem to get their head around how it works. Thus, a primer.
This document is not strong enough to let them know how mdev works. Therefore, it is an introductory document.
-----------
Basic Use
Basic use
-----------
Mdev has two primary uses: initial population and dynamic updates. Both
The mdev has two main applications: initialize the object and dynamic update.
require sysfs support in the kernel and have it mounted at /sys. For dynamic
Two require sysfs support in the kernel, and must be mounted to the /sys. In order to realize the dynamic update,
updates, you also need to have hotplugging enabled in your kernel.
You must also increase hot swap support in the kernel configuration(hotplugging).
Here's a typical code snippet from the init script:
The following is a typical mdev system initialization scripts in the code fragment:
[1] mount -t sysfs sysfs /sys
[2] echo /bin/mdev > /proc/sys/kernel/hotplug
[3] mdev -s

Of course, a more "full" setup would entail executing this before the previous
Of course, one of the mdev is a complete installation must be performed under the snippet above pre orders:
code snippet:
[4] mount -t tmpfs mdev /dev
[5] mkdir /dev/pts
[6] mount -t devpts devpts /dev/pts

The simple explanation here is that [1] you need to have /sys mounted before
Briefly stated the above code: [1] you must before executing mdev mount /sys .
executing mdev. Then you [2] instruct the kernel to execute /bin/mdev whenever
Then you [2] command execution in the kernel and device /bin/mdev ,
a device is added or removed so that the device node can be created or
The device node file will be created and deleted.
destroyed. Then you [3] seed /dev with all the device nodes that were created
Finally, you set [3] mdev, let it create device node all at system startup.
while the system was booting.
For the "full" setup, you want to [4] make sure /dev is a tmpfs filesystem
The mdev is a complete installation, you must ensure that the file system is TMPFS [4] /dev
(assuming you're running out of flash). Then you want to [5] create the
(assuming the file system runs on the flash). And you must be [5] to create

-------------
MDEV Config (/etc/mdev.conf)
The MDEV configuration (/etc/mdev.conf)
-------------
Mdev has an optional config file for controlling ownership/permissions of
device nodes if your system needs something more than the default root/root
660 permissions.
If your system needs some 660 more than the default root/root permissions,
Optional configuration files, you can use the mdev, the owner and access control equipment node.
The file has the format:
This 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 parsing in the first match. If no matching rows,
matched, then the default of 0:0 660 is used. To set your own default, simply
Then it uses the default 0:0 660. You can also pass in the match finally create the following
create your own total match like so:
For, to set the default settings for your own:
.* 1:1 777
If you also enable support for executing your own commands, then the file has
If you want mdev to perform custom commands to find matching rows, then the file format is as follows:
the format:
<device regex> <uid>:<gid> <octal permissions> [<@|$|*> <command>]
The special characters have the meaning:
The following special character meaning:
@ Run after creating the device.
@ Run command to create a device node.
$ Run before removing the device.
$ Run before removing the device.
* Run both after creating and before removing the device.
* To create a device node and delete the device node before the run command.
The command is executed via the system() function (which means you're giving a
These commands are through the system function (system ()) execution (that is you in the shell command)
command to the shell), so make sure you have a shell installed at /bin/sh.
, So please make sure you have installed shell on /bin/sh.
For your convenience, the shell env var $MDEV is set to the device name. So if
For the sake of convenience, the environment variable $MDEV shell is set to the device name. For example
the device 'hdc' was matched, MDEV would be set to "hdc".
Mdev analysis to the equipment of'hdc'matching, MDEV will be set to "hdc".

----------
FIRMWARE
Firmware
----------
Some kernel device drivers need to request firmware at runtime in order to
Some device drivers at run time, in order to correct initialization of the equipment, the need to upload the firmware.
properly initialize a device. Place all such firmware files into the
Please put all the firmware files into
/lib/firmware/ directory. At runtime, the kernel will invoke mdev with the
/lib/firmware/ Catalog. At run time, the core will press the firmware file name mdev ,
filename of the firmware which mdev will load out of /lib/firmware/ and into
After mdev through sysfs interface firmware from /lib/firmware/
the kernel via the sysfs interface. The exact filename is hardcoded in the
Loaded into the kernel. To determine the file name to be cured 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 the file in user space.
userspace.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Deborah at August 11, 2014 - 9:05 AM