Author Topic: How To Load G_file_storage.ko? Error Occus  (Read 9643 times)

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
How To Load G_file_storage.ko? Error Occus
« Reply #15 on: July 11, 2006, 05:28:07 am »
Glad you've got it sorted


Si
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

andyzn

  • Newbie
  • *
  • Posts: 13
    • View Profile
How To Load G_file_storage.ko? Error Occus
« Reply #16 on: July 11, 2006, 09:54:25 am »
The host(windows XP) always says "it should be formatted". I click yes, but it

failed just before the format process finished. Maybe bad block in Flash?


Quote
Glad you've got it sorted
Si
[div align=\"right\"][a href=\"index.php?act=findpost&pid=134660\"][{POST_SNAPBACK}][/a][/div]

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
How To Load G_file_storage.ko? Error Occus
« Reply #17 on: July 11, 2006, 10:05:29 am »
I'm not sure. You could always format it using the board before you load the mass-storage module.

I had some issues with WinXP recognising my Z as a mass-storage device, but not actually working a long while back when I was first fiddling with the storage_fd.o module. These issues seemed to just go away (or there may have been a patch - can't remember - try a search of this forum).


Si
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

andyzn

  • Newbie
  • *
  • Posts: 13
    • View Profile
How To Load G_file_storage.ko? Error Occus
« Reply #18 on: July 12, 2006, 01:58:05 am »
That is interesting.
I changed the partition type to Win95 FAT32 (LBA) on the board:
and everything is OK now.

Command (m for help): p

Disk /root/back_file: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

          Device Boot    Start       End    Blocks   Id  System
/root/back_file1               1           4       32098+   c  Win95 FAT32 (LBA)


Quote
I'm not sure. You could always format it using the board before you load the mass-storage module.

I had some issues with WinXP recognising my Z as a mass-storage device, but not actually working a long while back when I was first fiddling with the storage_fd.o module. These issues seemed to just go away (or there may have been a patch - can't remember - try a search of this forum).


Si
[div align=\"right\"][a href=\"index.php?act=findpost&pid=134682\"][{POST_SNAPBACK}][/a][/div]

andyzn

  • Newbie
  • *
  • Posts: 13
    • View Profile
How To Load G_file_storage.ko? Error Occus
« Reply #19 on: July 12, 2006, 02:39:17 am »
Goal: To simulate the flash of the board to be a USB DISK(In Host View).

Background: XScale Pxa27x Board, USB Slave 1.1, Linux 2.6 11, USB cable, a PC(as host) with Windows XP or Linux.

General: make use of GADGET DRIVER to specify to space in the flash,which is
              used as "USB disk".

Step 1:  

                      FILE_STORAGE.C NEED CHANGED

*****************************************************************
add '&' at two places, need a pointer accord to macro module_param_array.

module_param_array(file, charp, &mod_data.num_filenames, S_IRUGO);
MODULE_PARM_DESC(file, "names of backing files or devices");

module_param_array(ro, bool, &mod_data.num_ros, S_IRUGO);
MODULE_PARM_DESC(ro, "true to force read-only");
*****************************************************************
make use of this patch or change so code in usb/gadget/file_storage.c

--- kernel26/drivers/usb/gadget/file_storage.c.orig 2005-08-16 17:54:58 +0200
+++ kernel26/drivers/usb/gadget/file_storage.c 2005-08-16 18:01:15 +0200
@@ -288,6 +288,14 @@
 #define hw_optimize(g) do {} while (0)
 #endif
 
+/*
+ * PXA27X_UDC
+ */
+#ifdef CONFIG_USB_GADGET_PXA27X
+extern struct usb_ep* pxa27x_ep_config(struct usb_gadget *gadget,
+ struct usb_endpoint_descriptor *desc, int config, int interface, int alt);
+#endif
+
 
 /*
  * This driver assumes self-powered hardware and has no way for users to
@@ -3915,13 +3923,27 @@
 
  /* Find all the endpoints we will use */
  usb_ep_autoconfig_reset(gadget);
+#ifdef CONFIG_USB_GADGET_PXA27X
+ ep = pxa27x_ep_config (gadget, &fs_bulk_in_desc,
+ CONFIG_VALUE,
+ (int)intf_desc.bInterfaceNumber,
+ (int)intf_desc.bAlternateSetting);
+#else
  ep = usb_ep_autoconfig(gadget, &fs_bulk_in_desc);
+#endif
  if (!ep)
  goto autoconf_fail;
  ep->driver_data = fsg; // claim the endpoint
  fsg->bulk_in = ep;
 
+#ifdef CONFIG_USB_GADGET_PXA27X
+ ep = pxa27x_ep_config (gadget, &fs_bulk_out_desc,
+ CONFIG_VALUE,
+ (int)intf_desc.bInterfaceNumber,
+ (int)intf_desc.bAlternateSetting);
+#else
  ep = usb_ep_autoconfig(gadget, &fs_bulk_out_desc);
+#endif
  if (!ep)
  goto autoconf_fail;
  ep->driver_data = fsg; // claim the endpoint

for someone who is not familiar with how to patch a file, change some code like this:
#include "pxa27x_udc.h" or "extern struct usb_ep* pxa27x_ep_config...." which could be found in pxa27x_udc.c
then replace usb_ep_autoconfig with pxa27x_ep_config in two places as the patch does.

Step 2:

          COMPILE KERNEL, DOWNLOAD MODULES TO BOARD
In your linux host:
make menuconfig // remember to make gadgat file storage as module
make zImage
make modules
make modules_install //after this, go to /lib/modules/x.x.xx to find your module such as g_file_storage.ko

download the files in x.x.xx to your board, and place them in the same directory.

STEP 3:

            CREATE A SPACE FOR USB STORAGE

vi /root/back_file
dd if=1M count=32 if=/dev/zero of=/root/back_file
fdisk -S 8 -H 16 -C 512 /root/back_file  //I made it a Win95 FAT32 (LBA)

u could find content related here:
FSG

STEP 4:

            INSERT THE MODULE AND TEST
insmod g_file_storage file=/root/back_file
when "using /lib/modules/x.xx.xx/kernel/driver/usb/gadget/g_file_storage.ko" is displayed, insert is finished.

make sure your board is connected by the USB cable with PC(host), my host is Widows XP. After ONE MINUTE, just like a USB DISK is inserted,  a new driver is shown.(If not, go to the computer manager to see)

Finally, u could test the function of read and write.
It is OK for me,just like a USB DISK.

I hope this is helpful to some people.
I will be apreciate if u could give me some advice.
Thanks to lardman.
Thanks to everybody.
« Last Edit: July 12, 2006, 02:43:34 am by andyzn »