歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux內核

關於fl2440開發板Linux內核添加USB驅動的問題

添加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=3usb 1-1.2: Product: TransMemory

usb 1-1.2: Manufacturer: TOSHIBA

usb 1-1.2: SerialNumber: FB2F75AFCE3ACE605AE04025sdb: sdb1

掛載命令

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

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

0.jpg KOF97.zip1.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 mainwindowGHO php

(其中你看的?或者亂碼 是因為中文不支持)這樣就可以使用了。

遇到的問題做了一個小小的說明:

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

scsi0 : usb-storage 1-1.3:1.0scsi 0:0:0:0 Direct-Access 5.00 PQ: 0 ANSI: 2scsi 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的設備也是如此。

Copyright © Linux教程網 All Rights Reserved