Linux中對SD卡的支持非常完善了,我們只需要按照以下修改即可完成SD卡的初始化
1、arch/arm/mach-s3c2440/mach-smdk2440.c platform結構中增加&s3c_device_sdi語句。
static struct platform_device*smdk2440_devices[] __initdata =
{
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
&s3c_device_nand,
&s3c_device_sdi, //add here
};
2、添加和開發板相關的 SD 卡插拔引發的中斷:
#vi drivers/mmc/host/s3cmci.c +1335
在1335行,添加如下內容:
host->irq_cd = IRQ_EINT16;
s3c2410_gpio_cfgpin(S3C2410_GPG8, S3C2410_GPG8_EINT16);
注:SD卡中斷管腳需根據硬件連接圖實際情況修改
3、在makemenuconfig時選上所有關於sd卡的信息,要想支持中文還得選上:
Device Drivers --->
<*> MMC/SD/SDIO card support --->
--- MMC/SD/SDIO card support
[ ] MMC debugging
[ ] Allow unsafe resume (DANGEROUS)
*** MMC/SD/SDIO Card Drivers ***
<*> MMC block device driver
[*] Use bounce buffer for simple hosts
< > SDIO UART/GPS class support
< > MMC host test driver
*** MMC/SD/SDIO Host Controller Drivers ***
< > Secure Digital Host Controller Interface support
< > MMC/SD/SDIO over SPI
<*> Samsung S3CSD/MMC Card Interface support
File system--》
DOS/FAT/NT Filesystems--》
VFAT(Windows-95)fs support
(437)Default codepage for FAT
**把437改為936
Native language support -->
[*]Simplified Chinese charset
[*]NLS UTF-8
4、測試
這樣就可直接掛載了 mount -t vfat /dev/mmcblk0 /mnt
如果sd卡分區了 mount -t vfat /dev/mmcblk0p1 /mnt
直接讀寫sd就可以了