分类: 嵌入式
2009-10-09 21:21:09
USB和SD/MMC移植笔记
一、USB移植
在移植好内核和跟文件系统的基础上,进行USB的移植。
S
在内核目录下,输入make menuconfig,进入配置菜单,如下:
Device Drivers-à SCSI device support-à <*>SCSI device support [*]legacy /proc/scsi/ support <*>SCSI disk support <*>SCSI CDROM support [*]HID Devices-à <*> USB Human Interface Device(full HID)support [*] /dev/hiddev raw HID device support [*]USB support-à <*> support for Host-side USB [*] USB device filesystem [*] USB device class-devices(DEPRECATED) <*>OHCI HCD support <*>USB Mass storage support |
先用make clean命令清除编译内核的垃圾文件,然后用命令make zImage编译内核。
在移植的根文件系统系统目录dev下建立如下的设备文件:
mknod sda1 b 8 1
把编译好的内核和根文件系统映像文件下载到开发板,启动开发板后插入U盘,终端出现如下信息:
[@MrFeng=W]#ls bin etc linuxrc proc sys var boot home lost+found root tmp www dev lib mnt sbin usr [@MrFeng=W]#usb 1-1: new full speed USB device using s usb 1-1: New USB device found, idVendor="0204", idProduct="6025" usb 1-1: New USB device strings: Mfr="0", Product="0", SerialNumber="0" usb 1-1: configuration #1 chosen from 1 choice scsi0 : SCSI emulation for USB Mass Storage devices scsi 0:0:0:0: Direct-Access USB A Flash Disk 2.00 PQ: 0 ANSI: 2 sd 0:0:0:0: [sda] 506420 512-byte hardware sectors: (259 MB/247 MiB) sd 0:0:0:0: [sda] Write Protect is off sd 0:0:0:0: [sda] Assuming drive cache: write through sd 0:0:0:0: [sda] 506420 512-byte hardware sectors: (259 MB/247 MiB) sd 0:0:0:0: [sda] Write Protect is off sd 0:0:0:0: [sda] Assuming drive cache: write through sda: sda1 sd 0:0:0:0: [sda] Attached SCSI removable disk [@MrFeng=W]#mount -t vfat /dev/sda1 /mnt/usb FAT: utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive! |
使用命令mount挂载U盘:
[@MrFeng=W]#mount -t vfat /dev/sda1 /mnt/usb [@MrFeng=W]#ls /mnt/usb bootloader.tgz logomaker.tgz rootfs.img busybox- examples(1).tgz mini2440_pwm.c zImage getaddrinfo.c mkyaffsimage.tgz led_driver.c root_qtopia.img |
拔下U盘后出现:
[@MrFeng=W]#usb 1-1: USB disconnect, address 2 |
二、SD/MMC移植
S
Device Drivers-? <*>MMC/SD/SDIO card support---> <*>MMC block device driver [*]Use bounce buffer for simple hosts <*>Samsung S |
配置好后,把编译的内核下载到开发板后,插入SD卡终端没有任何提示。细细一看,友善之臂的SD卡的写保护不是直接接地的,二是接到GPH8引脚的,
于是我在内核文件/arch/arm/mach-s3c2440/mach-smdk2440.c中做如下修改:
static void __init smdk2440_machine_init(void) { s s //开启LCD背光 s s //关闭SD卡写保护 s s platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices)); smdk_machine_init(); } |
另外,将检测SD卡的引脚设为中断,用于检测SD卡,在内核文件在drivers/mmc/host/s3cmci.c中1335行添加如下代码:
… host->irq_cd = IRQ_EINT16; s … |
在1357行注释掉如下代码:
… //ret = -EBUSY; //goto probe_free_irq_cd; … |
重新编译内核,下载到开发板,并在跟文件系统的dev目录下通过命令“mknod mmcblk0 b 179 0”建立节点,烧写根文件系统。系统启动后将SD卡插入到卡座,在终端出现如下信息:
[@MrFeng=W]#mmc0: card 0002 removed s s s s s s s s s s s mmc0: new SD card at address 0002 mmcblk0: mmc0:0002 00000 1.90 GiB mmcblk0:<4>mmcblk0: retrying using single block read |
拔下SD卡出现:
[@MrFeng=W]#mmc0: card 0002 removed s |
说明:V1.2是对V1.1的SD卡移植部分进行修改,V1.1中移植SD卡是不完善的,只关闭了SD卡写保护,没有添加检测SD卡部分,这将导致使用不正常。
交流邮箱: