I noticed a possible error in the Starterware USB double-buffering FIFO routines. At the very least it is a point of confusion, and possibly a software bug.
The USB FIFO size is set in the TXFIFOSZ and RXFIFOSZ registers, where bit 4 (or "DPB") is set for double buffering, and where the lower 4 bits is m (or "SZ", which is short for size). (For example, m = 0x0F & TXFIFOSZ)
According to the manual:
"the FIFO size is calculated as 2^(m+3) for single packet buffering, and 2^(m+4) for dual packet buffering."
In other words, the same number, m, is interpreted differently depending on whether bit 4 is set. Setting bit 4, by itself, doubles the total FIFO memory size. I think the manual is likely correct on this point. (Reference: OMAP-L138 DSP+ARM Technical Reference Manual, file SPRUH77A.pdf, sections 35.4.55 and 35.4.56)
However, that appears to be in discrepancy with the Starterware USB software.
For example, take the following two items (from usb.h)
#define USB_FIFO_SZ_512 0x00000006 // 512 byte FIFO
...
#define USB_FIFO_SZ_512_DB 0x00000017 // 512 byte double buffered FIFO
// (occupying 1024 bytes)
Those items are used in the function USBFIFOConfigSet() to configure the FIFO sizes.
Compare those two items. Notice that the double-buffering item adds 1, (from 6 to 7), thereby doubling the FIFO memory size, and it also sets bit 4, (resulting in 0x17), which as I showed above also doubles the FIFO memory size. It results in four times the memory usage, not just double. This will throw off the memory assignment, likely resulting in overlapping buffers. (I suspect this may explain why so many people are expressing trouble with double-buffering.)
Unfortunately, the double-buffering values (e.g., USB_FIFO_SZ_512_DB) are used in more than one place, sometimes correctly, and other times not. So the problem cannot be cured by simply redefining USB_FIFO_SZ_512_DB.
The error occurs when you use those values in the library routine for configuring the FIFOs.
USBFIFOConfigSet(USB0_BASE, USB_EP_1, 64, USB_FIFO_SZ_512_DB, USB_EP_DEV_IN)
That will result in a FIFO size of 2048 bytes, not 1024.
The fix can occur like this:
#define DOUBLE_BUF_FIFO 0x10
USBFIFOConfigSet(USB0_BASE, USB_EP_1, 64, (USB_FIFO_SZ_512 + DOUBLE_BUF_FIFO), USB_EP_DEV_IN)
-- Walter Snafu