Hi All, Quick intro, I'm a Linux enthousiast / developer. Some time ago I've tried to use the cardreader of my HP PSC 1350 with an sd-card and it didn't work, the result was: Jul 14 21:39:38 shalem kernel: drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 3 if 1 alt 0 proto 2 vid 0x03F0 pid 0x3B11 Jul 14 21:39:38 shalem kernel: scsi5 : SCSI emulation for USB Mass Storage devices Jul 14 21:39:43 shalem kernel: scsi 5:0:0:0: Direct-Access HP 1.00 PQ: 0 ANSI: 2 Jul 14 21:39:43 shalem kernel: sd 5:0:0:0: [sdb] Attached SCSI removable disk Jul 14 21:39:43 shalem kernel: sd 5:0:0:0: Attached scsi generic sg2 type 0 Jul 14 21:40:31 shalem kernel: sd 5:0:0:0: [sdb] 1999872 512-byte hardware sectors (1024 MB) Jul 14 21:40:31 shalem kernel: sd 5:0:0:0: [sdb] Write Protect is off Jul 14 21:40:31 shalem kernel: sd 5:0:0:0: [sdb] Assuming drive cache: write through Jul 14 21:40:31 shalem kernel: sd 5:0:0:0: [sdb] 1999872 512-byte hardware sectors (1024 MB) Jul 14 21:40:31 shalem kernel: sd 5:0:0:0: [sdb] Write Protect is off Jul 14 21:40:31 shalem kernel: sd 5:0:0:0: [sdb] Assuming drive cache: write through Jul 14 21:40:31 shalem kernel: sdb: sdb1 Jul 14 21:40:32 shalem kernel: sd 5:0:0:0: [sdb] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE,SUGGEST_OK Jul 14 21:40:32 shalem kernel: sd 5:0:0:0: [sdb] Sense Key : Medium Error [current] Jul 14 21:40:32 shalem kernel: sd 5:0:0:0: [sdb] Add. Sense: Read error - loss of streaming Jul 14 21:40:32 shalem kernel: end_request: I/O error, dev sdb, sector 1999864
I noticed that the error were caused really close to the end of the sdcard, so I started experimenting, this resulted in me writing the following to the usb-storage mailinglist some time ago: --- So after 3 long evenings of debugging, I finally have my cardreader working "properly". At first I tried and succeeded with US_FL_FIX_CAPACITY, that worked but gave me warnings that the partition was larger then the device, and read access beyond the end of device errors. But it worked now! Further debugging has lead me to the following conclusion (with a few not suitable for submitting usb-storage mods to proof it, proof as in it works). The HP PSC 1350 reader will "crash" and from that moment on no longer communicate in any sane way, if you try to read the last sector of an sdcard* in a read that is more then 1 sector, so trying to read 8 sectors starting at sector capicity-8 will crash it, as will reading 2 sectors starting at sector capicity-2, however reading the last sector in a one 1 sector read will succeed! (* xdcards seem to be fine). I haven't tried if it will crash on larger then 1 sector writes which include the last sector too, I immediately added code to not do that in both the read and write paths. I have tested reading and writing the end of the disk with this kludge in and it works. As said I currently have an "really ugly" (tm) patch which modifies READ_10 and WRITE_10 commands in the usb-storage driver. Before I write a "proper" patch I have some questions: 1) currently I have decided to add quirk code for this to the usb-storage driver, as I don't want to polute the generic scsi code with this, but maybe it would be better to add a quirk for this to the scsi layer? 2) What on earth should I name the flag for this? 3) Currently I just shorten the read / write by one sector. The scsi layer then notices the 1 sector to short read/write and sends a new command for the last sector. This works well, but is it ok to depend on the scsi layer behaving this way? 4) Should I be checking for other READ_X and WRITE_x commands too? --- After some discussion I wrote a patch to the Linux kernel fixing this: http://people.atrpms.net/~hdegoede/usb-storage-psc1350-v2.patch Up till now however this patch has not been accepted yet, because its a bit ugly and the usb-storage maintainers would first like to see it being tested successfully be others. I've found several forum posts on the internet with people having the same problem, but sofar I haven't found anyone willing to test my patch and confirm it fixes things for them too. Which brings me to this list. Can you please: 1) Try the card reader of a HP PSC 1350 with Fedora 7 or another distro with kernel 2.6.22 (the kernel version might be important) and an sdcard and see if you get similar errors as I did? 2) Try the card reader of other HP printers with about the same age as the HP PSC 1350 with kernel 2.6.22 and an sdcard and see if you get similar errors as I did? 3) Try my patch and see if it fixes things for you. For easy testing I've made available a stand alone compilable patched usb-storage module here: http://people.atrpms.net/~hdegoede/usb-storage.tar.gz Usage instructions. <install kernel-devel, or your distro's equivalent> <untar> cd usb-storage make <unmount and unplug / turnoff any usb mass storage devices> sudo rmmod usb-storage insmod usb-storage.ko <turn on printer and plugin sd-card> Many many Thanks! Regards, Hans ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ HPLIP-Devel mailing list HPLIP-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hplip-devel