1.内核配置
增加驱动:
-> Device Drivers
-> MMC/SD/SDIO card support (MMC [=y])
-> MMC/SD/SDIO card support (MMC [=y])
<*> MMC block device driver
增加文件系统支持:
-> File systems
-> DOS/FAT/NT Filesystems
-> DOS/FAT/NT Filesystems
<*> VFAT (Windows-95) fs support
字符集支持:
<*> NLS ISO 8859-1 (Latin 1; Western European Languages)
<*> Codepage 437 (United States, Canada)
2. 热插拔自动挂载和卸载SD卡:
1). 确保文件系统支持mdev
mdev是busybox中udev设备文件系统的精简版
可以 make menuconfig 查看并添加
2). 启动时创建设备节点及热插拔事件
vim /etc/init.d/rcS
echo /sbin/mdev>/proc/sys/kernel/hotplug //有热插拔事件时,内核会调用sbin目录下的mdev
mdev -s //在dev目录下创建设备节点
mdev -s //在dev目录下创建设备节点
3).添加对热插拔事件的响应,实现U盘和SD卡的自动挂载
Vim /etc/mdev.conf
mmcblk[0-9]p[0-9] 0:0 666 @ /etc/sd_card_inserting
mmcblk[0-9] 0:0 666 $ /etc/sd_card_removing
mmcblk[0-9]p[0-9] 0:0 666 @ /etc/sd_card_inserting
mmcblk[0-9] 0:0 666 $ /etc/sd_card_removing
4).自动挂载和卸载脚本
/etc/sd_card_inserting
#!/bin/sh
mount -t vfat /dev/mmcblk0p1 /mnt/sd
/etc/sd_card_removing
#!/bin/sh
sync
umount /mnt/sd
#!/bin/sh
mount -t vfat /dev/mmcblk0p1 /mnt/sd
/etc/sd_card_removing
#!/bin/sh
sync
umount /mnt/sd
为以上两个脚本加上可执行权限:
chmod +x /etc/sd_card_inserting
chmod +x /etc/sd_card_removing