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

andyzn

  • Newbie
  • *
  • Posts: 13
    • View Profile
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..."?

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
How To Load G_file_storage.ko? Error Occus
« Reply #1 on: July 03, 2006, 10:27:33 am »
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
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 #2 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]

andyzn

  • Newbie
  • *
  • Posts: 13
    • View Profile
How To Load G_file_storage.ko? Error Occus
« Reply #3 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

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
How To Load G_file_storage.ko? Error Occus
« Reply #4 on: July 05, 2006, 07:03:37 am »
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
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 #5 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]

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
How To Load G_file_storage.ko? Error Occus
« Reply #6 on: July 10, 2006, 07:25:37 am »
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
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 #7 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]
« Last Edit: July 10, 2006, 09:14:50 am by andyzn »

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
How To Load G_file_storage.ko? Error Occus
« Reply #8 on: July 10, 2006, 06:57:25 pm »
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
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 #9 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]

andyzn

  • Newbie
  • *
  • Posts: 13
    • View Profile
How To Load G_file_storage.ko? Error Occus
« Reply #10 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]

andyzn

  • Newbie
  • *
  • Posts: 13
    • View Profile
How To Load G_file_storage.ko? Error Occus
« Reply #11 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 ~]#

andyzn

  • Newbie
  • *
  • Posts: 13
    • View Profile
How To Load G_file_storage.ko? Error Occus
« Reply #12 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]

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
How To Load G_file_storage.ko? Error Occus
« Reply #13 on: July 11, 2006, 05:05:08 am »
I was going to suggest that.

Have you tried using g_file_storage as a stand-alone module?

There are also lots of:

Quote
usbcore: registered new driver usbfs
usbcore: registered new driver hub

Which looks like the usb port is being used as a host - this is not what you want for mass storage. Assuming this is the same port, you may need to change it from host to client mode (unless this happens automatically...?).


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 #14 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.