Page 7 of 12
Re: example interfacing a STM32F4 with libusb
Posted: Sat Aug 11, 2012 1:30 am
by Mathias
You mean something like Wireshark? Wireshark helped me quite a lot in the beginning, when I didn't get the device registered at all. But I'm not sure if any analyzer can help to improve the speed. Either the hardware gets the packets stuffed into a frame or not... well maybe the timing could tell you something.
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 11:18 am
by Giovanni
Hi,
I committed changes to the STM32 USB-OTG driver which *should* enable higher speeds. Basically it implements what has already been discussed in this thread (note there is an extra field in the EP configuration structure).
Being in vacation I have only access to my "portable lab" with no way to confirm if the driver is indeed faster thanks to the deeper FIFOs but apparently it works correctly.
Any help in testing the driver would really be welcome.
Giovanni
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 11:52 am
by kjellhar
A quick run through Mathias' code is all I can do right now. As far as I can tell, the speed is 64kBytes/sec. I set the buffer multiplier to 3.
Kjell
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 12:34 pm
by Giovanni
If you use serial_usb you have to increase the queue size too or the transaction will still be "short".
Giovanni
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 12:48 pm
by kjellhar
I haven't checked lately, but I always thought Mathias used usb, not serial_usb.
Need to look closer at the code before I conclude in any direction.
Kjell
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 12:55 pm
by Giovanni
Hi,
I forgot I have Linux on the laptop, I can use the "dd" command.
I am getting 128KB/sec using the multiplier set to two, which is the expected value. Now I am going to try with deeper FIFOs.
Giovanni
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 1:19 pm
by Giovanni
Using 4 as multiplier yields 256KB/Sec, it scales correctly with FIFO depth.
I added an "usbblast" command to the demo shell in order to output data at high rate, any key stops the transmission and returns control to the shell (the demo is defaulted to a multiplier of 4 for the IN bulk endpoint).
Amazingly the changes to the driver were quite limited.
Giovanni
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 1:20 pm
by kjellhar
Giovanni wrote:Hi,
I forgot I have Linux on the laptop, I can use the "dd" command.
I am getting 128KB/sec using the multiplier set to two, which is the expected value. Now I am going to try with deeper FIFOs.
Giovanni
Ah, but that is what I think is wrong. As long as the FIFO size for the IN endpoint is equal to, or larger than 2x max packet size, and the interrupt is set to trigger on FIFO half empty, the speed should be more than that. If there is no other traffic on the USB bus, it should approach the 12Mbps (minus USB overhead). 1Mbyte/sec should be possible.
The problem as far as I can tell is that the interrupt is not triggered by the FIFO source for some reason. Even if the OTG_FS_DIEPINTx->TXFE is set, I cannot see that the ISR is called until the SOF is detected.
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 1:27 pm
by Giovanni
kjellhar wrote:Ah, but that is what I think is wrong. As long as the FIFO size for the IN endpoint is equal to, or larger than 2x max packet size, and the interrupt is set to trigger on FIFO half empty, the speed should be more than that. If there is no other traffic on the USB bus, it should approach the 12Mbps (minus USB overhead). 1Mbyte/sec should be possible.
The transmission is split in "transactions", the driver cannot push the packets of the next transaction in the TXFIFO until the previous transaction is over and the application submits the next transaction buffer.
So the worst between FIFO size and transaction size is what limits the usable bandwidth.
I don't think there is a workaround for this, it is how the USB peripheral works (and may be intrinsic to the USB protocol).
Giovanni
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 1:58 pm
by Giovanni
Ok, after thinking a bit about it now I think you are right, it should scale with the transaction size as long the multiplier is at least 2.
This does not happen, something is still hiding in there.
Giovanni