一、移植环境
主 机:Fedora 14 (kernel-2.6.33.7) 开发板:FL2440(nandflash:K9F1G08
128MB)
编译器:arm-linux-gcc-4.3.2
二、移植步骤 1. 添加SD卡设备到系统设备初始化列表中。2.6.30.4内核对MMC/SD卡的支持已经非常完善了,而且支持超大容量32GB,所以这里我们只需把s3c_device_sdi添加到列表中即可。
- #vim arch/arm/mach-s3c2410/mach-smdk2410.c
-
static struct platform_device *smdk2410_devices[] __initdata = {
-
&s3c_device_usb,
-
&s3c_device_sdi, //SD/MMC
-
&s3c_device_lcd,
-
&s3c_device_wdt,
-
&s3c_device_i2c0,
-
&s3c_device_iis,
-
&s3c_device_rtc,
-
&s3c24xx_uda134x, //uda
-
&s3c_device_dm9000,
-
};
2. 修改MMC/SD驱动源码。主要是添加SD卡的中断处理,去掉驱动的Bug和一些多余的调试信息
- vim drivers/mmc/host/s3cmci.c
-
-
static struct s3c24xx_mci_pdata s3cmci_def_pdata = {
-
.gpio_detect = S3C2410_GPG(8),
-
.gpio_wprotect = S3C2410_GPH(8),
-
.set_power = NULL,
-
.ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34,
-
};
-
-
-
static void s3cmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
-
{
-
....
-
-
/* Set CLOCK_ENABLE */
-
if (ios->clock)
-
mci_con |= S3C2410_SDICON_CLOCKTYPE;
-
else
-
mci_con &= ~S3C2410_SDICON_CLOCKTYPE;
-
-
writel(mci_con, host->base + S3C2410_SDICON);
-
-
if ((ios->power_mode == MMC_POWER_ON) ||
-
(ios->power_mode == MMC_POWER_UP)) {
-
//dbg(host, dbg_conf, "running at %lukHz (requested: %ukHz).\n",
-
// host->real_rate/1000, ios->clock/1000);
-
} else {
-
dbg(host, dbg_conf, "powered down.\n");
-
}
-
-
host->bus_width = ios->bus_width;
-
....
-
}
3. 修改内核配置选项。完成后重新编译内核下载到开发板上
- 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 S3C SD/MMC Card Interface support
4. 插入SD卡。当开机之后系统启动后插入SD卡就会出现一些信息,还可以看到mmcblk0就是SD设备了。
- s3c2410 TouchScreen successfully loaded
-
input: s3c2410 TouchScreen as /class/input/input0
-
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
-
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
-
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
-
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
-
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
-
s3c-sdi s3c2440-sdi: powered down.
-
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
5. 重新插入SD卡,开发板已经识别出了SD卡
- [root@yyq2440 /]# mmc0: card b368 removed
-
s3c-sdi s3c2440-sdi: powered down.
-
mmc0: new SD card at address b368
-
mmcblk0: mmc0:b368 SD 1.90 GiB
-
mmcblk0: p1
6. 挂载SD卡。执行mount命令将SD卡挂载到/mnt/mmc/目录下,但是没成功,出错了。首先查看/dev/目录下并没有mmcblk0p1节点所以出错,我们查看/proc/partitions/目录发现SD卡的主设备号是179,次设备号是1,那么我们就创建这个设备的节点,b代表块设备,最后再执行mount命令,没有出错。最后可以成功看到SD卡里面的内容。过程如下。
- [root@yyq2440 /]# mkdir mnt/mmc
-
[root@yyq2440 /]# mount /dev/mmcblk0p1 /mnt/mmc
-
mount: mounting /dev/mmcblk0p1 on /mnt/mmc failed: No such file or directory
-
[root@yyq2440 /]# ls /dev
-
console null
-
[root@yyq2440 /]# cat /proc/partitions
-
major minor #blocks name
-
-
31 0 128 mtdblock0
-
31 1 384 mtdblock1
-
31 2 3072 mtdblock2
-
31 3 61440 mtdblock3
-
31 4 512 mtdblock4
-
31 5 60928 mtdblock5
-
179 0 1997312 mmcblk0
-
179 1 1997188 mmcblk0p1
-
[root@yyq2440 /]# mknod /dev/blk0p1 b 179 1
-
[root@yyq2440 /]# rm /dev/blk0p1
-
[root@yyq2440 /]# mknod /dev/mmcblk0p1 b 179 1
-
[root@yyq2440 /]# mount /dev/mmcblk0p1 /mnt/mmc
-
[root@yyq2440 /]# ls /mnt/mmc
-
???? htmlhelp.exe st-ndt test.wav
-
[root@yyq2440 /]#
2011-03-01
|