您的位置:首页 > 运维架构 > Linux

关于fl2440开发板Linux内核添加USB驱动的问题

2016-07-18 15:14 369 查看
添加USB支持:

FL2440添加u盘的挂载比较简单,大部分的内容都是在内核里面做make menuconfig,配置内核

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

[*]legacy /proc/scsi/ support

<*>SCSI disk support

<*> SCSI CDROM support

[*] Probe all LUNs on each SCSI device

[*] 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 (DEPRECATED)

[*] USB device class-devices (DEPRECATED)

<*> USB Monitor

<*> OHCI HCD support

<*> USB Mass Storage support

File systems ---> //配置u盘的文件系统

DOS/FAT/NT Filesystems --->

<*> MSDOS fs support

<*> VFAT (Windows-95) fs support

(936) Default codepage for FAT

(cp936) Default iocharset for FAT

-*- Native language support ---> //配置u盘的语言格式支持,不过感觉着个配置没什么用,中文也支持不了,也许是因为linux对中文的支持并不好吧

<*> Simplified Chinese charset (CP936, GB2312)

<*> ASCII (United States)

<*> NLS UTF-8

添加USB结构体变量,加厂商ID和设备ID

[Ciel@localhost linux-3.0]$ vim drivers/usb/serial/option.c

2964 @@ -51,6 +51,13 @@

2965 static void option_instat_callback(struct urb *urb);

2966

2967 /* Vendor and product IDs */

2968 +static int vendor = 0; /* Add by guowenxue */

2969 +static int product = 0; /* Add by guowenxue */

2970 +

2971 +/* Vendor and product IDs */

2972 +#define OPTION_VENDOR_RESERVED 0xFFFF /* Add by guowenxue */

2973 +#define OPTION_RESERVED_DEVICE 0xFFFF /* Add by guowenxue */

2974 +

2975 #define OPTION_VENDOR_ID 0x0AF0

2976 #define OPTION_PRODUCT_COLT 0x5000

2977 #define OPTION_PRODUCT_RICOLA 0x6000

2978 @@ -446,7 +453,8 @@

2979 .reason = OPTION_BLACKLIST_SENDSETUP

2980 };

2981

2982 -static const struct usb_device_id option_ids[] = {

2983 +static struct usb_device_id option_ids[] = {

2984 + { USB_DEVICE(OPTION_VENDOR_RESERVED, OPTION_RESERVED_DEVICE) }, /* Add by guowenxue */

2985 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },

2986 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },

2987 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },

2988 @@ -1079,6 +1087,15 @@

2989 static int __init option_init(void)

2990 {

2991 int retval;

2992 +

2993 + if ((vendor>0) && (product>0))

2994 + {

2995 + option_ids[0].match_flags = USB_DEVICE_ID_MATCH_DEVICE;

2996 + option_ids[0].idVendor = vendor;

2997 + option_ids[0].idProduct = product;

2998 + printk("Register option drvier for modem vendor=0x%04x product=0x%04x\n", vendor, product);

2999 + }

3000 +

[Ciel@localhost linux-3.0]$ vim arch/arm/mach-s3c2440/mach-smdk2440.c

4 @@ -23,6 +23,13 @@

5 #include <linux/platform_device.h>

6 #include <linux/io.h>

7

8 +/* add by guowenxue for norflash */

9 +#include <linux/gpio_keys.h>

10 +#include <linux/input.h>

11 +#include <linux/mtd/physmap.h>

12 +#include <linux/mtd/mtd.h>

13 +#include <linux/mtd/partitions.h>

14 +

15 #include <asm/mach/arch.h>

16 #include <asm/mach/map.h>

17 #include <asm/mach/irq.h>

18 @@ -44,6 +51,11 @@

19 #include <plat/clock.h>

20 #include <plat/devs.h>

21 #include <plat/cpu.h>

22 +#include <plat/ts.h> /*Add by guowenxue to support Touch screen, 2011.09.06*/

23 +#include <mach/regs-clock.h> /*Add by guowenxue 2012.07.15, for usb_s3c2440_init() */

24 +#include <linux/i2c.h> /*Add by guowenxue 2012.10.22, for AT24C512 driver */

25 +#include <linux/i2c/at24.h> /* Add by guowenxue 2012.10.22, for AT24C512 driver */

26 +#include <linux/delay.h>

27

28 #include <plat/common-smdk.h>

29

30 @@ -102,6 +114,13 @@

31 }

224 +/* Add by guowenxue 2012.07.15, fix device descriptor read/64, error -62 bug, value refer to datasheet P255 */

225 +int usb_s3c2440_init(void)

226 +{

227 + /* Input Frequency is 12.0000MHz, and MDEV=0x38 PDIV=2 SDIV=2, so output frequency 48.00MHz */

228 + unsigned long upllvalue = (0x38<<12)|(0x02<<4)|(0x02);

229 + while (upllvalue != __raw_readl(S3C2410_UPLLCON))

230 + {

231 + __raw_writel(upllvalue, S3C2410_UPLLCON);

232 + mdelay(1);

233 + }

234 +

235 + return 0;

236 +}

237 +

238 static void __init smdk2440_map_io(void)

239 {

240 s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));

241 - s3c24xx_init_clocks(16934400);

242 + s3c24xx_init_clocks(12000000); /*Modify by guowenxue, 2011.08.30*/

243 s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));

244 + usb_s3c2440_init(); /* Add by guowenxue, 2012.07.15 */

245 }

246

重新编译下内核,加载到开发板,插入U盘

usb 1-1.2: New USB device found, idVendor=0930, idProduct=6544

usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3

usb 1-1.2: Product: TransMemory

usb 1-1.2: Manufacturer: TOSHIBA

usb 1-1.2: SerialNumber: FB2F75AFCE3ACE605AE04025

sdb: sdb1


挂载命令

>: mount -t vfat /dev/sdb1 /mnt/usb/

U盘查看>: ls /mnt/usb/

0.jpg KOF97.zip

1.Altium Designer??b.avi RStudio

2016???????????.doc SOPC_Class.rar

?? System Volume Information

??? VMware-workstation-full-9.zip

???? VSX4_Pro_TBYB.exe

????? lzj-???.doc

??Qt?????2.ppt lzj.mpg

??Qt???????.ppt lzj??.doc

CentOS-6.3-i386-LiveCD.iso mainwindow

GHO php


(其中你看的?或者乱码 是因为中文不支持)这样就可以使用了。

遇到的问题做了一个小小的说明:

>:usb 1-1.3: new full speed USB device number 3 using s3c2410-ohci

scsi0 : usb-storage 1-1.3:1.0

scsi 0:0:0:0 Direct-Access 5.00 PQ: 0 ANSI: 2

scsi 0:0:0:0 Attached scsi generic sg0 type 0


这是把U盘识别为光驱了 ,需要检查你的make menuconfig的配置选项有没有改错

遇到挂载不上去有可能是文件系统的问题需要检查你的根文件树或者是make menuconfig对应的根文件树的路径有误

还有一个关于自动挂载的问题,如果你的U盘在板子上显示是sd,也可能有的设备是ub ,这时候可以进入你的根文件树查看是否自动挂载

[Ciel@localhost etc]$ vim mdev.conf

sd[a-z][0-9] 0:0 0777 @(mount /dev/$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)

ub[a-z] 0:0 0777 $(umount /mnt/usb)

mmcblk[0-9]p[0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/sdc)

mmcblk[0-9] 0:0 0777 $(umount /mnt/sdc)


sd的设备后置从 a-z 或者 0-9 都可以显示自动挂载


ub的设备后置从 a-z 可以显示自动挂载,如果你的ub设备显示数字,

可以在第三行改为ub[a-z][0-9] 0:0 0777 (mount /dev/$MDEV /mnt/usb)

mmcblk的设备也是如此。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: