cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F107 and USB Stick - Read fails after few packets

js23
Associate III
Posted on December 06, 2010 at 11:36

STM32F107 and USB Stick - Read fails after few packets

5 REPLIES 5
js23
Associate III
Posted on May 17, 2011 at 14:17

After further investigation it seems to me, that the OTG core receives some packets and does not store them in the FIFO. When the problem occurs during a transfer of a block (512 Bytes = 8x 64Byte packets) PKTCNT in HCTSIZ is set to 0, but only half of the packets (4 out of 8) are reported, stored and fetched from the FIFO. No RXLVL for the remaining 4 packets occurs, but I do get some ACK interrups. Like if there were empty packets sent by the USB stick.

Currently I am stuck and have no ideas any more. (Besides moving to the LPC1768...). Any suggestions are welcome...
stforum2
Associate II
Posted on May 17, 2011 at 14:17

How about programming another board (an STM32F103 board for instance) as a USB mass storage device and communicating with that.  Then you will be able to monitor (and control) exactly what is being sent to the STM32F107.

js23
Associate III
Posted on May 17, 2011 at 14:17

Yep, I already considered that, too. But this will make things really complicated. Especially as the OTG controllers are not easy to debug - they change their state by simply reading a register (GRXSTSP). Maybe the non OTG in the F103 is more user friendly? but I am not familiar with it at all...

Of course the easiest solution would be to buy a USB protocol analyzer. And at the same time the most expensive, I guess.

If there is a way to find out what deivce is sending on the USB bus, I would simply hook the logic analyzer to it. Because of frame positions, length of signal, etc. some information can be collected without looking at the bytes in detail. This may be enough at the moment and help to get further. Maybe.
js23
Associate III
Posted on May 17, 2011 at 14:17

Ok, finally: Bug found, it is WORKING!!

 

The problem was: FIFO sizes are given in WORDS. What a stupid, stupid bug. S*$''$§ !! It took me >50h to find out.

What happened: The RXFIFO run into the HNPTXFIFO after a few blocks. And the results are... well... entertaining.

My first thought was, that the code in the OTG lib was wrong, but now it makes sense...

Thank you for listening. And having a place to complain ;)

Regards,

Johannes

sami
Associate II
Posted on May 17, 2011 at 14:17

could you share your code please ?