Based on the previously transplanted kernel, we transplanted the drivers separately. This article mainly transplanted the USB driver and clarified the mdev related to hot swapping. In kernel 2.6.30, the USB driver has been improved, you only need to modify the configuration sheet. The added content is as follows:
Device Drivers --->
SCSI device support --->
SCSI Device Support
SCSI disk support depends on the help of the configuration list. If a USB storage device is used, select this option.
Hid devices --->
Generic hid support
USB Human Interface Device (full hid) Support add USB Human-Machine Interface Device Support
USB support ---> there are many USB-related settings under this menu, but only USB can recognize the USB flash drive first. If other functions are required, add
Support for host-side USB supports USB hosts, which is a prerequisite for using USB
USB announce new devices allows USB to declare the device ID and manufacturer ID.
USB device filesystem supports USB file system, allowing users to directly access USB devices
Ohci hcd support OHCI support, that is, USB 1.0, my Development Board is, embedded
Generally 1.0
USB Mass Storage Support supports large-capacity USB storage devices
In this way, you can use USB. In addition, with the previously created file system, hot swapping is supported. After a USB flash drive is inserted, the system automatically mounts the USB flash drive to the/mnt/udisk/directory.
The following describes how to use mdev of busybox to implement hot swapping. For more information, see Docs/mdev.txt in busybox. Here, only the important points are described. (I am using busybox 1.htm)
Here's a typical code snippet from the init script:
[0] Mount-T proc/proc
[1] Mount-T sysfs/sys
[2] echo/sbin/mdev>/proc/sys/kernel/hotplug (note that the original article is/bin/mdev and there is a problem)
[3] mdev-S
This section describes the content that should be added to the initialization script, that is, the content added to the/etc/init. d/RCS script of the file system. The main task is to mount procfs and sysfs, and then redirect the output information of/bin/mdev/to/proc/sys/kernel/hotplug to inform the information inserted by the new device.
Alternatively, without procfs the above becomes:
[1] Mount-T sysfs/sys
[2] sysctl-W kernel. hotplug =/bin/mdev
[3] mdev-S
Or you may not use procfs, so the above Code should be modified.
Of course, a more "full" setup wocould entail executing this before the previous
Code snippet:
[4] Mount-T tmpfs-O size = 64 K, mode = 0755 tmpfs/dev
[5] mkdir/dev/PTS
[6] Mount-T devpts/dev/PTS
In addition, more complete settings need to be completed before the above Code. Mount tampfs and devpts.
In this way, the content of the initialization script is complete.
Next, let's talk about the mdev-related configuration file/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.
That is to say, this file is not required, but is set when you do not use the default permissions.
Here, we will not explain each part of this file too much, but only the statement format in the final file. For details, see/docs/mdev.txt.
<Device RegEx> <uid >:< GID> <octal permissions> [= path] [@ | $ | * <command>]
Or
<Device RegEx> <uid >:< GID> <octal permissions> [> path] [@ | $ | * <command>]
Path and command are optional, and the symbols before command are interpreted
The special characters have the meaning:
@ Run after creating the device.
$ Run before removing the device.
* Run both after creating and before removing the device.
Take the statements used by my file system as an example to describe:
SD [A-Z] * [0-9] 0: 0 0660 @ (Mount-T vfat-O iocharset = utf8/dev/$ mdev/mnt/udisk)
SD [A-Z] * [0-9] 0: 0 0660 * (umount/mnt/udisk)
The device node name is SD [A-Z] combined with numbers 0-9. The UID and GID are both 0, that is, root/root. The permission is 660, that is, the user has read and write permissions, users in the same group have the read and write permissions. Users in other groups do not have the permission. In the first sentence
@ (Mount-T vfat-O iocharset = utf8/dev/$ mdev/mnt/udisk)
After creating a device node, Mount/dev/$ mdev to/mnt/udisk. The character format is utf8. $ mdev is interpreted
For your convenience, the shell env var $ mdev is set to the device name. So if the device "HDC" was matched, mdev wocould be set to "HDC ".
That is, the name of the device node under the dev directory.
Second sentence SD [A-Z] * [0-9] 0: 0 0660 * (umount/mnt/udisk)
Uninstall the device before deleting the device.
After completing these operations, you can support hot swapping. There are only two steps:
1. Add the corresponding content to/etc/init. d/RCS;
2. Fill in the mdev. conf file.