Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - andyzn

Pages: [1]
1
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« 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.

2
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« 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]

3
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« 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]

4
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 11, 2006, 05:13:41 am »
I am happy to say, my windows host could recognize the "Linux Usb mass storage " as a disk just now. But still could not be format as FAT OR FAT32 by windows host. And I have change the size of back_file to 32M.

I used the patch again and change some code from that patch.
stupid me.
pxa27x_udc.h is not used,.

usb_eb_autoconfig() in file_storage.c is useless, I
replace it with pxa2x_ep_config() in pxa27x_udc.h.

Later I will write down all my experience.

Thanks a lot.

5
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 11, 2006, 02:44:01 am »
rootfs is not mounted while open /root/back_file,according to the msg.

Quote
pxa27x_udc: version 23-Sep-2004
***************andy_error = -2********* /*this is the error=PTR_ERR(filp)*/
g_file_storage gadget-lun0: unable to open backing file: /root/back_file
mice: PS/2 mouse device common for all mice
ac97_codec: AC97 Audio codec, id: CRY52 (Cirrus Logic CS4299 rev D)
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
NET: Registered protocol family 1
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 108K
IRQ41 (GPIO9): rising edges
VFS: Can't find an ext2 filesystem on dev ram0.
ads7843 : open [pid=834]
[root@emdoor ~]#
[div align=\"right\"][a href=\"index.php?act=findpost&pid=134632\"][{POST_SNAPBACK}][/a][/div]

6
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 11, 2006, 12:19:02 am »
after dmesg,below is the information while rebooting.

Built 1 zonelists
Kernel command line: console=ttyS0,115200 mem=64M root=1F02 rw
PID hash table entries: 512 (order: 9, 8192 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 64MB = 64MB total
Memory: 62080KB available (2213K code, 391K data, 108K init)
Calibrating delay loop... 519.37 BogoMIPS (lpj=2596864)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. © 2001-2003 Red Hat, Inc.
Initializing Cryptographic API
Console: switching to colour frame buffer device 80x30
IRQ54 (GPIO22): falling edges
ads7843: touch screen driver initialized
SA1100 Real Time Clock driver v1.00
ttyS0 at MMIO 0x40100000 (irq = 22) is a FFUART
ttyS1 at MMIO 0x40700000 (irq = 20) is a STUART
ttyS2 at MMIO 0x40200000 (irq = 21) is a BTUART
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
PP_addr=0x1300
eth0: cs8900 rev K found at 0xf0000300 no EEPROM
cs89x0: No EEPROM, relying on command line....
cs89x0 media RJ-45, IRQ 41, programmed I/O, MAC 00:0b:f4:2f:9b:e5
Probing flash0 at physical address 0x00000000 (32-bit bankwidth)
flash0: Found 2 x16 devices at 0x0 in 32-bit bank
 Intel/Sharp Extended Query Table at 0x010A
 Intel/Sharp Extended Query Table at 0x010A
 Intel/Sharp Extended Query Table at 0x010A
 Intel/Sharp Extended Query Table at 0x010A
Using buffer write method
cfi_cmdset_0001: Erase suspend on write enabled
0: offset=0x0,size=0x10000,blocks=4
1: offset=0x40000,size=0x40000,blocks=255
flash0: 1 set(s) of 2 interleaved chips --> 16 partitions of 4096 KiB
Using static partitions on flash0
Creating 3 MTD partitions on "flash0":
0x00000000-0x00040000 : "boot"
0x00040000-0x001c0000 : "kernel"
0x001c0000-0x04000000 : "rootfs"
pxa27x-ohci pxa27x-ohci: new USB bus registered, assigned bus number 1
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
usbcore: registered new driver usbhid
drivers/usb/input/hid-core.c: v2.0:USB HID core driver
pxa27x_udc: version 23-Sep-2004
***************andy_error = -2********* /*this is the error=PTR_ERR(filp)*/
g_file_storage gadget-lun0: unable to open backing file: /root/back_file
mice: PS/2 mouse device common for all mice
ac97_codec: AC97 Audio codec, id: CRY52 (Cirrus Logic CS4299 rev D)
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
NET: Registered protocol family 1
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 108K
IRQ41 (GPIO9): rising edges
VFS: Can't find an ext2 filesystem on dev ram0.
ads7843 : open [pid=834]
[root@emdoor ~]#

7
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 11, 2006, 12:06:59 am »
I have checked the error, error = PTR_ERR(filp)
          error = -2

IN Linux/include/asm-generic/errno-base.h
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H

 #define EPERM            1      /* Operation not permitted */
#define ENOENT           2      /* No such file or directory */
 #define ESRCH            3      /* No such process */
 #define EINTR            4      /* Interrupted system call */
 #define EIO              5      /* I/O error */

So why no such file or directory ??



Quote
What does filp indicate the error is?

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

8
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 10, 2006, 11:29:49 pm »
In gadget/gadget_chips.h

#ifdef CONFIG_USB_GADGET_PXA27X
#define gadget_is_pxa27x(g)     !strcmp("pxa27x_udc", (g)->name)
#else
#define gadget_is_pxa27x(g)     0
#endif

In gadget/file_storage.c
                if (................)
                else if(gadget_is_pxa(fsg->gadget))
                        mod_data.release = __constant_cpu_to_le16(0x0303);

                else if (gadget_is_sh(fsg->gadget))
                        mod_data.release = __constant_cpu_to_le16(0x0304);

                /* The sa1100 controller is not supported */

                else if (gadget_is_goku(fsg->gadget))
                        mod_data.release = __constant_cpu_to_le16(0x0306);
                else if (gadget_is_mq11xx(fsg->gadget))
                        mod_data.release = __constant_cpu_to_le16(0x0307);
                else if (gadget_is_omap(fsg->gadget))
                        mod_data.release = __constant_cpu_to_le16(0x0308);
                else if (gadget_is_lh7a40x(gadget))
                        mod_data.release = __constant_cpu_to_le16 (0x0309);
                else {
                        WARN(fsg, "controller '%s' not recognized\n",
                                fsg->gadget->name);
                        mod_data.release = __constant_cpu_to_le16(0x0399);
                 }


This has been fixed by:

replace gadget_is_pxa(fsg->gadget) by
(strcmp("pxa27x_udc", fsg->gadget->name)==0)
I don't think anything changed,however, the error "controller not recognized"
disappeared.

Quote
I didn't notice it before, but this can't really be a good sign:

Quote
g_file_storage gadget: controller 'pxa27x_udc' not recognized

I'm not sure what could be causing this problem I'm afraid.


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

9
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 10, 2006, 08:18:01 am »
Oh, sorry.

Actually it is

[root@Bill ~]fdisk -S 8 -H 16 -C 128 /root/back_file

and the partition is created by fdisk in this step.

The partitions information:

Command(m for help) p
 Device Boot         Start         End      Blocks   Id  System
 /root/back_file1          1        128                        Linux

maybe I should try mkXXfs /root/back_file.


Quote
What does filp indicate the error is?

Your file may need a filesystem, though I'm not altogether sure about that. In fact, it looks like the code doesn't even get this far.

[root@Bill ~]fdisk -S 8 -H 16 -C 128 /root/disk

/root/disk is not the backing file afaict...


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

10
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 07, 2006, 02:14:20 am »
Thanks for that. But the patch dosen't work.

And this time I make the g_file_storage module builed in while compling.

Then make some changes in file_storage.c

/**********************************************************************/
static char             *file[MAX_LUNS] = {"/root/back_file", };/* changed*/
static int              ro[MAX_LUNS] = {0, };
/**********************************************************************/

but while rebooting, it says unable to open "/root/back_file".

ERROR WHILE REBOOTING:
pxa27x_udc: version 23-Sep-2004
g_file_storage gadget: controller 'pxa27x_udc' not recognized
g_file_storage gadget-lun0: unable to open backing file: /root/back_file

the code related is here:

static int open_backing_file(.............)
{
.......
.......
/* R/W if we can, R/O if we must */
        ro = curlun->ro;
        if (!ro) {
                filp = filp_open(filename, O_RDWR | O_LARGEFILE, 0);
                if (-EROFS == PTR_ERR(filp))
                        ro = 1;
        }
        if (ro)
                filp = filp_open(filename, O_RDONLY | O_LARGEFILE, 0);
        if (IS_ERR(filp)) {
                LINFO(curlun, "unable to open backing file: %s\n", filename);/***/
                return PTR_ERR(filp);
        }

.......
.......
}

the /root/back_file is created like this:
[root@Bill ~]vi /root/back_file
[root@Bill ~]dd bs=1M count=8 if=/dev/zero of=/root/back_file
[root@Bill ~]fdisk -S 8 -H 16 -C 128 /root/disk
Above is from llinux-usb.org/gadget/file_storage.html
then
[root@Bill ~]chmod 777 /root/back_file


file_storage.c I have changed is attached

Quote
I don't know, but a quick google turned up some posts and patches which might be of use:

http://www.nabble.com/pxa27x_udc-fails-w-g...l-t1036446.html


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

11
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 05, 2006, 04:35:47 am »
Here is sth after dmesg:

[root@emdoor bin]# dmesg
...........
...........
g_file_storage: Ignoring new-style parameters in presence of obsolete ones
g_file_storage gadget: controller 'pxa27x_udc' not recognized
g_file_storage gadget: unable to autoconfigure all endpoints

12
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 05, 2006, 04:14:53 am »
Today I found g_ether is builded in.
SO I recompiled the kernel.Deselect g_ether and made FSG STORAGE a module.

When I  "modprobe g_file_storage file=/root/data" again, "Device busy" error disappear.
Another error occur,and more confused:

[root@emdoor 2.6.11-XSBase27x]# insmod g_file_storage file=/root/back_file
Using /lib/modules/2.6.11-XSBase27x/kernel/drivers/usb/gadget/g_file_storage.ko
insmod: cannot insert `/lib/modules/2.6.11-XSBase27x/kernel/drivers/usb/gadget/g_file_storage.ko': Unknown error 524 (-1): Unknown error 524


524 is for what?

Quote
How do you get a terminal prompt, not over a usb ethernet link hopefully?

Do you have g_ether loaded? If so, you'll need to remove it.


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

13
Angstrom & OpenZaurus / How To Load G_file_storage.ko? Error Occus
« on: July 03, 2006, 10:21:11 am »
I have a board with USB slave 1.1, and Linux installed on it.

I have connected it with a PC through a USB cable.

And I want to make the PC "know" the device?

on the board(the kernel is 2.6.11):

1. start Linux

2. dd bs=1M count=8 if=/dev/zero /root/data   (FAT32)
   
3. modprobe g_file_storage file=/root/data

HERE IS THE ERROR MESSAGE:
*****************************************
Using /lib/modules/2.6.11-XSBase27x/kernel/drivers/usb/gadget/g_file_storage.ko
insmod: cannot insert `/lib/modules/2.6.11-XSBase27x/kernel/drivers/usb/gadget/g
_file_storage.ko': Device or resource busy (-1): Device or resource busy
modprobe: failed to load module g_file_storage
*****************************************

which device is busy?

Or
what should I do before I "modprobe g_file_storage..."?

Pages: [1]