usb 问题解决方法.txt

来源:互联网 发布:可视化分析软件 编辑:程序博客网 时间:2024/05/22 03:15
sudo make modules_install ARCH=arm INSTALL_MOD_PATH=/home/winson/rootfs/
make menuconfig
usb support
select usb devcie filesystem


mount -t usbfs none /proc/bus/usb


cat /proc/bus/usb/devices
mknod /dev/mouse c 13 32
cat /dev/mouse


手动创建节点mknod mouse c 13 32,测试鼠标cat mouse,移动鼠标有数据打印出来。




1.未作移植,插入U盘后提示如下


[root@Emux/]#usb 1-1: new full speed USB device using s3c2410-ohci and address 2
usb 1-1: device descriptor read/64, error -62
usb 1-1: device descriptor read/64, error -62
usb 1-1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1: device descriptor read/64, error -62
usb 1-1: device descriptor read/64, error -62
usb 1-1: new full speed USB device using s3c2410-ohci and address 4
usb 1-1: device not accepting address 4, error -62
usb 1-1: new full speed USB device using s3c2410-ohci and address 5
usb 1-1: device not accepting address 5, error -62
hub 1-0:1.0: unable to enumerate USB device on port 1


 


2.代码修改——修改arch/arm/mach-s3c2410/mach-smdk2410.c


+#include <linux/device.h>
+#include <linux/delay.h>
+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\n");
+s3c_device_usb.dev.platform_data = &usb_sbc2410_info;
+while(upllvalue!=__raw_readl(S3C2410_UPLLCON))
+{
+__raw_writel(upllvalue,S3C2410_UPLLCON);
+mdelay(1);
+}
+return 0;
+}


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);
+usb_sbc2410_init();
}


3.内核配置
>让内核支持热插拔


General setup  --->  Support for hot-pluggable devices


>USB驱动设置


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


                                        ---> USB Mass Storage support


                                              USB Monitor


>加入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


做完这些后,插入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


>使能(DOS分区)CONFIG_MSDOS_PARTITION


File systems  ---> Partition Types 


                                ---> PC BIOS (MSDOS partition tables) support


以下是我的内核插入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目录下


>加入中文字体库


Native Language Support 


                               ---> Simplified Chinese charset (CP936, GB2312) 


                                      NLS UTF8


以下是挂载usb设备后的显示:
[root@Emux /]# mount -t vfat -o iocharset=cp936 /dev/ub/a/part1 /mnt
[root@Emux /]# ls /mnt


 


4.移植小结


>如果想知道内核有没有识别出u盘的话可以执行命令:cat /proc/partitions ,看看插入USB前后分区信息有什么不同就知道了 


>另外,如果想让内核把它当成SCSI设备来处理的话


Device Drivers  ---> Block devices 


                                      --->  Low Performance USB Block driver     去掉


Device Drivers  --->SCSI device support


                                      --->  SCSI disk support                                  添加


个人觉得使用usb设备的话Low Performance USB Block driver比SCSI disk要好


>一般都会新建一个/dev/sda1的链接指向usb设备的挂载点的,可以在启动文件中使用命令ln -s xxx xxx来建立这个链接


 


5.问题小结


插入u盘时显示:


[root@/]#usb 1-1: new full speed USB device using s3c2410-ohci and address 4    
usb 1-1: device descriptor read/64, error -62                                   
usb 1-1: device descriptor read/64, error -62                                   
usb 1-1: new full speed USB device using s3c2410-ohci and address 5             
usb 1-1: device descriptor read/64, error -62                                   
usb 1-1: configuration #1 chosen from 1 choice
去掉 Device Drivers--> Real Time Clock


 


插入u盘时显示:
[root@/]#usb 1-1: new full speed USB device using s3c2410-ohci and address 3                usb 1-1: configuration #1 chosen from 1 choice                                 
scsi1 : SCSI emulation for USB Mass Storage devices                            
scsi 1:0:0:0: Direct-Access     Kingston DataTraveler2.0  1.00 PQ: 0 ANSI: 2   
sd 1:0:0:0: [sda] 3903359 512-byte hardware sectors (1999 MB)                  
sd 1:0:0:0: [sda] Write Protect is off                                         
sd 1:0:0:0: [sda] Assuming drive cache: write through                          
sd 1:0:0:0: [sda] 3903359 512-byte hardware sectors (1999 MB)                  
sd 1:0:0:0: [sda] Write Protect is off                                         
sd 1:0:0:0: [sda] Assuming drive cache: write through                          
sda: sda1                                                                     
sd 1:0:0:0: [sda] Attached SCSI removable disk
看似没有问题,但是在挂载的时候出现问题:
Unable to load NLS charset  cp437
FAT: codepage cp437 not found
添加 File systems-->
Native language support-->
Codepage 437 (United States, Canada)


插入后显示和第二次一样;
挂载的时候出现问题:
Unable to load NLS charset iso8859-1                                            


FAT: IO charset iso8859-1 not found
添加 File systems-->
Native language support-->
NLS ISO 8859-1  (Latin 1; Western European Languages)


如果出现以下问题:
usb 1-1: device descriptor read/64, error -110
解决办法:
修改linux-2.6.24/drivers/usb/host/ohci-s3c2410.c
添加头文件:
#include <asm/arch/regs-clock.h>
在s3c2410_start_hc里增加:
unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03);
while (upllvalue != __raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue, S3C2410_UPLLCON);
mdelay(1);



==========================
用开发板模拟一个U盘:
1.在linux内核源码中添加相应的配置:
make menuconfig
Device Drivers->USB support->USB Gadget Support中的三项:
S3C2410 udc debug messages=y、USB Gadget Drivers=M、 File-backed Storage Gadget =M、File-backed Storage Gadget testing version=y


2.编译内核
make 
make modules_install INSTALL_MOD_PATH=/home/bryan/rootfs


3.insmod /lib/modules/2.6.27/drivers/usb/gadget/g_file_storage.ko file=/dev/mtdblock3 stall=0 removeble=1
或者 file=/dev/sda1(代表开发板上的一个U盘)
原创粉丝点击