wMaxPacketSize declared in the descriptor is just to inform the host the size... if you have going to override this in your firmware, when the host requests for data and the device is capable of responding with packets up to 1024 bytes... here the problem is if the device is gonna send a bulk packet of size greater than 512 bytes it will most likely crash the host i.e drivers don't try to catch all exceptions mainly under the assumption that the device at least follow the hard and fast rules set by the spec.... btw why do you want to do this???
Thanks for feedback.
I implemented cypress chip as slave fifo with EP2IN size 1024 and wMaxPacketSize set to 1024 because at that time I did not know that wMaxPacketSize is limited to 512 for BULK transfers.
This by the way worked perfectly for windows and linux (It seems they manage this case at kernel level).
But I have problems under Mac OS X and I discovered the wMaxPacketSize limitation to 512.
Setting EP2IN size to 512 in firmware like this:
EP2CFG = 0xE0; // EP2IN, bulk, size 512, 4x buffered
Did not work.
At hardware side (slave fifo side) I only use manual commit packets and no auto-commits.
For that reason I expected to keep mi EP2IN size 1024 but set wMaxPacketSize to 512.
But This does not work either.
To make it simpler, would you say wMaxPacketSize should always be the same size than size set in EP2CFG? That in fact will answer every thing!
ya.... you got it....
Everything is fine now.
My device (hardware, firmware and driver) works perfectly.
Hi , i have small question about it
i also defined the EP2 1024 and wMaxPacketSize as 1024 using windows and it worked fine.
the question is using 1024 is better then 512 in performance despite that in the sepc of usb 2.0 it defined as 512? if it does not improve performance why use 1024? is it safe to use 1024?
It is not safe to use 1024. Some host controllers might take it lightly but not all host controllers do. You might run into BSOD on certain machines.
Taking the better bandwidth theory. why not take it more than 1024? The buffer required, error handling etc are gonna scale up accordingly. 4 types of transfers are given to work with these tradeoffs.
What if i want to transfer a large file? For example a picture. Because I am encountering a problem that is the buffer cannot store all of the data of the picture instead it only captures a segment of it.
Please see the attachments.
13.PNG 163.8 K