分类: LINUX
2010-02-24 11:03:05
先前一直被g_file_storage写大文件时比较慢的问题困扰,终于在网上找到了解决方法。现整理如下:
1.修改arch/arm/plat-s3c24xx/common-smdk.c
/*USB device上拉电阻处理 */
static void smdk2410_udc_pullup(enum s3c2410_udc_cmd_e cmd)
{
u8 *s3c2410_pullup_info[] = {
" ",
"Pull-up enable",
"Pull-up disable",
"UDC reset, in case of"
};
printk("smdk2410_udc: %s\n",s3c2410_pullup_info[cmd]); s3c2410_gpio_cfgpin(S3C2410_GPG(9), S3C2410_GPIO_OUTPUT);
switch (cmd)
{
case S3C2410_UDC_P_ENABLE :
s3c2410_gpio_setpin(S3C2410_GPG(9), 1); //set gpg9 output HIGH break; case S3C2410_UDC_P_DISABLE :
s3c2410_gpio_setpin(S3C2410_GPG(9), 0); //set gpg9 output LOW break; case S3C2410_UDC_P_RESET :
//FIXME!!!
break;
default:
break;
}
}
static struct s3c2410_udc_mach_info smdk2410_udc_cfg __initdata = {
.udc_command = smdk2410_udc_pullup,
};
static struct platform_device *smdk2410_devices[] __initdata = {
…,
&s3c_device_usbgadget, /*USB gadget device设备登记*/
};
在void __init smdk_machine_init(void)函数中添加
s3c24xx_udc_set_platdata(&smdk2410_udc_cfg); /* 初始化*/
2.修改drivers/usb/gadget/file_storage.c
在static int fsg_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)函数中
- fsg->ep0req->zero = rc < w_length;
+ fsg->ep0req->zero = rc < w_length \
&& (rc % gadget->ep0->maxpacket) == 0;
3.修改drivers/usb/gadget/s3c2410_udc.c
在static void s3c2410_udc_handle_ep(struct s3c2410_ep *ep)函数中
struct s3c2410_request *req;
int is_in = ep->bEndpointAddress & USB_DIR_IN;
u32 ep_csr1;
u32 idx;
+ handle_ep_again:
……
if ((ep_csr1 & S3C2410_UDC_OCSR1_PKTRDY) && req) {
s3c2410_udc_read_fifo(ep,req);
+ if (s3c2410_udc_fifo_count_out())
+ goto handle_ep_again;
}
4.修改内核配置
<*> USB Gadget Support --->
USB Peripheral Controller (S3C2410 USB Device Controller) --> S3C2410 USB Device Controller
[] S3C2410 udc debug messages
5.编译及加载
#make zImage
#make modules
# insmod g_file_storage.ko file=/dev/mmcblk0p1 stall=0 removable=1
经过在2.6.32.5内核上的测试拷贝5MB大小的文件很快完成