I'm adding support (OK, *trying* to add support...) for a USB
programmer in flashrom. I've had it working without error, but at an
incredibly slow rate due to a tiny 128 byte chunk size, which is all I
can get it to work with.
This (USB driver development) is new to me so I expected to hit a few
problems and learn along the way... but I'm at a point where I don't
know where the problem is and could use a push in the right direction.
A linux+libusb1.0 program already exists, which is using async bulk
transfer and 8192 byte chunks. The closed source Windows driver reads
in the same way but 4096 byte chunks.
As far as I know, the legacy libusb 0.1 does not support async so I
can't just copy/paste code here.
The error occurs at 160 bytes, which happens to be the same number
that is returned as "URB length" in a "-ENOENT" packet immediately
following the read request - probably not a coincidence.
Here's a small example of what's going on in a printf-heavy version
(the "ff ff ff ff" is expected at the start of each chunk):
begin loop
len=4178502, max_payload=7901
usb write (out) (8192 bytes)
[read #00] (32 bytes): ff ff ff ff c0 44 46 c2 ...
[read #01] (32 bytes): 57 c0 c0 9d 8f 00 f0 ...
[read #02] (32 bytes): 00 04 bd 17 0f 41 00 ...
[read #03] (32 bytes): 9f ff ef 2f ff 00 04 7f ...
[read #04] (32 bytes): ERROR ret=-110
end loop
begin loop
len=4170601, max_payload=7901
usb write (out) (8192 bytes)
[read #00] (32 bytes): ff ff ff ff 00 00 00 00 ...
[read #01] (32 bytes): 00 00 00 00 00 ...
[read #02] (32 bytes): c3 00 00 80 00 00 00 ...
[read #03] (32 bytes): 20 c0 80 00 1a 40 ...
[read #04] (32 bytes): ERROR ret=-110
end loop
My current thoughts are:
- I'm doing this completely wrong for legacy libusb
- I haven't found the secret "enable large read buffers" command to
send the device
- Something in flashrom is changing how this should work
- Something really simple like a value out by 1, although that
wouldn't explain why it works up until the 5th read of each block
I'm not after being spoonfed - but if anyone can give a hint as to
where I should be looking or what I may have done wrong that'd help!
Thanks,
Steven