PDA

Bekijk de volledige versie : linuxrc bug? - WL-500g not booting from usb drive with hub



daniel632
14-01-2006, 17:57
Setup:
I am trying to boot my router from a usb memory stick which is connected to a usb 1.1 4-port hub. Besides the stick, there are two usb printers and a soundcard connected to the hub, which is currently powered by an external power supply. For preparing the usb drive, I followed the instructions on Oleg's firmware page.

Problem:
When there are more than two devices connected to the hub, the router does not boot from the usb drive, but from internal flash, the usb drive is mounted as /tmp/harddisk, and an ftp server is started...

I suspect that this is because of the two seconds delay in the linuxrc script that makes the router wait until the usb devices are created in the kernel. It looks like this is too slow when there is a hub with a lot of devices connected.

To test this, I ran some parts of the linuxrc script from the commandline, pasting the whole text at once. I also inserted two 'date' commands to get an idea of the speed. Here is the code executed on the command line and it's output:


[admin@(none) root]$ date
Sat Jan 14 18:31:36 MEZ 2006
[admin@(none) root]$ insmod ide-mod && insmod ide-probe-mod && insmod ide-disk
insmod: ide-mod.o: no module by that name found
[admin@(none) root]$ insmod usbcore; insmod usb-ohci
Using /lib/modules/2.4.20/kernel/drivers/usb/usbcore.o
insmod: A module named usbcore already exists
Using /lib/modules/2.4.20/kernel/drivers/usb/host/usb-ohci.o
[admin@(none) root]$ insmod ehci-hcd && insmod usb-uhci && sleep 2s
insmod: ehci-hcd.o: no module by that name found
[admin@(none) root]$ insmod scsi_mod && insmod sd_mod && insmod usb-storage
Using /lib/modules/2.4.20/kernel/drivers/scsi/scsi_mod.o
Using /lib/modules/2.4.20/kernel/drivers/scsi/sd_mod.o
Using /lib/modules/2.4.20/kernel/drivers/usb/storage/usb-storage.o
[admin@(none) root]$ sleep 2s; date
Sat Jan 14 18:31:39 MEZ 2006
[admin@(none) root]$ mount -t ext3 -o ro "/dev/scsi/host0/bus0/target0/lun0/part1" /mnt || mount -t ext2 -o ro "/dev/scsi/host0/bus0/target0/lun0/part1" /mnt
mount: Mounting /dev/scsi/host0/bus0/target0/lun0/part1 on /mnt failed: No such file or directory
mount: Mounting /dev/scsi/host0/bus0/target0/lun0/part1 on /mnt failed: No such device

And here are the corresponding syslog entries:


Jan 14 18:31:37 kernel: usb-ohci.c: USB OHCI at membase 0xb8004000, IRQ 2
Jan 14 18:31:37 kernel: usb-ohci.c: usb-00:04.0, PCI device 14e4:4715
Jan 14 18:31:37 kernel: usb.c: new USB bus registered, assigned bus number 1
Jan 14 18:31:37 kernel: hub.c: USB hub found
Jan 14 18:31:37 kernel: hub.c: 2 ports detected
Jan 14 18:31:37 kernel: SCSI subsystem driver Revision: 1.00
Jan 14 18:31:37 kernel: Initializing USB Mass Storage driver...
Jan 14 18:31:37 kernel: usb.c: registered new driver usb-storage
Jan 14 18:31:37 kernel: USB Mass Storage support registered.
Jan 14 18:31:37 kernel: hub.c: new USB device 00:04.0-1, assigned address 2
Jan 14 18:31:37 kernel: hub.c: USB hub found
Jan 14 18:31:37 kernel: hub.c: 4 ports detected
Jan 14 18:31:38 kernel: hub.c: new USB device 00:04.0-1.1, assigned address 3
Jan 14 18:31:38 kernel: hub.c: USB hub found
Jan 14 18:31:38 kernel: hub.c: 1 port detected
Jan 14 18:31:39 kernel: hub.c: new USB device 00:04.0-1.2, assigned address 4
Jan 14 18:31:39 kernel: usb.c: USB device 4 (vend/prod 0x3f0/0x1504) is not claimed by any active driver.
Jan 14 18:31:39 kernel: hub.c: new USB device 00:04.0-1.3, assigned address 5
Jan 14 18:31:39 kernel: usb.c: USB device 5 (vend/prod 0x67b/0x2305) is not claimed by any active driver.
Jan 14 18:31:40 kernel: hub.c: new USB device 00:04.0-1.4, assigned address 6
Jan 14 18:31:40 kernel: usb.c: USB device 6 (vend/prod 0x41e/0x3020) is not claimed by any active driver.
Jan 14 18:31:40 USB audio: attached
Jan 14 18:31:40 kernel: hub.c: new USB device 00:04.0-1.1.1, assigned address 7
Jan 14 18:31:40 kernel: scsi0 : SCSI emulation for USB Mass Storage devices
Jan 14 18:31:40 kernel: Vendor: Prolific Model: USB Flash Disk Rev: PROL
Jan 14 18:31:40 kernel: Type: Direct-Access ANSI SCSI revision: 02
Jan 14 18:31:40 kernel: Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
Jan 14 18:31:40 kernel: SCSI device sda: 256000 512-byte hdwr sectors (131 MB)
Jan 14 18:31:40 kernel: sda: Write Protect is off
Jan 14 18:31:40 kernel: p1
Jan 14 18:31:46 kernel: kjournald starting. Commit interval 5 seconds
Jan 14 18:31:46 kernel: EXT3 FS 2.4-0.9.19, 19 August 2002 on sd(8,1), internal journal
Jan 14 18:31:46 kernel: EXT3-fs: mounted filesystem with ordered data mode.
Jan 14 18:31:46 USB storage: ext3 fs mounted to /tmp/harddisk
Jan 14 18:31:46 FTP server: daemon is started

As you can see, the mount command is started at 18:31:39, but the scsi device is created at 18:31:40, so mount has a good reason to fail.

When there are only two devices connected to the hub, the router boots from the usb drive. Also the commands extracted from linuxrc work nicely when the delay is increased to 4s.

Question:
Is there a way to increase the delay in the linuxrc script?

Oleg
31-01-2006, 17:13
Is there a way to increase the delay in the linuxrc script?
The only way at the moment is recompiling a firmware. Yet another way is to replace hub with another one.

cmuarg
20-11-2008, 11:05
Edit: It really seems to be a timing problem. If I wait to plug the second reader until booted then it seems to work.
---------------------------------------------------------------------------------------------------------------

Could it be that there is a kernel limit of two usb devices?
I've played around with 2 different hub's, 2 usbserial readers and 2 "disks" but can't get more than 2 devices working at the same time no matter how they are connected.

Ex. 1 disk & 1 reader on a hub is OK, but with one more reader (on the hub or in the 2nd w500 port), only one reader dev is created.
Part of dmesg output below.

Without the disk, two readers can be connected direct to the w500 usb ports or via a hub in any combination.

If there is a kernel limit, where can I find it?

Thanks


ehci_hcd 01:03.2: USB 2.0 enabled, EHCI 1.00, driver 2003-Dec-29/2.4
hub.c: USB hub found
hub.c: 4 ports detected
usb.c: registered new driver usblp
printer.c: v0.13: USB Printer Device Class driver
SCSI subsystem driver Revision: 1.00
hub.c: connect-debounce failed, port 1 disabled
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
hub.c: new USB device 01:03.2-2, assigned address 2
hub.c: USB hub found
hub.c: 4 ports detected
usb.c: registered new driver serial
usbserial.c: USB Serial support registered for Generic
usbserial.c: USB Serial Driver core v1.4
usbserial.c: USB Serial support registered for FTDI SIO
usbserial.c: USB Serial support registered for FTDI 8U232AM Compatible
usbserial.c: USB Serial support registered for FTDI FT232BM Compatible
usbserial.c: USB Serial support registered for USB-UIRT Infrared Receiver/Transmitter
usbserial.c: USB Serial support registered for Home-Electronics TIRA-1 IR Transceiver
ftdi_sio.c: v1.3.5:USB FTDI Serial Converters Driver
hub.c: new USB device 01:03.2-2.2, assigned address 3
scsi0 : SCSI emulation for USB Mass Storage devices
Vendor: SanDisk Model: Cruzer Rev: 8.01
Type: Direct-Access ANSI SCSI revision: 02
Vendor: SanDisk Model: Cruzer Rev: 8.01
Type: CD-ROM ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sda: 3907711 512-byte hdwr sectors (2001 MB)
sda: Write Protect is off
Partition check:
/dev/scsi/host0/bus0/target0/lun0: p1
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 3
hub.c: new USB device 01:03.2-2.3, assigned address 4
usb.c: not enough configurations
usb.c: unable to get device 4 configuration (error=-22)
hub.c: new USB device 01:03.2-2.3, assigned address 5
usb.c: not enough configurations
usb.c: unable to get device 5 configuration (error=-22)
hub.c: new USB device 01:03.0-1, assigned address 2
usbserial.c: FTDI FT232BM Compatible converter detected
usbserial.c: FTDI FT232BM Compatible converter now attached to ttyUSB0 (or usb/tts/0 for devfs)
kjournald starting. Commit interval 5 seconds
EXT3-fs warning: maximal mount count reached, running e2fsck is recommended
EXT3 FS 2.4-0.9.19, 19 August 2002 on sd(8,1), internal journal
EXT3-fs: recovery complete.
EXT3-fs: mounted filesystem with ordered data mode.

cmuarg
02-12-2008, 13:35
After some trial and error, it seems like the following introduced delay fix the problem (don’t ask me why):

Firmware 1.9.2.7-10, file src/linux/linux/drivers/usb/usb.c

In the function usb_new_device()



……
err = usb_get_device_descriptor(dev);
if (err < (signed)sizeof(dev->descriptor)) {
if (err < 0)
err("unable to get device descriptor (error=%d)", err);
else
err("USB device descriptor short read (expected %Zi, got %i)",
sizeof(dev->descriptor), err);

clear_bit(dev->devnum, &dev->bus->devmap.devicemap);
dev->devnum = -1;
return 1;
}

// added delay
#if 1 // wait for data
{
int wcnt;
for(wcnt=0; wcnt<20 && dev->descriptor.bNumConfigurations==0; wcnt++)
{
wait_ms(50);
// err("ewait(%d)=%d", wcnt+1, dev->descriptor.bNumConfigurations);
}
}
#endif
…….

cmuarg
08-08-2009, 11:08
You have to set up and build the kernel as decribed in http://oleg.wl500g.info.

jplevens
14-03-2012, 15:28
It could be that the delay help to wait the usb link establishement.
In that case I would exepect the delay should be added before the usb_get_device_descriptor() function.
It could be that the enumeration is started 3 times in loop, and the delay added after the usb_get_device_descriptor() help for the next or last loop.