Page 1 of 1

Raspberry Pi USB Transfer

Posted: Thu Jul 04, 2013 10:49 pm
by blue.storm
Hello everyone,
I am working on writing my own userspace USB driver for an old webcam I have Creative PD1100, I have built the driver using "libusb" and it works fine on ubuntu and Mac.

However when I try to run the driver on the PI and read data ISOCHRONOUSLY from the camera, it seems by sniffing the data it is working correctly, Also, in the driver packets are being sent and their sizes seems logical and the status of the transfer is success but libusb allocated buffer is never written to and it always return zeroes.

My guess is that the reason for the problem is that the allocated buffer is not contiguous as mandated here:

[Pointer to the buffer to be used when sending data to the device (for an OUT urb) or when receiving data from the device (for an IN urb). In order for the host controller to properly access this buffer, it must be created with a call to kmalloc, not on the stack or statically.] Source: http://www.makelinux.net/ldd3/chp-13-sect-3
-----------------------
To offer contiguous allocation I should use kmalloc but that is out of my knowledge and requires kernel programming, is there another solution, am I even thinking in the right direction?

I have found a similar issue on this forum:
http://www.raspberrypi.org/phpBB3//view ... 7&p=124424
Thanks for your help!

Re: Raspberry Pi USB Transfer

Posted: Fri Jul 05, 2013 5:57 am
by gsh
A buffer allocated using kmalloc resides in the kernel memory space that is always mapped into the MMU (so that if you interrupt a user application the interrupt (running at supervisor level) can access any kernel memory without having to touch the MMU setup, this takes a long time

If you have done the wrong thing then it should crash or you'd receive an error when adding the buffer...

Gordon

Re: Raspberry Pi USB Transfer

Posted: Fri Jul 05, 2013 6:01 am
by gsh
Since you are writing a userspace driver that documentation isn't really relevant, that is the specification for the kernel driver... libusb should be handling the copy to user copy from user stuff to make sure the data is going to be available...

We know it should work (many isochronous devices do work...)

Don't forget that isochronous is significantly different to bulk, you do need to treat it like a stream, I think it'll return an empty buffer if it transfers no data... Fill the buffer with known data beforehand to see if it's being overwritten...

Gordon