本开发板内核版本为Linux-3.0
此文章只是介绍USB移植的过程,对于Linux内核自带驱动的移植一般分为两个步骤:
1、修改代码,将USB初始化;
2、修改Linux内核配置,使其支持USB
进入内核的mach-smdk2440.c (路径为:linux-3.0/arch/arm/mach-s3c2440/mach-smdk2440.c )
#include
#include
static int option_send_setup(struct usb_serial_port *port);
static void option_instat_callback(struct urb *urb);
/* Vendor and product IDs */
static int vendor = 0;
static int product = 0;
#define OPTION_VENDOR_RESERVED 0xFFFF /* Add by huangan */
#define OPTION_RESERVED_DEVICE 0xFFFF /* Add by huangan */
#define OPTION_VENDOR_ID 0x0AF0
#define OPTION_PRODUCT_COLT 0x5000
将static const struct usb_device_id option_ids[]中的const去掉,并添加代码
static struct usb_device_id option_ids[] = {
455 { USB_DEVICE(OPTION_VENDOR_RESERVED, OPTION_RESERVED_DEVICE) },
456 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
457 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
改3:
更改int __init option_init结构体
static int __init option_init(void)
1086 {
1087 int retval;
if ((vendor>0) && (product>0))
{
option_ids[0].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
option_ids[0].idVendor = vendor;
option_ids[0].idProduct = product;
printk("Register option drvier for modem vendor=0x%04x product=0x%04x\n", vendor, product);
}
1096 retval = usb_serial_register(&option_1port_device);
1097 if (retval)
1098 goto failed_1port_device_register;
vim /etc/mdev.conf(这是自己制作的根文件系统)
sd[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb) //当检测到sda1类似的设备时将mdev检测到的设备挂载到mnt/usb上
sd[a-z] 0:0 0777 $(umount /mnt/usb)
ub[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)//如果你u盘插上去能检测到设备但是不能看到里面的内容,就注释掉这2句话,是因为你没挂载成功。
ub[a-z] 0:0 0777 $(umount /mnt/usb)
好了,以上就是对代码的修改,接下来是修改内核驱动的配置
Device Drivers --->
Generic Driver Options --->
(/sbin/hotplug) path to uevent helper //配置u盘的热插拔
[*] Block devices --->
<*> Low Performance USB Block driver
SCSI device support --->
<*> SCSI device support
<*> SCSI generic support
[*] Probe all LUNs on each SCSI device
//对于这个上面的具体选项可以参考这个博客: http://blog.chinaunix.net/uid-9727915-id-259858.html
[*] HID Devices --->
-*- Generic HID support
<*> USB Human Interface Device (full HID) support
因为u盘用到了scsi命令,所以我们需要增加scsi支持.
(usb storage驱动利用scsi中间层将usb storage设备虚拟成scsi逻辑设备。这样可以方便的使用scsi驱动的设备IO接口,以及plugin/plugout等机制)
SCSI device support --->
<*> SCSI device support
[*] legacy /proc/scsi/ support
<*> SCSI disk support
现在的U盘等移动存储器使用的大都是 FAT/FAT32 格式的,因此我们还需要添加FAT32 文件系统以及分区格式的支持:
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
Partition Types --->
[*] PC BIOS (MSDOS partition tables) support
[*] Windows Logical Disk Manager (Dynamic Disk) support
-*- Native language support --->
<*> Codepage 437 (United States, Canada)
<*> Simplified Chinese charset (CP936, GB2312)
<*> ASCII (United States)
<*> NLS ISO 8859-1 (Latin 1; Western European Languages)
<*> NLS UTF-8
好了,以上就是要修改的地方