2019-01-18 10:21 AM
I am working on testing libopencm3 based USB OTG FS stack for STM32F411/STM32F413. And OTG FS stack works fine to begin with without any issues. But, after a while it seems to lock-up waiting for transfer complete interrupt to fire on one of the IN endpoints.
The test script running on the PC repeatedly sends messages to the OTG device and device also sends data back. This seems to run fine for a while but eventually gets locked-up.
I have a debugger hooked and on lock-up i observe that the transfer complete interrupt on an IN endpoint never fired, causing to device to hang.
Browsing for similar issue i have come across multiple posts where people have reported similar problems and it looks like TX FIFO access has some limitations.
Can someone please shed more light on how to fix this bug. We have been debugging this for a while and haven't been successful in fixing this. Any inputs would be highly appreciated.
2019-01-18 11:39 AM
> I have a debugger hooked
Are you sure it does not access the OTG registers *before* the lockup occurs? Debugger reads are intrusive with registers which change content or hardware state upon read (e.g. OTG_GRXSTSP).
Make sure the FIFO write is not interrupted with any code which would access any other OTG resource, including other FIFOs (OS sounds much like an opportunity to such problem). Make sure the number of FIFO writes is correctly rounded up to whole words, and that all writes are in words and to address properly aligned to word. Observe OTG_DTXFSTSx, make sure there's always enough space available in the given FIFO before start writing, observe its value (as well as DIEPTSIZx, DIEPCTLx, DIEPINTx value) when lockup.
JW
2019-01-18 12:15 PM
.
2019-01-18 12:16 PM
Thanks for your response, much appreciated. I have couple of queries as below:
BTW,
Please do share your inputs.
2019-01-18 12:52 PM
Let's not accuse the debugger right now, leave it for later, but make sure all "view" windows (register view, memory view) are closed while running, "live view" features are switched off, and that there are no data breakpoints or any other feature which might be suspicious of potentially involve autonomous unprovoked reads.
I'm not absolutely sure how to interpret the readout values you presented, but at the first sight they appear to be OK.
Increase the TX FIFO size so that you'll always see some "residuum". How exactly do you write to the FIFO area? Do you write to a single address in the FIFO area, or are you incrementing the address? Store the intended number of writes before starting writing to FIFO to a static/global variable, so that it could be checked when the problem occurs. Similarly store the value you are writing to DIEPTSIZ for later checking (any other interesting register writes too perhaps).
JW
2019-01-18 01:04 PM
Thanks again. To answer your question yes I am incrementing the FIFO address as I write to it.
will try to save the buffer contents and the register values before initiating the transfer and come back with more data.
Regards,
md.suhel7
2019-01-18 01:34 PM
And increase the FIFO size so that the remainder when writing maxpacket is not 0.
And try to not increment the FIFO address when writing.
JW
2019-01-21 09:41 AM
I tried to increment the FIFO size to more than the maxpacket and did not increment the FIFO address when writing.
But, i still notice the USB getting locked up. Any other suggestions?
2019-01-21 09:43 AM
Also i tried testing without debugger as well and i still notice the lock-up.
2019-01-21 10:20 AM
Guys, any inputs?