一、代碼修改
在這裡把include前面的#給刪了,希望有幫助
/*add by lfc*/
#include
#include
#include
#include
/*end add*/
/**********************add by lfc*************************************/
static struct s3c2410_hcd_info usb_sbc2410_info = {
.port[0] = {
.flags = S3C_HCDFLG_USED
}
};
int usb_sbc2410_init(void)
{
unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03);
printk("USB Control, (c) 2006 sbc2410 ");
s3c_device_usb.dev.platform_data = &usb_sbc2410_info;
while(upllvalue!=__raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue,S3C2410_UPLLCON);
mdelay(1);
}
return 0;
}
/***************************end add**********************/
static void __init smdk2410_map_io(void)
{
s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
s3c24xx_init_clocks(0);
s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
s3c24xx_set_board(&smdk2410_board);
/*************************add by lfc****************************/
usb_sbc2410_init();
/*************************end add*******************************/
}
上面的修改其實也參考了這個牛貼一下,裡面有大蝦們對USB驅動移植的討論,還不錯:
http://www.linuxforum.net/forum/showflat.php?Cat=&Board=embedded&Number=556915&page=0&view=collapsed&sb=5&o=0&fpart=
其實到了這裡,要修改的代碼已經修改完了,比添加Nand flash的支持修改的地方還要少^_^,不過我一直以為還沒修改好,最後發現原來是沒配置好~_~
二、內核配置
下面說一下鬱悶了我好一陣子的內核配置(支持USB)問題,這個就比Nand flash的配置要複雜多了。
1、讓內核支持熱插拔
│ General setup --->
│ │[*] Support for hot-pluggable devices
2、USB驅動設置,可能有些不選也行,不過沒時間去試,至於為什麼要選這些選項的話可以看一下這個貼(Linux下的硬體驅動——USB設備):
http://www-128.ibm.com/developerworks/cn/linux/l-usb/index1.html
│ │ Device Drivers --->
│ │ Generic Driver Options --->
│<*> Hotplug firmware loading support
│ │ Block devices --->
│ │ <*> Low Performance USB Block driver
│ │ SCSI device support --->
│ │ <*> SCSI generic support
│ │ [*] Probe all LUNs on each SCSI device
│ │ USB support --->
│ │<*> Support for Host-side USB
│ │[*] USB device filesystem
│ │<*> OHCI HCD support
│ │<*> USB Mass Storage support
│ │[*] USB Monitor
3、加入了MSDOS fs和VFAT fs的支持。
│ │ File systems --->
│ │ DOS/FAT/NT Filesystems --->
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ <*> MSDOS fs support │ │
│ │ <*> VFAT (Windows-95) fs support │ │
│ │ (936) Default codepage for FAT │ │
│ │ (cp936) Default iocharset for FAT │ │
│ │ < > NTFS file system support
做完這些后,插入u盤后,內核應該可以識別到u盤,出現:
usb 1-1: new full speed USB device using s3c2410-ohci and address 3
ub(1.3): GetMaxLUN returned 0, using 1 LUNs
但是,還有下面一句出錯提示:
/dev/ub/a: unknown partition table
再次查看了貼子上大蝦們的討論,提到:“使能CONFIG_MSDOS_PARTITION選項”,再仔細查找,發現配置選項如下:
│ │ File systems --->
│ │ Partition Types --->
│ │ [*] PC BIOS (MSDOS partition tables) support
加上這個后應該就可以掛載usb上的MSDOS分區了
以下是我的內核插入u盤后的提示信息:
usb 1-1: new full speed USB device using s3c2410-ohci and 2
ub(1.2): GetMaxLUN returned 0, using 1 LUNs
/dev/ub/a: p1
表示usb設備已經掛載到/dev/ub/a/part1目錄下
4. 加入中文字體庫(可惜在我的板上還是沒能正常顯示中文~_~,知道的朋友麻煩告訴我一聲,大家一起探討)
│ │ Native Language Support --->
│ │<*> Simplified Chinese charset (CP936, GB2312)
│ │<*> NLS UTF8
以下是掛載usb設備后的顯示:
[root@luofuchong /]# mount -t vfat -o iocharset=cp936 /dev/ub/a/part1 /mnt
[root@luofuchong /]# ls /mnt
cramfs-1.1.tar.gz netkit-base-0.17.tar.gz thttpd-2.25b.tar.gz
lfc settings.dat . . I. .. . .txt
三、一點心得
四、
呵呵,說了一大堆的廢話,希望不要見怪。畢竟我對usb設備了解不多,如果有什麼說錯的地方請各位大蝦見諒。其實關於usb驅動的移植在網上有不少的貼,我在這裡只對針對我的經歷作一點總結而已,希望能對大家有一點的幫助^_^
[admin via 研發互助社區 ] linux下USB驅動移植心得已經有2438次圍觀
http://cocdig.com/docs/show-post-42095.html