内核版本:linux-2.6.32.2 实验平台:mini2440
1. 添加平台设备支持
s3c2440的usb host平台设备已经定义好了的,定义在plat-s3c/dev-usb.c中:
static struct resource s3c_usb_resource[] = { [0] = { .start = S3C_PA_USBHOST, .end = S3C_PA_USBHOST + 0x100 - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = IRQ_USBH, .end = IRQ_USBH, .flags = IORESOURCE_IRQ, } }; static u64 s3c_device_usb_dmamask = 0xffffffffUL; struct platform_device s3c_device_usb = { .name = "s3c2410-ohci", .id = -1, .num_resources = ARRAY_SIZE(s3c_usb_resource), .resource = s3c_usb_resource, .dev = { .dma_mask = &s3c_device_usb_dmamask, .coherent_dma_mask = 0xffffffffUL } }; EXPORT_SYMBOL(s3c_device_usb);
只需要在mach-mini2440.c中包含<plat/devs.h>这个头文件,然后将这个平台设备添加到mini2440_devices这个平台设备数组里面,以便完成平台设备的注册。
static struct platform_device *mini2440_devices[] __initdata = { /* ... */ &s3c_device_usb, /* ... */ };
Device Drivers ---> [*] USB support ---> <*> Support for Host-side USB [*] USB announce new devices [*] USB device filesystem (DEPRECATED) <*> OHCI HCD support
编译下载内核,系统启动过程中可以看到以下一些信息:
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver s3c2410-ohci s3c2410-ohci: S3C24XX OHCI s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1 s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000 usb usb1: New USB device found, idVendor=1d6b, idProduct=0001 usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 usb usb1: Product: S3C24XX OHCI usb usb1: Manufacturer: Linux 2.6.32.2 ohci_hcd usb usb1: SerialNumber: s3c24xx usb usb1: configuration #1 chosen from 1 choice hub 1-0:1.0: USB hub found hub 1-0:1.0: 2 ports detected
将u盘插入到usb host接口处,虽然能够检测到有usb设备插入,但是由于没有为该usb找到合适的usb驱动,所以u盘暂时还不能正常工作,所以还需要usb device驱动的支持。配置内核:
Device Drivers ---> SCSI device support ---> <*> SCSI device support <*> SCSI disk support [*] USB support ---> <*> USB Mass Storage support
上面配置好了u盘设备的支持。
虽然此时u盘设备都能够正常枚举,但是此时u盘还不能够挂载,因为没有文件系统的支持,例如vfat、ntfs等等。
所以接下来是配置文件系统的支持:
File systems ---> DOS/FAT/NT Filesystems ---> <*> MSDOS fs support <*> VFAT (Windows-95) fs support (437) Default codepage for FAT (iso8859-1) Default iocharset for FAT <*> NTFS file system support [*] NTFS write support
最后,还需要配置语言的支持:
File systems ---> -*- Native language support ---> (iso8859-1) Default NLS Option <*> Codepage 437 (United States, Canada) <*> NLS ISO 8859-1 (Latin 1; Western European Languages)
3. 测试
重新编译内核并下载内核到板子上,等系统启动之后,插上u盘,使用下面的命令进行挂载:
mount -t vfat /dev/sda1 /mnt/udisk
这样虽然能够正常挂载u盘,但是中文会显示乱码(包括文件名和文件里面的内容)。
Device Drivers ---> Input device support ---> <*> Event interface [*] HID Devices ---> <*> USB Human Interface Device (full HID) support
配置项Event interface表示将在/dev/input目录下创建event设备节点。